-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add support for entity guid in health #420
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
Open
danielstokes
wants to merge
19
commits into
main
Choose a base branch
from
feat-entity-guid
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
95ea28a
feat: add support for entity guid in health
danielstokes cf6a502
slight restructure to make some code more testable
danielstokes c9fdd95
move some comments back
danielstokes 50b06ad
add tests for checking instrumentation status diff
danielstokes 90e93e0
add instrumentation webhook defaulter tests
danielstokes 0dc9361
change ci
danielstokes 0ee922f
minor fixes
danielstokes dd240b8
fix chart
danielstokes bcde222
test instrumentation conversion
danielstokes 53637b5
fix e2e tests; update crd
danielstokes 7506df3
extend time to run e2e tests
danielstokes 9bbc812
Merge branch 'main' into feat-entity-guid
danielstokes 9324968
trigger ci
danielstokes 465ae2f
trigger ci
danielstokes ab1e962
Merge branch 'main' into feat-entity-guid
danielstokes 237381c
trigger ci
danielstokes 4579daf
codecov is being annoying
danielstokes 04f72e0
codecov is being annoying
danielstokes 97754e8
codecov is being annoying
danielstokes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,152 @@ | ||
| package v1beta2 | ||
|
|
||
| // Hub marks this type as a conversion hub. | ||
| func (*Instrumentation) Hub() {} | ||
| import ( | ||
| "github.com/newrelic/k8s-agents-operator/api/current" | ||
| "sigs.k8s.io/controller-runtime/pkg/conversion" | ||
| ) | ||
|
|
||
| // ConvertTo converts this Instrumentation to the Hub version. | ||
| func (src *Instrumentation) ConvertTo(dstRaw conversion.Hub) error { | ||
| dst := dstRaw.(*current.Instrumentation) | ||
|
|
||
| // ObjectMeta | ||
| dst.ObjectMeta = src.ObjectMeta | ||
|
|
||
| for _, srcExpr := range src.Spec.ContainerSelector.ImageSelector.MatchExpressions { | ||
| dst.Spec.ContainerSelector.ImageSelector.MatchExpressions = append(dst.Spec.ContainerSelector.ImageSelector.MatchExpressions, current.ImageSelectorRequirement{ | ||
| Key: current.ImageSelectorKey(srcExpr.Key), Operator: current.ImageSelectorOperator(srcExpr.Operator), Values: srcExpr.Values, | ||
| }) | ||
| } | ||
| for _, srcExpr := range src.Spec.ContainerSelector.EnvSelector.MatchExpressions { | ||
| dst.Spec.ContainerSelector.EnvSelector.MatchExpressions = append(dst.Spec.ContainerSelector.EnvSelector.MatchExpressions, current.EnvSelectorRequirement{ | ||
| Key: srcExpr.Key, Operator: current.EnvSelectorOperator(srcExpr.Operator), Values: srcExpr.Values, | ||
| }) | ||
| } | ||
| for _, srcExpr := range src.Spec.ContainerSelector.NameSelector.MatchExpressions { | ||
| dst.Spec.ContainerSelector.NameSelector.MatchExpressions = append(dst.Spec.ContainerSelector.NameSelector.MatchExpressions, current.NameSelectorRequirement{ | ||
| Key: current.NameSelectorKey(srcExpr.Key), Operator: current.NameSelectorOperator(srcExpr.Operator), Values: srcExpr.Values, | ||
| }) | ||
| } | ||
|
|
||
| dst.Spec.ContainerSelector.ImageSelector.MatchImages = src.Spec.ContainerSelector.ImageSelector.MatchImages | ||
| dst.Spec.ContainerSelector.EnvSelector.MatchEnvs = src.Spec.ContainerSelector.EnvSelector.MatchEnvs | ||
| dst.Spec.ContainerSelector.NameSelector.MatchNames = src.Spec.ContainerSelector.NameSelector.MatchNames | ||
| dst.Spec.ContainerSelector.NamesFromPodAnnotation = src.Spec.ContainerSelector.NamesFromPodAnnotation | ||
|
|
||
| dst.Spec.PodLabelSelector = src.Spec.PodLabelSelector | ||
| dst.Spec.NamespaceLabelSelector = src.Spec.NamespaceLabelSelector | ||
| dst.Spec.LicenseKeySecret = src.Spec.LicenseKeySecret | ||
| dst.Spec.AgentConfigMap = src.Spec.AgentConfigMap | ||
| dst.Spec.Agent = current.Agent{ | ||
| Language: src.Spec.Agent.Language, | ||
| Image: src.Spec.Agent.Image, | ||
| VolumeSizeLimit: src.Spec.Agent.VolumeSizeLimit, | ||
| Env: src.Spec.Agent.Env, | ||
| Resources: src.Spec.Agent.Resources, | ||
| ImagePullPolicy: src.Spec.Agent.ImagePullPolicy, | ||
| SecurityContext: src.Spec.Agent.SecurityContext, | ||
| } | ||
| dst.Spec.HealthAgent = current.HealthAgent{ | ||
| Image: src.Spec.HealthAgent.Image, | ||
| Env: src.Spec.HealthAgent.Env, | ||
| ImagePullPolicy: src.Spec.HealthAgent.ImagePullPolicy, | ||
| SecurityContext: src.Spec.HealthAgent.SecurityContext, | ||
| Resources: src.Spec.HealthAgent.Resources, | ||
| } | ||
| var unhealthyPodErrors []current.UnhealthyPodError | ||
| if l := len(src.Status.UnhealthyPodsErrors); l > 0 { | ||
| unhealthyPodErrors = make([]current.UnhealthyPodError, l) | ||
| for i, e := range src.Status.UnhealthyPodsErrors { | ||
| unhealthyPodErrors[i] = current.UnhealthyPodError{ | ||
| Pod: e.Pod, | ||
| LastError: e.LastError, | ||
| } | ||
| } | ||
| } | ||
| dst.Status = current.InstrumentationStatus{ | ||
| PodsMatching: src.Status.PodsMatching, | ||
| PodsUnhealthy: src.Status.PodsUnhealthy, | ||
| PodsHealthy: src.Status.PodsHealthy, | ||
| PodsInjected: src.Status.PodsInjected, | ||
| PodsOutdated: src.Status.PodsOutdated, | ||
| PodsNotReady: src.Status.PodsNotReady, | ||
| UnhealthyPodsErrors: unhealthyPodErrors, | ||
| LastUpdated: src.Status.LastUpdated, | ||
| ObservedVersion: src.Status.ObservedVersion, | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // ConvertFrom converts from the Hub version to this version. | ||
| func (dst *Instrumentation) ConvertFrom(srcRaw conversion.Hub) error { | ||
| src := srcRaw.(*current.Instrumentation) | ||
|
|
||
| // ObjectMeta | ||
| dst.ObjectMeta = src.ObjectMeta | ||
|
|
||
| // Spec | ||
|
|
||
| for _, srcExpr := range src.Spec.ContainerSelector.ImageSelector.MatchExpressions { | ||
| dst.Spec.ContainerSelector.ImageSelector.MatchExpressions = append(dst.Spec.ContainerSelector.ImageSelector.MatchExpressions, ImageSelectorRequirement{ | ||
| Key: ImageSelectorKey(srcExpr.Key), Operator: ImageSelectorOperator(srcExpr.Operator), Values: srcExpr.Values, | ||
| }) | ||
| } | ||
| for _, srcExpr := range src.Spec.ContainerSelector.EnvSelector.MatchExpressions { | ||
| dst.Spec.ContainerSelector.EnvSelector.MatchExpressions = append(dst.Spec.ContainerSelector.EnvSelector.MatchExpressions, EnvSelectorRequirement{ | ||
| Key: srcExpr.Key, Operator: EnvSelectorOperator(srcExpr.Operator), Values: srcExpr.Values, | ||
| }) | ||
| } | ||
| for _, srcExpr := range src.Spec.ContainerSelector.NameSelector.MatchExpressions { | ||
| dst.Spec.ContainerSelector.NameSelector.MatchExpressions = append(dst.Spec.ContainerSelector.NameSelector.MatchExpressions, NameSelectorRequirement{ | ||
| Key: NameSelectorKey(srcExpr.Key), Operator: NameSelectorOperator(srcExpr.Operator), Values: srcExpr.Values, | ||
| }) | ||
| } | ||
|
|
||
| dst.Spec.ContainerSelector.ImageSelector.MatchImages = src.Spec.ContainerSelector.ImageSelector.MatchImages | ||
| dst.Spec.ContainerSelector.EnvSelector.MatchEnvs = src.Spec.ContainerSelector.EnvSelector.MatchEnvs | ||
| dst.Spec.ContainerSelector.NameSelector.MatchNames = src.Spec.ContainerSelector.NameSelector.MatchNames | ||
| dst.Spec.ContainerSelector.NamesFromPodAnnotation = src.Spec.ContainerSelector.NamesFromPodAnnotation | ||
|
|
||
| dst.Spec.PodLabelSelector = src.Spec.PodLabelSelector | ||
| dst.Spec.NamespaceLabelSelector = src.Spec.NamespaceLabelSelector | ||
| dst.Spec.LicenseKeySecret = src.Spec.LicenseKeySecret | ||
| dst.Spec.Agent = Agent{ | ||
| Env: src.Spec.Agent.Env, | ||
| Image: src.Spec.Agent.Image, | ||
| ImagePullPolicy: src.Spec.Agent.ImagePullPolicy, | ||
| Language: src.Spec.Agent.Language, | ||
| Resources: src.Spec.Agent.Resources, | ||
| SecurityContext: src.Spec.Agent.SecurityContext, | ||
| VolumeSizeLimit: src.Spec.Agent.VolumeSizeLimit, | ||
| } | ||
| dst.Spec.HealthAgent = HealthAgent{ | ||
| Env: src.Spec.HealthAgent.Env, | ||
| Image: src.Spec.HealthAgent.Image, | ||
| ImagePullPolicy: src.Spec.HealthAgent.ImagePullPolicy, | ||
| Resources: src.Spec.HealthAgent.Resources, | ||
| SecurityContext: src.Spec.HealthAgent.SecurityContext, | ||
| } | ||
| dst.Spec.AgentConfigMap = src.Spec.AgentConfigMap | ||
| var unhealthyPodErrors []UnhealthyPodError | ||
| if l := len(src.Status.UnhealthyPodsErrors); l > 0 { | ||
| unhealthyPodErrors = make([]UnhealthyPodError, l) | ||
| for i, e := range src.Status.UnhealthyPodsErrors { | ||
| unhealthyPodErrors[i] = UnhealthyPodError{ | ||
| Pod: e.Pod, | ||
| LastError: e.LastError, | ||
| } | ||
| } | ||
| } | ||
| dst.Status = InstrumentationStatus{ | ||
| PodsMatching: src.Status.PodsMatching, | ||
| PodsUnhealthy: src.Status.PodsUnhealthy, | ||
| PodsHealthy: src.Status.PodsHealthy, | ||
| PodsInjected: src.Status.PodsInjected, | ||
| PodsOutdated: src.Status.PodsOutdated, | ||
| PodsNotReady: src.Status.PodsNotReady, | ||
| UnhealthyPodsErrors: unhealthyPodErrors, | ||
| LastUpdated: src.Status.LastUpdated, | ||
| ObservedVersion: src.Status.ObservedVersion, | ||
| } | ||
| return nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't this unnecessary since the matrix doesn't have these versions?
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.
To be honest, I'm a bit disappointed in the github api. I should have permission to remove them (they're required actions), but they are not visible to me unless I add them, but even if I remove the requirement later it doesn't fix the issue. It's hacky, but I don't have another solution.
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.
have you tried through the UI? I can show you how to change the required ones.