Skip to content

feat: Ensure new configurations from the file are applied #894

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

weichou1229
Copy link
Member

After upgrading EdgeX, new configurations may be introduced. Ensure new configurations from the YAML file are pushed to the core-keeper.

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/go-mod-bootstrap/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?) not impact
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?) not impact

Testing Instructions

  • deploy old version (such tag v4.1.0-dev.46) edgex-go
  • shut down and deploy the latest edgex-go with this PR.
  • verify the new configs are pushed to core-keeper

New Dependency Instructions (If applicable)

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.90%. Comparing base (92b3da6) to head (b92b2bf).

Files with missing lines Patch % Lines
bootstrap/config/config.go 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
- Coverage   46.08%   45.90%   -0.19%     
==========================================
  Files          62       62              
  Lines        3669     3684      +15     
==========================================
  Hits         1691     1691              
- Misses       1856     1871      +15     
  Partials      122      122              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@weichou1229 weichou1229 force-pushed the config-migrate branch 2 times, most recently from 90e916a to 226cd21 Compare August 15, 2025 08:56
@weichou1229 weichou1229 marked this pull request as ready for review August 15, 2025 08:57
@weichou1229 weichou1229 requested a review from judehung August 15, 2025 08:57
Comment on lines 1298 to 1300
if hasSubConfig {
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to indicate the rationale why skip the key when it has subConfig

continue
}
if err = configClient.PutConfigurationValue(key, []byte(fmt.Sprint(value))); err != nil {
return fmt.Errorf("failed to push common configuration key %s with value %v: %s", key, value, err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the error log, does the code here only handle common config? How about the private config?

Comment on lines 1333 to 1299
// buildKeyValues is a helper function to parse the configuration yaml file contents
func buildKeyValues(data map[string]interface{}, kv map[string]interface{}, origKey string) map[string]interface{} {
key := origKey
for k, v := range data {
if len(key) == 0 {
key = fmt.Sprint(k)
} else {
key = fmt.Sprintf("%s/%s", key, k)
}

vdata, ok := v.(map[string]interface{})
if !ok {
kv[key] = v
key = origKey
continue
}

kv = buildKeyValues(vdata, kv, key)
key = origKey
}

return kv
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current function comment doesn’t clearly convey the purpose of this helper, making it hard to judge whether its recursive logic is correct.

From the code, I can only guess that the function’s intent is to flatten a nested map into a single-level map? If that’s correct, please update the comment to explicitly describe this purpose. Also, since this is a utility function, consider to move this func to bootstrap/utils/utils.go and this func should have unit tests to verify that its behavior matches the intended goal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the config provider client has already done the key flattening and put config when the keyValue not exist or override is set, so I updated the code to keep it simple.
https://github.com/edgexfoundry/go-mod-configuration/blob/main/internal/pkg/keeper/client.go#L96

After upgrading EdgeX, new configurations may be introduced. Ensure new configurations from the YAML file are pushed to the core-keeper.

Signed-off-by: bruce <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants