Skip to content
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

Commits on Oct 15, 2024

  1. Avoid error log when unmarshalling config for MC controller

    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]>
    antoninbas committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    88207cd View commit details
    Browse the repository at this point in the history