Skip to content

env-kvstore: warn when env specific values are missing from kvstore#489

Open
bpdohall wants to merge 4 commits into
mainfrom
brendan/env-kvstore-warn-on-missing-env-values
Open

env-kvstore: warn when env specific values are missing from kvstore#489
bpdohall wants to merge 4 commits into
mainfrom
brendan/env-kvstore-warn-on-missing-env-values

Conversation

@bpdohall

@bpdohall bpdohall commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Currently failing for repositories invoking the action with an environment set but the environment has not been configured in the secrets manager kvstore.

Because we're using ABAC/tag-based access to secrets, there's never going to be a "resource not found" error.

This PR simplifies handling of errors populating the environment-specific values so they are treated and logged as a warning instead of a failure.

@bpdohall bpdohall requested a review from a team as a code owner June 24, 2026 19:55

@rosstimothy rosstimothy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add some test coverage to prevent regressions?

}
if envArn != "" && envStore.IsEmpty() && err == nil {
slog.Info("environment-specific values are empty in Secrets Manager, only repo-level values will be available", "environment", s.ghaClaims.Environment, "arn", envArn)
err = envStoreError{msg: fmt.Sprintf("no environment-specific values found in Secrets Manager for environment %s", s.ghaClaims.Environment)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will an envStoreError error ever be populated with a different message? Should an envStoreError have an environment instead of a msg, and should this fmt.Sprintf be in (envStoreError) Error() instead of here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Revised per your feedback in 7536402 and was able to collapse some logic

Added separate handling for the case where unmarshalling fails. This scenario should fail the job. f7d99b2

@bpdohall bpdohall requested a review from rosstimothy June 25, 2026 13:33
@bpdohall

Copy link
Copy Markdown
Contributor Author

Testing ("docker shared-workflows/tools/env-kvstore summary"): missing environment, job is successful with warnings: https://github.com/gravitational/bpdohall-platformops-gha/actions/runs/28175820640

@rosstimothy

Copy link
Copy Markdown
Contributor

Testing ("docker shared-workflows/tools/env-kvstore summary"): missing environment, job is successful with warnings: https://github.com/gravitational/bpdohall-platformops-gha/actions/runs/28175820640

Do we execute these jobs against every change to this tool? Can we add unit tests that are required to pass before any change to this tool merges to prevent regressions?

@bpdohall

bpdohall commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Testing ("docker shared-workflows/tools/env-kvstore summary"): missing environment, job is successful with warnings: https://github.com/gravitational/bpdohall-platformops-gha/actions/runs/28175820640

Do we execute these jobs against every change to this tool? Can we add unit tests that are required to pass before any change to this tool merges to prevent regressions?

I executed those jobs manually. Added unit tests that cover secretsmanager API responses and errors in d5383b6

@bpdohall bpdohall force-pushed the brendan/env-kvstore-warn-on-missing-env-values branch from 1b6c662 to 6517aed Compare June 26, 2026 20:33
@bpdohall bpdohall force-pushed the brendan/env-kvstore-warn-on-missing-env-values branch from 6517aed to d5383b6 Compare June 26, 2026 20:59
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