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

Does not need review yet: Update main.go #632

Closed
wants to merge 1 commit into from
Closed

Conversation

uturunku1
Copy link
Collaborator

@uturunku1 uturunku1 commented Jan 11, 2023

These tests are occasionally running with an incorrect TFE_TOKEN env var: https://github.com/hashicorp/go-tfe/blob/main/.github/workflows/nightly-tfe-ci.yml#L108

As an example, you can see that this run https://github.com/hashicorp/go-tfe/actions/runs/3878869728/jobs/6615534375 is showing that some tests are failing with "unauthorized", which is a symptom of a token that is querying for an organization or other resource that is does not have privileges to.

This token, is an admin token, that is coming from the state outputs https://github.com/hashicorp/go-tfe/blob/main/.github/scripts/fetch_outputs/main.go#L42, that should have privileges to all the resources that are being managed on the tflocal instance.

Why would the tests sometimes run with the right token and not other times? The value is clearly not empty otherwise we would see another error, which means that the token must switching in the middle of the process.
This issue is not reproducible locally. Every time that I grab the token and the hostname from the state outputs and place them into my environment before running the tests, I get the regular test results, not the unauthorized errors.

My goal, for next time that we run into "unauthorized", is to check against that the last digits of the token to either match them to the one we see in our workspace's state outputs or to another workspace.

Description

Testing plan

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" go test ./... -v -run TestFunctionsAffectedByChange

...

These tests are occasionally running with an incorrect token: https://github.com/hashicorp/go-tfe/blob/main/.github/workflows/nightly-tfe-ci.yml#L108

As an example, you can see that this run https://github.com/hashicorp/go-tfe/actions/runs/3878869728/jobs/6615534375 is showing that some tests are failing with "unauthorized", which is a symptom of a token that is querying for an organization that is does not have privileges too.

That seems odd because the token that we are using for these tests is coming from the state outputs https://github.com/hashicorp/go-tfe/blob/main/.github/scripts/fetch_outputs/main.go#L42
which has privileges for the "hashicorp" organization.

Even more strange, why would the tests sometimes run with the right token and not other times?

My goal is to verify that the last digits of the token match the one with see in our workspace's state next time the tests fail with "unauthorized".
@uturunku1 uturunku1 changed the title Update main.go Do not review: Update main.go Jan 12, 2023
@uturunku1 uturunku1 changed the title Do not review: Update main.go Does not need review yet: Update main.go Jan 12, 2023
@uturunku1
Copy link
Collaborator Author

TDP created a JIRA ticket (499) to address this issue 🎉

@uturunku1 uturunku1 closed this Apr 20, 2023
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.

None yet

1 participant