-
Notifications
You must be signed in to change notification settings - Fork 10
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
operator v1: add reproducer for drift detection with null #320
Conversation
@@ -17,6 +17,28 @@ import ( | |||
"github.com/stretchr/testify/require" | |||
) | |||
|
|||
func TestDiffWithNull(t *testing.T) { |
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.
test is expected to fail, currently it's a diff,keeping operator spinning forever.
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.
shall succeed now with the fix commit
@@ -145,6 +145,14 @@ func PropertiesEqual( | |||
l logr.Logger, v1, v2 interface{}, metadata rpadmin.ConfigPropertyMetadata, | |||
) bool { | |||
log := l.WithName("PropertiesEqual") | |||
|
|||
// "null" (string) is the only way to define null as the desired value. | |||
// Therefore, treat `"null"` as equal to `null` (only if `null` |
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.
Could you rephrase? The end of the sense is miss leading
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.
apparently i did not save the file. updated the comment
09ecb1c
to
c2188e6
Compare
So, QQ about this -- it seems to me like this is potentially working around the fact that we're populating our
I'm wondering if it'd make more sense to just relax the type some and use some sort of schemaless field that we can unmarshal directly to a |
So there's another case were this will fail. I'm not entirely certain of how it happens but I've seen a cloud cluster have a numeric value specified in scientific notation ( Is there a reason we can't call |
string does not work well with json unmarshal. example: i set:
In yaml. json unmarshal does not work, because ofc, we could work around it, but i fear breaking stuff @chrisseto i have seen scientific notation as well somewhere. i do not recall for sure how it happens, but we don't want it (anymore).. i would be glad if we rejected that honestly. |
The problem with schemaless fields is that it makes the CRD "non-structural" which causes terraform's Long term, @RafalKorepta and I have discussed having separate CRDs for different use cases. We'd keep a structural schema to play nice with terraform and then an unstructured/schemaless one for GitOps setups. One would of the two would be a compatibility layer that just creates the other.
Seems like
If we don't have tests in this repo that catch these issues we'll always be afraid of breaking stuff. Only one way to find out ;) Refactoring all of this will be a good candidate to tackle with the merger work. We can punt until then. |
@@ -17,6 +17,28 @@ import ( | |||
"github.com/stretchr/testify/require" | |||
) | |||
|
|||
func TestDiffWithNull(t *testing.T) { |
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.
Would you mind copying the setup of a similar test that we have in operator/cmd/syncclusterconfig
? We stand up a redpanda test container to make sure that the config is actually accepted by the redpanda instance. Way faster than a full k8s setup with much more validation (and no need to write out the ConfigPropertyMetadata manually)
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.
Yep will add this test, i am interested in a few corner cases
|
||
// "null" (string) is the only way to define null as the desired value. | ||
// Therefore, treat `"null"` as equal to `null` (only if `"null"` is on the k8s side) | ||
if metadata.Nullable { |
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.
So this fixes the diffing but are we going to have bugs with actually setting null
values? If not does that mean we have duplicate code attempting to massage string values into the correct format? 😬
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.
we cannot set null
because our type in the CRD is string, so it can never be an actual nil. well, at least have null on the CRD side of things. but i suspect there's some magic in redpanda to turn "null" into null - this stuff actually worked, "null" turned into null in redpanda.
definitely needs more test for sure, i will add them hopefully tomorrow
this stops operator from detecting non-existing drifts over and over again, if "null" is used to set `null`. Since spec.additionalConfiguration is map[string]string, string "null" is the only way to set `null.`
c2188e6
to
b8a39e9
Compare
Fixed in #324 |
this is a reproducer that shows "null" is treated as a diff from
null
.