Add Terraform States to Backup and Restore tasks
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:
When included:
When restoring (if not skipped):
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have self-reviewed this MR per code review guidelines. -
I have followed the style guides.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.)
Edited by Harsh Chouraria