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

Adding missing Env variables for core sts #465

Merged
merged 1 commit into from Dec 2, 2020

Conversation

jackyalbo
Copy link
Contributor

Added a new check on missing env variable and adding them if they appear in the yaml

Doing this only for core sts for now just for you guys to take a look - we can copy the logic to other yamls if we need to - for now tagged as WIP until we figure this out

Signed-off-by: jackyalbo jalbo@redhat.com

Comment on lines 349 to 353
for j := range r.DefaultCoreApp.Env {
if (!existingEnvs[r.DefaultCoreApp.Env[j].Name] &&
(r.DefaultCoreApp.Env[j].Value != "" || r.DefaultCoreApp.Env[j].ValueFrom != nil)) {
c.Env = append(c.Env, r.DefaultCoreApp.Env[j])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that copy is enough as sometimes we leave envs values empty on purpose so the code will reconcile them with custom logic. If I will just delete n env that has an empty value (in the template) it will not get its reconciled value back.

I think a better approach is to take the list from the template then merge into it the current envs then run the reconcile code (the for with the switch statement) on the merged list

Copy link
Contributor

Choose a reason for hiding this comment

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

@nb-ohad is right. just add a mergeEnvs function and call it before the envs for

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, you should merge only the missing envs from the template into the CR, then the reconcile env loop can stay the same

@jackyalbo
Copy link
Contributor Author

@dannyzaken @nb-ohad fixed to merge - please re-review

pkg/util/util.go Outdated
Comment on lines 1085 to 1090
for _, item := range *envB {
if !existingEnvs[item.Name] {
*envA = append(*envA, item)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think something with the indentation here is wrong

@jackyalbo jackyalbo force-pushed the fix_root_secret_upgrade branch 2 times, most recently from d08acd0 to 0949ac9 Compare November 30, 2020 09:38
@jackyalbo jackyalbo changed the title [WIP] Adding missing Env variables Adding missing Env variables for core sts Dec 1, 2020
Signed-off-by: jackyalbo <jalbo@redhat.com>
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.

None yet

3 participants