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

cli: only create resource backups if upgrade is executed #1437

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

derpsteb
Copy link
Member

Proposed change(s)

  • Upgrade apply creates local backups of all CRDs and CRs to recover from faulty microservice upgrades. Previously these backups were created during upgrade apply even if no service upgrades were executed. Now they are only created if at least one service is upgraded. To allow for this change some restructuring was necessary:
    • new chartInfo type that holds release name, path and chart name
    • upgrade execution and version validity are checked separately

Checklist

  • Update docs
  • Add labels (e.g., for changelog category)
  • Link to Milestone

@derpsteb derpsteb added this to the v2.7.0 milestone Mar 16, 2023
@netlify
Copy link

netlify bot commented Mar 16, 2023

Deploy Preview for constellation-docs canceled.

Name Link
🔨 Latest commit e031261
🔍 Latest deploy log https://app.netlify.com/sites/constellation-docs/deploys/6414215fd9995f0008ae22d7

Previously backups were created even if no service upgrades were
executed. To allow this some things are restructured:
* new chartInfo type that holds release name, path and chart name
* upgrade execution and version validity are checked separately
@derpsteb derpsteb force-pushed the feat/selective-backup-upgrades branch from 112a40c to 9fb681b Compare March 16, 2023 14:35
Comment on lines 187 to 192
var info chartInfo

switch chart.Metadata.Name {
case ciliumInfo.chartName:
info = ciliumInfo
values, err = loader.loadCiliumValues()
Copy link
Member

@daniel-weisse daniel-weisse Mar 16, 2023

Choose a reason for hiding this comment

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

I feel like we could skip having to define the chartInfo type if we instead pulled some of the logic that comes after the switch statement into the switch statement.

For example if info == certManagerInfo && !allowDestructive could be moved directly into the cert-manager case.
Similar the call to c.updateCRDs(ctx, chart) can be moved into the the Constellation operators case.

The different cases then only need to set a string for their respective release name, which can be passed into the prepareValues and upgradeAction functions, which are called for all cases

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 applied your suggestions but kept the chartInfo type for now. Reason: I am hoping to unify the loadCilium, loadCertManager, loadOperators, loadConstellationServices in loader.go into a single function, hopefully making the code more concise & understandable. But I would do that in a separate PR to keep PRs small and simple.

If you think this is a bad idea, please tell me. If it turns out to not work as I expect I would remove the chartInfo type again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Only allowed for some minor change: #1441
Not sure if it's better that way. "Feels" better because there is slightly less code duplication. I guess the DRY principle sits deep in me :D

But also doesn't make it worse. So 🤷‍♂️ ..

@daniel-weisse
Copy link
Member

Looks a lot cleaner now and only creates the backups when necessary, nice

@derpsteb derpsteb merged commit 9e13b0f into main Mar 20, 2023
@derpsteb derpsteb deleted the feat/selective-backup-upgrades branch March 20, 2023 13:49
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.

2 participants