-
Notifications
You must be signed in to change notification settings - Fork 369
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
Avoid error log when unmarshalling config for MC controller #6744
Avoid error log when unmarshalling config for MC controller #6744
Conversation
The MultiClusterConfig struct does not have yaml tags, only json tags. Therefore, trying to unmarshal it as YAML (by calling yaml.UnmarshalLenient) will not work, and will show a log indicating that strict unmarshalling has failed. The resulting struct object will be all empty, since none of the fields can be decoded without a tag. A key observation is that calling yaml.UnmarshalLenient does not serve any purpose, as we are also calling runtime.DecodeInto (which will first convert the YAML data to JSON data, before unmarshalling). Hence we can just remove the call to yaml.UnmarshalLenient. We add a couple of unit tests, and in particular we validate that the default controller_manager_config.yaml config can be unmarshalled (strictly) to MultiClusterConfig. While this is slightly orthogonal to the issue being addressed here, it may help avoid issues in the future as it ensures that the default config is always in sync with the struct definition. Signed-off-by: Antonin Bas <[email protected]>
2ce03d9
to
88207cd
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, thanks for fixing 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.
LGTM
/test-multicluster-e2e |
1 similar comment
/test-multicluster-e2e |
@antoninbas We can ignore the multicluster e2e failure which should be fixed by the PR #6742 |
Thanks @luolanzone |
…o#6744) The MultiClusterConfig struct does not have yaml tags, only json tags. Therefore, trying to unmarshal it as YAML (by calling yaml.UnmarshalLenient) will not work, and will show a log indicating that strict unmarshalling has failed. The resulting struct object will be all empty, since none of the fields can be decoded without a tag. A key observation is that calling yaml.UnmarshalLenient does not serve any purpose, as we are also calling runtime.DecodeInto (which will first convert the YAML data to JSON data, before unmarshalling). Hence we can just remove the call to yaml.UnmarshalLenient. We add a couple of unit tests, and in particular we validate that the default controller_manager_config.yaml config can be unmarshalled (strictly) to MultiClusterConfig. While this is slightly orthogonal to the issue being addressed here, it may help avoid issues in the future as it ensures that the default config is always in sync with the struct definition. Signed-off-by: Antonin Bas <[email protected]>
The MultiClusterConfig struct does not have yaml tags, only json tags. Therefore, trying to unmarshal it as YAML (by calling yaml.UnmarshalLenient) will not work, and will show a log indicating that strict unmarshalling has failed. The resulting struct object will be all empty, since none of the fields can be decoded without a tag.
A key observation is that calling yaml.UnmarshalLenient does not serve any purpose, as we are also calling runtime.DecodeInto (which will first convert the YAML data to JSON data, before unmarshalling). Hence we can just remove the call to yaml.UnmarshalLenient.
We add a couple of unit tests, and in particular we validate that the default controller_manager_config.yaml config can be unmarshalled (strictly) to MultiClusterConfig. While this is slightly orthogonal to the issue being addressed here, it may help avoid issues in the future as it ensures that the default config is always in sync with the struct definition.