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

roachprod: refactor gcp environment variable initialization #138711

Merged

Conversation

shailendra-patel
Copy link
Contributor

Moved the initialization of default variables related to the GCP Project and DNS into the GCP provider Init function instead of initializing them during package initialization. Setting default variables as global variables caused issues when environment variables are modified before calling Init.

Epic: none

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Moved the initialization of default variables related to the
GCP Project and DNS into the GCP provider Init function instead of
initializing them during package initialization. Setting default
variables as global variables caused issues when environment variables
are modified before calling Init.

Epic: none

Release note: None
@shailendra-patel shailendra-patel force-pushed the drtprod-initialization-fix branch from 032f9ef to 5fdced8 Compare January 9, 2025 07:46
@shailendra-patel
Copy link
Contributor Author

GCP Nightly Smoke Test.

@shailendra-patel shailendra-patel marked this pull request as ready for review January 10, 2025 04:13
@shailendra-patel shailendra-patel requested review from a team as code owners January 10, 2025 04:13
@shailendra-patel shailendra-patel requested review from herkolategan, srosenberg, nameisbhaskar and vidit-bhat and removed request for a team January 10, 2025 04:14
Copy link
Contributor

@vidit-bhat vidit-bhat left a comment

Choose a reason for hiding this comment

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

LGTM

@shailendra-patel
Copy link
Contributor Author

TFTR!

bors r=vidit-bhat,srosenberg

@craig craig bot merged commit 31e84cb into cockroachdb:master Jan 13, 2025
22 checks passed
golgeek added a commit to golgeek/cockroach that referenced this pull request Jan 13, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

Signed-off-by: Ludovic Leroux <[email protected]>
craig bot pushed a commit that referenced this pull request Jan 13, 2025
138960: roachprod: promhelper fix project and wipe r=srosenberg a=golgeek

This PR fixes a bug introduced in #138711 and also adds deletion of Prometheus targets at cluster wipe.

Before #138711, the GCE provider defaults were defined during init(). This logic was moved to an init function to allow the `drtprod` command to define its own defaults via environment variables. This introduced a state in which where the promhelper client's defaults for `SupportedPromProject` is initialized with `gce.DefaultProject()` before this value is initialized, and no Prometheus targets are ever pushed.

This PR removes the `promhelperclient.DefaultClient` that should not be used anymore, and computing the defaults in `NewPromClient()`. This PR also delegates the checks on whether or not providers and projects are supported to the promhelperclient package to simplify the logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a `secure` cluster during a `roachtest` run, the promhelper client would delete the `secure` configuration during cluster destruction, but would leave the `insecure` configuration (as the promhelper clients tries to delete `secure` first, then `insecure` if not found). This was creating stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster wipe to fix this.

Epic: none
Release note: None

Co-authored-by: Ludovic Leroux <[email protected]>
blathers-crl bot pushed a commit that referenced this pull request Jan 13, 2025
This PR fixes a bug introduced in #138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before #138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

Signed-off-by: Ludovic Leroux <[email protected]>
golgeek added a commit to golgeek/cockroach that referenced this pull request Jan 13, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

----

Release justification: test-only change

Signed-off-by: Ludovic Leroux <[email protected]>
golgeek added a commit to golgeek/cockroach that referenced this pull request Jan 13, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

----

Release justification: test-only change

Signed-off-by: Ludovic Leroux <[email protected]>
golgeek added a commit to golgeek/cockroach that referenced this pull request Jan 13, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

----

Release justification: test-only change

Signed-off-by: Ludovic Leroux <[email protected]>
golgeek added a commit to golgeek/cockroach that referenced this pull request Jan 13, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

----

Release justification: test-only change

Signed-off-by: Ludovic Leroux <[email protected]>
golgeek added a commit to golgeek/cockroach that referenced this pull request Jan 14, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

---

Release justification: test-only change

Signed-off-by: Ludovic Leroux <[email protected]>
InManuBytes pushed a commit to InManuBytes/cockroach that referenced this pull request Jan 15, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

Signed-off-by: Ludovic Leroux <[email protected]>
mohini-crl pushed a commit to mohini-crl/cockroach that referenced this pull request Jan 17, 2025
This PR fixes a bug introduced in cockroachdb#138711 and also adds deletion of
Prometheus targets at cluster wipe.

Before cockroachdb#138711, the GCE provider defaults were defined during init().
This logic was moved to an init function to allow the `drtprod` command
to define its own defaults via environment variables.
This introduced a state in which where the promhelper client's defaults
for `SupportedPromProject` is initialized with `gce.DefaultProject()`
before this value is initialized, and no Prometheus targets are ever
pushed.

This PR removes the `promhelperclient.DefaultClient` that should not
be used anymore, and computing the defaults in `NewPromClient()`.
This PR also delegates the checks on whether or not providers and
projects are supported to the promhelperclient package to simplify the
logic in the callers.

Also, prior to this PR, if an `insecure` cluster was reused as a
`secure` cluster during a `roachtest` run, the promhelper client would
delete the `secure` configuration during cluster destruction, but would
leave the `insecure` configuration (as the promhelper clients tries to
delete `secure` first, then `insecure` if not found). This was creating
stale Prometheus targets.

This PR introduces the deletion of the Prometheus targets at cluster
wipe to fix this.

Epic: none
Release note: None

Signed-off-by: Ludovic Leroux <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants