-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove pkg level state #95
Remove pkg level state #95
Conversation
Codecov Report
@@ Coverage Diff @@
## main #95 +/- ##
==========================================
+ Coverage 51.87% 54.54% +2.67%
==========================================
Files 3 3
Lines 401 374 -27
==========================================
- Hits 208 204 -4
+ Misses 164 140 -24
- Partials 29 30 +1
Continue to review full report at Codecov.
|
219f89a
to
769ef57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just one minor change on test log initialization
59f53c2
59f53c2
to
8902d05
Compare
@mmlb is this potentially a problem? |
As part of 0.7 id like to see these deprecated anyway, removed in 0.8. The endpoint retrieved its data from a variable that didn't have any definition other than indicating it was JSON. The variable was unset suggesting it was set during build time so I felt comfortable removing that instead returning a defined payload. The fact this is v0 and that this data had no structure to it, it felt appropriate to strip it out. |
Signed-off-by: Chris Doherty <[email protected]>
Signed-off-by: Chris Doherty <[email protected]>
Signed-off-by: Chris Doherty <[email protected]>
8902d05
to
4f6bc9e
Compare
## Description Builds on #95 (rebased after PR was created) This feature builds on #81 and realizes the Hegel portion of the [Kubernetes back-end proposal](https://github.com/tinkerbell/proposals/tree/main/proposals/0026). Having generalized the client used to acquire metadata, this PR implements a Kubernetes client that leverages an internal client caching mechanism so as to reduce load on the Kubernetes API Server. Additionally, I put some effort into reworking the Hegel Dockerfile so it could leverage layer caching for Go module dependencies and added an image build command to the Makefile. The `Watch` API for the client is unimplemented and scheduled for a follow up. This is so we can get off the ground for machine provisioning. The `Watch` API is used for subscription capabilities so doesn't feature in metadata retrieval. ## How Has This Been Tested? Built and ran the image with the Kubernetes back-end enabled talking to a KinD cluster containing the necessary CRDs and a `Hardware` resource. ## How are existing users impacted? What migration steps/scripts do we need? None. Users enable the Kubernetes back-end by setting the `DATA_MODEL_VERSION=kubernetes` plus some additional env vars. ## Future work - Implement the `Watch` API for consistency with other back-ends.
The branch got messed up during a rebase and Github automatically closed the previous PR (#87). All comments from the previous PR have been addressed.
The primary purpose of this PR is to strip package level state from the service. Global state contributes to application complexity that is considered the cause for many bugs. Package state is 1 notch behind global state.
Package state has been replaced with explicit dependency declarations in functions and, consequently, injected dependencies. This lays a foundation for further refactoring to bring about cleaner code that's easier to work with.
With the state removal some additional fixes and restructuring was done; specifics:
http.Handler
that leverages the injected dependencies.metrics
package and is launched as a distinct goroutine.http.StatusInternalServerError
codes are written.Content-Type
headers as the setter was called afterWriteHeader()
meaning it has no effect.git_rev
as the JSON key.http-server
package tohttp
andgrpc-server
package togrpc
; these changes have been isolated on their own commit for ease of reviewing.Metric package state is untouched given it'll likely require a more thought out refactor than simply removing the state and injecting a dependency.
Similarly, I've purposely avoided writing additional tests as I'd like to do a hoslitic rework of unit and e2e testing.
The only behavioral change is that the
/_packet/version
endpoint payload is now structured and may be different to existing expectations.