fix(pkg/agent): merge kubelet config content with flag defaults#8777
Draft
abigailliang-aks-sig-node wants to merge 2 commits into
Draft
fix(pkg/agent): merge kubelet config content with flag defaults#8777abigailliang-aks-sig-node wants to merge 2 commits into
abigailliang-aks-sig-node wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates how pkg/agent generates kubelet config-file JSON by merging sources: start from customKubeletConfig content and only backfill missing fields from flag-derived values, while keeping the existing kubelet CLI flag filtering behavior unchanged.
Changes:
- Refactors
GetKubeletConfigFileContentto build a content-derived config first, then merge in missing fields from the flag-derived config. - Introduces helper functions to merge config content and flags via a map-based merge.
- Adds a unit test to verify that content values are not overwritten while missing fields are filled from flags.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/agent/utils.go | Refactors kubelet config-file generation and adds helper-based merge logic; keeps CLI filtering semantics while preparing for a future “config-file authoritative” shift. |
| pkg/agent/utils_test.go | Adds a unit test validating that content wins on conflicts and flags backfill missing fields. |
Comment on lines
+651
to
+667
| func mergeKubeletConfigContentFromFlags(contentConfig, flagConfig *datamodel.AKSKubeletConfiguration) *datamodel.AKSKubeletConfiguration { | ||
| contentMap := kubeletConfigToMap(contentConfig) | ||
| flagMap := kubeletConfigToMap(flagConfig) | ||
| mergeMissingConfigFields(contentMap, flagMap) | ||
|
|
||
| mergedBytes, _ := json.Marshal(contentMap) | ||
| mergedConfig := &datamodel.AKSKubeletConfiguration{} | ||
| _ = json.Unmarshal(mergedBytes, mergedConfig) | ||
| return mergedConfig | ||
| } | ||
|
|
||
| func kubeletConfigToMap(config *datamodel.AKSKubeletConfiguration) map[string]interface{} { | ||
| configBytes, _ := json.Marshal(config) | ||
| configMap := map[string]interface{}{} | ||
| _ = json.Unmarshal(configBytes, &configMap) | ||
| return configMap | ||
| } |
Author
@microsoft-github-policy-service agree company="Microsoft" |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetKubeletConfigFileContentBehavior
Validation
go test ./pkg/agent -count 1