Verify terraform state [RUN ALL RSPEC] [RUN AS-IF-FOSS]
What does this MR do?
This MR adds verification for terraform states:
-
Add verification through self-service framework for Terraform States, using terraform_state_versions table -
Add related metrics to API and Prometheus -
Update metrics doc
I have cross checked with the checklist in the new issue template for adding replication/verification to blob types.
Resolves: #322886 (closed)
Things to todo:
-
Test verification manually -
Test metrics: replication and verification metrics should now be available in the API, the Admin > Geo > Nodes view, and Prometheus
Manual Testing
Setup
- All migrations on default db, geo db on locally run gdk
- FF
geo_terraform_state_version_verification
is enabled on primary
Observations
- Terraform State Version verification shows in UI
- Created terraform state and state version records in the db on the primary, e.g.
Terraform::State.new(project_id: 18, name: "terraform-state").save!
Terraform::StateVersion.new(terraform_state_id: 1, version: 1, file_store: 1, file: f).save!
- Confirmed - Verification works
Primary
Secondary
All terraform states got replicated and verified.
Metrics
- Usage statistics payload includes:
"enablement": {
"geo_secondary_web_oauth_users": 1,
"geo_node_usage": [
{
"terraform_state_versions_count": 3,
"terraform_state_versions_checksum_total_count": null,
"terraform_state_versions_checksummed_count": null,
"terraform_state_versions_checksum_failed_count": null,
"terraform_state_versions_synced_count": 3,
"terraform_state_versions_failed_count": 0,
"terraform_state_versions_registry_count": 3,
"terraform_state_versions_verification_total_count": 3,
"terraform_state_versions_verified_count": 3,
"terraform_state_versions_verification_failed_count": 0,
- Terraform state versions' related data included in
GET /geo_nodes/status
API response:
[
{
"geo_node_id": 1,
"terraform_state_versions_count": 3,
"terraform_state_versions_checksum_total_count": 3,
"terraform_state_versions_checksummed_count": 3,
"terraform_state_versions_checksum_failed_count": 0,
"terraform_state_versions_synced_count": null,
"terraform_state_versions_failed_count": null,
"terraform_state_versions_registry_count": null,
"terraform_state_versions_verification_total_count": null,
"terraform_state_versions_verified_count": null,
"terraform_state_versions_verification_failed_count": null,
"terraform_state_versions_synced_in_percentage": "0.00%",
"terraform_state_versions_verified_in_percentage": "0.00%",
},
{
"geo_node_id": 5,
"terraform_state_versions_count": 3,
"terraform_state_versions_checksum_total_count": null,
"terraform_state_versions_checksummed_count": null,
"terraform_state_versions_checksum_failed_count": null,
"terraform_state_versions_synced_count": 3,
"terraform_state_versions_failed_count": 0,
"terraform_state_versions_registry_count": 3,
"terraform_state_versions_verification_total_count": 3,
"terraform_state_versions_verified_count": 3,
"terraform_state_versions_synced_in_percentage": "100.00%",
"terraform_state_versions_verified_in_percentage": "100.00%",
}
]
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Michael Kozono