-
Notifications
You must be signed in to change notification settings - Fork 98
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
Introducing defaulting logic #324
Conversation
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.
This pull request does not contain a valid label. Please add one of the following labels: bug, enhancement, documentation
Codecov Report
@@ Coverage Diff @@
## main #324 +/- ##
==========================================
+ Coverage 59.07% 63.12% +4.05%
==========================================
Files 60 60
Lines 6370 6552 +182
==========================================
+ Hits 3763 4136 +373
+ Misses 2337 2119 -218
- Partials 270 297 +27
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Really like this implementation 👏
It is great improvement for the Operation UX!
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.
just small docs changes
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.
Great work, some comments. I think newer Operator with older CRDs will panic
(the opposite is also probably true), so we should state that somewhere in the README
.
|
||
// IsEqualStruct is a util fonction that returns whether 2 structures are the same | ||
// We compare the marchaled results to avoid traversing all fields and be agnostic of the struct. | ||
func IsEqualStruct(in interface{}, cmp interface{}) bool { |
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.
Looking at the PR, it looks like IsEqualStruct
is only used to compare userInput
and emptyStruct
, like v1alpha1.IsEqualStruct(dd.Spec.Agent, v1alpha1.DatadogAgentSpecAgentSpec{})
.
Doing JSON Marshalling is costly in terms of CPU and I wonder if we could do better here.
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.
I agree, it's not ideal... Because of the intricacy of the whole structure (with pointers of other structures etc), I decided to go the marchalling route to make sure that I would compare apple to apple.
I did look into a few alternatives with build tags, interfaces etc but that was the best I could find.
I did isolate the function on purpose though, in case we figure out something better.
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.
I would expect https://github.com/kubernetes/apimachinery/blob/master/pkg/api/equality/semantic.go to work in this scenario. We could extend the Semantic
var with more types if not.
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.
I looked into it a bit - It would probably work indeed. Though as it uses reflects under the hood I would be curious to benchmark the change. I will make a card so we can evaluate changing this bit of logic.
@@ -897,6 +893,26 @@ func defaultSystemProbeEnvVars() []corev1.EnvVar { | |||
Name: datadoghqv1alpha1.DDSystemProbeNPMEnabled, | |||
Value: "false", | |||
}, | |||
{ | |||
Name: datadoghqv1alpha1.DDSystemProbeConntrackEnabled, |
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.
It means it's no more possible to configure Agent through datadog.yaml
even if booleans are not set in DatadogAgent
CRD.
It's not a problem specific to this field, it has been there for a while, but with this PR we should take the time to clarify what we want to support there.
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.
Sorry, I don't get this one. Are you talking about the config file of the agent? Do you mean that we don't mirror values to this file?
Happy to chat about how you think we could approach this and use maybe this change to fix it.
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.
Any ENV variable that is set by default means that having a configuration in datadog.yaml
(and nothing set in DatadogAgent
) is not going to work, the value from datadog.yaml
being ignored.
As this PR handles defaulting, I think it's a good place to clarify what we want to do for these cases.
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.
The goal of this change was to surface defaulted values in the status and stop mutating the spec of the DDA.
But I agree with you, this problem should be tackled as part of the boarder defaulting initiative.
For the sake of unblocking iterations towards the GA, I am creating a task in our backlog to look into that.
I still have to work on the Features
, so all can be done in parallel once we merge this (which is a blocker for the rest).
c087c69
to
62021cf
Compare
@cswatt I actually tried to use your suggestions but it conflicts with the code gen tool that we use. |
Tried to use the operator 0.6.0 with the new CRD and also used the new controller with the old CRD and it went well. |
7129693
to
f684135
Compare
What does this PR do?
This PR introduces a new field in the status that surfaces the fields that have been defaulted as part of the defaulting logic of the DatadogAgent (DDA) object.
We do not update the spec of the DDA anymore, thus an update of the operator will directly benefit the deployment of the DDA.
Started using more pointers in order not to end up with empty structures in the object rendered.
Introduced the FeatureOverride method in order to take a second round of defaulting in case a certain feature is enabled (this is in order to accommodate our update work on simplifying Features)
Fixing the command used in the init-volume and the volumes mounted in case the Runtime security is enabled (or not).
Repackaged the defaults a bit.
Motivation
Get ready for GA.
Additional Notes
IsEqualStruct
extensively, which I introduced in order to properly compare the large DDA object that contains nested json and pointers.Describe your test plan
Create DDAs with limited elements in the spec and verify that the DefaultOverride reflects the proper defaults.