-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid error log when unmarshalling config for MC controller (#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]>
- Loading branch information
1 parent
d6f809f
commit b1b0cac
Showing
3 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2024 Antrea Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package multicluster | ||
|
||
import _ "embed" | ||
|
||
//go:embed config/default/configmap/controller_manager_config.yaml | ||
var DefaultControllerManagerConfigBytes []byte |