8000 cli: Terraform migrations on upgrade by msanft · Pull Request #1685 · edgelesssys/constellation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cli: Terraform migrations on upgrade #1685

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

Merged
merged 55 commits into from
May 22, 2023
Merged

cli: Terraform migrations on upgrade #1685

merged 55 commits into from
May 22, 2023

Conversation

msanft
Copy link
Contributor
@msanft msanft commented Apr 26, 2023

Proposed change(s)

  • Implement migration of cloud resources on Constellation version upgrades. (e.g. Constellation 2.6.0 doesn't create an MAA, while 2.7.0 does optionally and 2.8.0 always creates one)
    • In that case, a user with a cluster without an MAA (2.6.0/2.7.0) downloads the 2.8.0 CLI and runs the upgrade apply command to have a MAA added to his cloud resources.
  • How the migration works:
    • The old Terraform directory constellation-terraform is backed up into constellation-upgrade/constellation-upgrade-terraform-backup. If the user wants to rollback to the pre-upgrade state, he can do it there
    • Constellation copies the old Terraform state from the constellation-terraform dir into the constellation-upgrade/constellation-upgrade-terraform dir.
    • Constellation populates the constellation-upgrade/constellation-upgrade-terraform dir with the new Terraform script files (embedded in the CLI)
    • Constellation performs a terraform plan on selected targets (as of now, only on the MAA on Azure)
    • The resulting diff is shown to the user who can confirm it or abort the upgrade.
    • If the user confirms the diff (resources to be crated / changed / etc.), the new script is applied on the selected target (in simpler terms; the output confirmed by the user gets created)
    • The old Terraform directory constellation-terraform is replaced with the new constellation-upgrade/constellation-upgrade-terraform. The output of the migrated resources is written into terraform-migration-output.json (e.g. the attestation URL of the MAA provider)

Additional info

  • TODO: Add e2e test run

Checklist

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

@netlify
Copy link
netlify bot commented Apr 26, 2023

Deploy Preview for constellation-docs canceled.

Name Link
🔨 Latest commit 02fd7bf
🔍 Latest deploy log https://app.netlify.com/sites/constellation-docs/deploys/646b4a9ac909fa000856ec6e

@msanft msanft added the feature This introduces new functionality label May 4, 2023
@msanft msanft added this to the v2.8.0 milestone May 4, 2023
@msanft msanft requested a review from derpsteb May 4, 2023 09:06
@msanft msanft marked this pull request as ready for review May 4, 2023 09:06
@katexochen katexochen removed their request for review May 4, 2023 09:09
@derpsteb
Copy link
Contributor
derpsteb commented May 9, 2023

re "design descision": I would expect constellation terminate to delete all my resources. I don't see a reason why we would not replace the old state. Which reasons are there?

re "Constellation performs a terraform plan on selected targets (as of now, only on the MAA on Azure)": could you point me to the code that restricts the plan to any specific resources? while reading the changes it seemed to me like a general plan would happen on all resources.

@msanft
Copy link
Contributor Author
msanft commented May 11, 2023

re "selected targets"

Planning and applying the configuration uses the targets flag which specifies resources to plan / apply the configuration for.
The specific targets get set here.

@msanft
Copy link
Contributor Author
msanft commented May 11, 2023

re "design decision"

The reason I would see is, that if an upgrade goes wrong, the user should be able to rollback to the old resource state manually. Therefore we should at least keep the old state somewhere in the upgrade folder. I will prepare something to put the current state into a backup folder and move the upgraded state into the constellation-terraform folder

@msanft msanft force-pushed the feat/cli/terraform-upgrades branch from 881724f to f792467 Compare May 11, 2023 11:15
@msanft msanft requested a review from derpsteb May 12, 2023 09:00
@msanft msanft requested a review from derpsteb May 17, 2023 10:18
@msanft msanft requested review from 3u13r, malt3 and thomasten as code owners May 22, 2023 07:17
@msanft msanft removed request for daniel-weisse and 3u13r May 22, 2023 07:18
@msanft msanft force-pushed the feat/cli/terraform-upgrades branch 2 times, most recently from 9fea7a5 to c30844f Compare May 22, 2023 07:23
Copy link
Contributor
@derpsteb derpsteb left a comment

Choose a reason for hiding this comment

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

Just tested it again on AWS and Azure. Looks great now :)

@msanft msanft changed the title feat: Terraform migrations on upgrade cli: Terraform migrations on upgrade May 22, 2023
@msanft msanft merged commit c69e677 into main May 22, 2023
@msanft msanft deleted the feat/cli/terraform-upgrades branch May 22, 2023 11:31
@derpsteb derpsteb added no changelog Change won't be listed in release changelog feature This introduces new functionality and removed feature This introduces new functionality no changelog Change won't be listed in release changelog labels Jun 5, 2023
@malt3 malt3 mentioned this pull request Jun 19, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This introduces new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0