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

Have leader election use namespace from env var #3209

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

chiayi
Copy link
Contributor

@chiayi chiayi commented Jun 9, 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:
Currently leader election uses hardcoded namespace, this changes so that it uses the namespace from the env vars

Which issue(s) this PR fixes:
Towards #3208

Special notes for your reviewer:

@@ -84,6 +84,7 @@ const (
kubeconfigFlag = "kubeconfig"
allocationBatchWaitTime = "allocation-batch-wait-time"
defaultResync = 30 * time.Second
podNamespace = "pod-namespace"
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 just call this lease-namespace and make it clear it's the namespace to use for the controller lease. The helm chart can make sure it's aligned appropriately.

Strictly speaking, I don't think this needs to be in the same namespace as the pod - I think the controller just needs rights to it and for it to exist, which was the issue, AIUI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would this be confusing since the namespace is the same one as the controller pods? Or should there be another env variable for leader election?

Copy link
Member

Choose a reason for hiding this comment

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

As a note, this doesn't (and probably shouldn't?) come from helm. We can use the downward API to get this information from K8s directly:

https://kubernetes.io/docs/concepts/workloads/pods/downward-api/

Copy link
Member

Choose a reason for hiding this comment

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

Just thinking, someone could do a yaml install to a different namespace, and expect it to work. If we use the downward API, this handles that scenario.

Copy link
Contributor Author

@chiayi chiayi Jun 9, 2023

Choose a reason for hiding this comment

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

I think it should be already using the downward api, looks very similar from the doc: https://github.com/googleforgames/agones/blob/main/install/helm/agones/templates/controller.yaml#L159-L162 is there a big difference between exposing it as a env variable vs a downward-api volume?

Copy link
Member

Choose a reason for hiding this comment

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

Oh sweet - I didn't realise it was already there.

If it's already there as an env var, then you are good to go!

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is already plumbed into the deployment then I have no problem with the existing name - AIUI you're basically consuming an env variable that we already set here, so I guess my lease-namespace comment is ignorable.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 98a0fa2b-338e-41c2-a9d0-89838eb9883c

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/3209/head:pr_3209 && git checkout pr_3209
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.33.0-4b2a8a1-amd64

@chiayi chiayi marked this pull request as ready for review June 9, 2023 22:56
@google-oss-prow google-oss-prow bot requested a review from aLekSer June 9, 2023 22:57
Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Saw a small typo below, but other than that, no issues on my end here. @zmerlynn any on your end?

Other than the typo, this look good to merge?

cmd/controller/main.go Outdated Show resolved Hide resolved
@zmerlynn
Copy link
Collaborator

Saw a small typo below, but other than that, no issues on my end here. @zmerlynn any on your end?

No, this LGTM other than the typo - wasn't sure if @chiayi was ready.

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Noice!

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chiayi, markmandel

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

The pull request process is described 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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 7e0b8ec4-3a37-4b29-b635-4dccbcaa065e

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/3209/head:pr_3209 && git checkout pr_3209
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.33.0-c4066b3-amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants