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

Use GCS as the Terraform state backend #2938

Merged
merged 4 commits into from
Jan 31, 2023
Merged

Conversation

gongmax
Copy link
Collaborator

@gongmax gongmax commented Jan 27, 2023

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking
/kind bug
/kind cleanup
/kind documentation

/kind feature

/kind hotfix

What this PR does / Why we need it:
Use GCS as the backend of the e2e test cluster Terraform state, so the maintainers can have a central store of the state. This will also benefit the management of the additional e2e test clusters we will introduced in near future.

As a side work, the PR also remove the consul from the Autopilot e2e test cluster.

Which issue(s) this PR fixes:

Closes #

Special notes for your reviewer:
Since we will have the central authority of the e2e test clusters state, we should discourage users to create e2e test cluster for their local dev purpose. Users should be able to just create one test-cluster and perform all the dev on it including the e2e test. Instruction changes will be in following PRs.

@@ -28,6 +28,10 @@ terraform {
version = "~> 2.3"
}
}
backend "gcs" {
bucket = "agones-e2e-infra-bucket-tfstate"
Copy link
Member

@markmandel markmandel Jan 27, 2023

Choose a reason for hiding this comment

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

Given that a bucket name has to be glopally unique - this should probably be dynamic (use the project name as a prefix?) so it can be run against development projects without failing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's doable. But I have doubt whether it makes sense to create an e2e test cluster for development. I was thinking we should push user to just create one test-cluster and use it for the development purpose even the e2e test.

Copy link
Member

Choose a reason for hiding this comment

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

With it the way it is, you can't test this Terraform script, except to test it in production.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was expecting the backend part would be relatively stable since it's only a thing for our maintainers who have access to the infra and won't have many change (if any). But it's still a fair point. I will make it not hardcoded.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly just something like {project}-tfstate makes sense to me, that's what I was thinking of doing.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: d206037d-40ed-4487-9e91-c0151e62a7a6

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2938/head:pr_2938 && git checkout pr_2938
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-22ec2a7-amd64

@google-oss-prow google-oss-prow bot added size/L and removed size/M labels Jan 28, 2023
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: c7584429-ea28-4b2b-8cb6-21cb9841c898

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: caab8303-f722-408e-8289-57d1b01e28c0

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2938/head:pr_2938 && git checkout pr_2938
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-1b12efb-amd64

@gongmax gongmax marked this pull request as ready for review January 28, 2023 05:06
@gongmax gongmax changed the title Use GCS to as the Terraform state backend Use GCS as the Terraform state backend Jan 28, 2023
$(DOCKER_RUN) bash -c 'cd $(mount_path)/build/terraform/e2e && terraform destroy -var project=$(GCP_PROJECT) -auto-approve'

# Creates a gcloud cluster for prow
gcloud-prow-build-cluster: GCP_PROJECT ?= $(shell $(current_project))
gcloud-prow-build-cluster: $(ensure-build-image)
gcloud-prow-build-cluster:
$(MAKE) terraform-init DIRECTORY=prow
$(MAKE) terraform-init BUCKET=$(GCP_PROJECT)-prow-infra-bucket-tfstate PREFIX=terraform/state DIRECTORY=prow
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe not strictly necessary here, but given that we are at an inflection point of changing the e2e infrastructure and I don't think any of us understands if the Prow configuration is even working, should we just instead turn down Prow? I am afraid that if we continue as is we'll give someone a false sense of "maybe it works" when I feel like it has reached the point of bitrot.

Copy link
Member

Choose a reason for hiding this comment

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

I have no objections to removing the prow cluster.

Copy link
Member

Choose a reason for hiding this comment

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

I have no objections to removing the prow cluster.

Who are you, and what have you done with the real @roberthbailey ? 😁

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: e15b8cf6-cc64-4685-b046-c484abfa4b46

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 5b5272ad-2b07-41fa-8daa-171d1ae1a159

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2938/head:pr_2938 && git checkout pr_2938
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-7d9aae3-amd64

@gongmax gongmax requested review from zmerlynn and removed request for cyriltovena and aLekSer January 31, 2023 18:43
@@ -14,6 +14,7 @@


// Run:
// terraform init -backend-config="bucket=<YOUR_GCP_ProjectID>-e2e-infra-bucket-tfstate" -backend-config="prefix=terraform/state"
Copy link
Collaborator

Choose a reason for hiding this comment

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

out of curiousity, what happens if you don't provide these variables? does terraform error out in an obvious way, or does it default to something bad?

Copy link
Collaborator

Choose a reason for hiding this comment

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

(I would like if it failed brightly, vs just continued without GCS, if that's something easy enough to do.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If starting with a clean state, i.e. there is no tfstate file for this module in your dev environment, terraform init without those variables will succeed but the local root configuration directory for this module will be used as backend. But the following terraform apply will fail because the state doesn't match with the existing resources, unless the related resources (clusters, firewalls) are all deleted, which is basically starting from a brand new state.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point. I think that's good enough, yeah.

Copy link
Collaborator

@zmerlynn zmerlynn left a comment

Choose a reason for hiding this comment

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

Left a minor question. It's non-blocking to merge.

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gongmax, zmerlynn
Once this PR has been reviewed and has the lgtm label, please assign markmandel for approval by writing /assign @markmandel in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot removed the lgtm label Jan 31, 2023
@google-oss-prow
Copy link

New changes are detected. LGTM label has been removed.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 604fc25e-0783-4bfe-805c-b0a109dc840b

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2938/head:pr_2938 && git checkout pr_2938
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-7d9aae3-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 522b5ed9-8b27-4788-af9d-bb80713737c0

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2938/head:pr_2938 && git checkout pr_2938
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-1f36d83-amd64

@gongmax gongmax merged commit 36997f2 into googleforgames:main Jan 31, 2023
igooch pushed a commit to igooch/agones that referenced this pull request Jan 31, 2023
* Use GCS to as the Terraform state backend

* fix format

* Make gcs bucket dynamic; Use gcs as terraform backend for prow cluster

* remove prow cluster
@Kalaiselvi84 Kalaiselvi84 added this to the 1.30.0 milestone Feb 28, 2023
@Kalaiselvi84 Kalaiselvi84 added the kind/feature New features for Agones label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New features for Agones size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants