Skip to content

Add Terraform States to Backup and Restore tasks

Harsh Chouraria requested to merge hchouraria-backup-terraform-state-files into master

What does this MR do?

Reuses standard file upload storage to cover Terraform states backup

Adds a seed for generating terraform state files under each project

Manual testing (in local GDK env):

  • Verfied seed addition via bin/rake db:seed_fu FILTER=terraform
  • Verified seed addition is repeatable
  • Created backup: bin/rake gitlab:backup:create
  • Verified output shows up:
2021-06-05 23:48:54 +0530 -- Dumping terraform states ...
2021-06-05 23:48:54 +0530 -- done
  • Verified backup tar contains terraform_states.tar.gz
  • Verified terraform_states.tar.gz carries content
  • Verified that these contents remain encrypted in the backup and unreadable without keys
  • Destroyed all records: Terraform::State.destroy_all
  • Deleted all files: rm -rf shared/terraform_state/*
  • Performed restore: bin/rake gitlab:backup:restore
  • Verified Terraform::State.all shows back older records
  • Verified association of builds to some of these records
  • Verified shared/terraform_state/ is repopulated
  • Verified Terraform::StateVersion.each do |sv| pp sv.file.read end works and shows the seed-added data
  • Verified skipping of terraform_states keyword works:
2021-06-06 00:11:33 +0530 -- Dumping terraform states ...
2021-06-06 00:11:33 +0530 -- [SKIPPED]

Verified with same workflow as above (backup, destroy, delete, then restore) that skipped backup variant does not contain terraform_state.tar.gz and does not show up those files after restore

Miscellany:

Adds a missing test for LFS backups Adds File operation fixes to neighboring tests

Related Omnibus change: omnibus-gitlab!5336 (merged)

Closes #331806 (closed)

Screenshots (strongly suggested)

When skipped:

image

When included:

image

When restoring (if not skipped):

image

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Harsh Chouraria

Merge request reports