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

instantiate a default cns config if loading fails #1829

Merged
merged 3 commits into from
Mar 2, 2023

Conversation

rbtr
Copy link
Contributor

@rbtr rbtr commented Mar 1, 2023

Reason for Change:

Currently if CNS does not find a config it returns a nil pointer and an error, but does not stop executing and continues to attempt to use that nil config pointer (immediately, in the next line...).
This change modifies the behavior such that if we fail to find a config and return a nil pointer, we instantiate a default struct and assign it to make the subsequent pointer refs valid.

Issue Fixed:

closes #1775

Requirements:

Notes:

@rbtr rbtr requested a review from a team as a code owner March 1, 2023 18:17
@rbtr rbtr requested review from ramiro-gamarra and removed request for a team March 1, 2023 18:17
@rbtr rbtr self-assigned this Mar 1, 2023
@rbtr rbtr added cns Related to CNS. fix Fixes something. labels Mar 1, 2023
@rbtr rbtr requested a review from csfmomo March 1, 2023 18:29
@rbtr rbtr enabled auto-merge (squash) March 1, 2023 18:29
@@ -503,6 +503,7 @@ func main() {
cnsconfig, err := configuration.ReadConfig(cmdLineConfigPath)
if err != nil {
logger.Errorf("[Azure CNS] Error reading cns config: %v", err)
cnsconfig = &configuration.CNSConfig{}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should make it apparent in the error log line that a default will be used. I'm also curious if we should only use a default in cases where the file is missing. If, for example, the file is malformed, maybe it's better to still crash such that orchestrators take action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree and updated

@rbtr rbtr merged commit 21d2355 into Azure:master Mar 2, 2023
@rbtr rbtr deleted the fix/cns-no-config branch March 2, 2023 19:32
rjdenney pushed a commit that referenced this pull request Mar 13, 2023
rbtr added a commit that referenced this pull request Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cns Related to CNS. fix Fixes something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CNS fails if cns_config.json does not exist
2 participants