-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Fix invalid revision in IOP #28784
Fix invalid revision in IOP #28784
Conversation
/test integ-helm-tests_istio |
/test integ-security-k8s-tests_istio |
808add1
to
9a82ea7
Compare
@howardjohn PTAL. |
@shamsher31 - I think #24819 is more generic than fixing bad revision. So I think we should still keep it open even if this PR is merged. Probably we should convert it to an umbrella issue to track these kind of stuff? |
@esnible PTAL and provide your feedback on this. |
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 like the way this is headed.
@howardjohn has a good point that it is strange to validate inside UnmarshalIOP(). My first idea was that UnmarshallIOP should change non-String Revision to a string, but that the revision itself should be validated elsewhere.
However, this might be too much flexibility. Perhaps UnmarshallIOP() should reject non-strings. It is unclear if the message when a non-string YAML arrives should be "revision must be a string" or the better message you have that requires calling validate inside unmarshal. For Istio developers rejecting non-string is the most helpful, as it keeps the unmarshal method generic. Users might prefer to get a good error message the first time, rather than a generic message. Whichever approach you take, make sure the call to validate the version is inside the function that validates the IOP even if it is already called when unmarshalling.
0782e8f
to
1129268
Compare
Agree. Updated to check just non-string revision in UnmarshallIOP().
Invalid string revision is checked in the validation step here #28745
@esnible Please take another look. |
@esnible PTAL. |
@@ -284,6 +284,11 @@ func UnmarshalIOP(iopYAML string) (*v1alpha1.IstioOperator, error) { | |||
un.SetCreationTimestamp(meta_v1.Time{}) // UnmarshalIstioOperator chokes on these | |||
iopYAML = util.ToYAML(un) | |||
} | |||
// TODO: find a better way to validate all the invalid values in IOP YAML | |||
// before it is unmarshal into IstioOperator |
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.
Not sure if the code has changed or I am just repeating myself, but I still don't think this is right.
First, this method is extremely inefficient. First we take a yaml string, then marshal to a map, then back to yaml, then marshal to a map again, then marshal to IstioOperator. This feels very wrong and contributes to massive memory allocations (it may seem like speed doesn't matter much since its a one-shot CLI tool, and it doesn't, but the amount of allocations we do is so high it makes our unit tests noticeably slow)
Second, why is revision special? Don't we have the same problem with every other field?
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 had problems in the past with IOPs with creation timestamps. (e.g. istioctl/pkg/install/pre-check.go, istioctl/pkg/verifier/verifier.go and already in operator/pkg/validate/common.go.). However, I have retested by removing the clearing of creation time from istioctl x precheck
and I see no problems. Let's stop introducing the clearing of Time fields until we can identify a way to reproduce.
@howardjohn @esnible Does it make sense to merge this PR or we are ok with invalid revision in IOP? |
@shamsher31 I suggest we merge this. I approved it. @howardjohn What do you think? |
I will repeat my comment:
|
@ostromart @richardwxn WDYT about this fix? |
@istio/wg-environments-maintainers ping. |
my initial reaction to the code is are we sure this is conceptually the right fix? |
Closing as this is not a valid solution. |
To fix #24819
Related:
#28745
#28778