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

Improve error msg when serviceaccount.json is in invalid json format #723

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

plkokanov
Copy link
Contributor

How to categorize this PR?

/area usability ops-productivity
/kind enhancement
/platform gcp

What this PR does / why we need it:
This PR enhances the error which is returned if the gcp cloud provider secret contains a serviceaccount.json field which is in an invalid json format and cannot be unmarshalled.
Without this, if someone tries to create a SecretBinding to such a secret containing an invalid serviceaccount.json the only error that is displayed is:

Error from server: error when creating "secretbinding-cloudprovider.yaml": admission webhook "validator.admission-gcp.extensions.gardener.cloud" denied the request: unexpected end of JSON input

Now the error should be more descriptive pointing to its actual cause:

Error from server: error when creating "secretbinding-cloudprovider.yaml": admission webhook "validator.admission-gcp.extensions.gardener.cloud" denied the request: referenced secret foo/bar is not valid: could not get service account from "serviceaccount.json" field: failed to unmarshal json object: unexpected end of JSON input

Additionally, I noticed that the readServiceAccountSecret function is unused, so I removed it.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:

An error text which better indicates the reason for the failure is displayed when a user tries to create a `SecretBinding` resource which references a `Secret` with a `serviceaccount.json` field in invalid json format.

@plkokanov plkokanov requested review from a team as code owners April 4, 2024 17:15
@gardener-robot gardener-robot added needs/review Needs review area/ops-productivity Operator productivity related (how to improve operations) area/usability Usability related kind/enhancement Enhancement, improvement, extension platform/gcp Google cloud platform/infrastructure size/s Size of pull request is small (see gardener-robot robot/bots/size.py) labels Apr 4, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Apr 4, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Apr 4, 2024
Copy link
Member

@AndreasBurger AndreasBurger left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@kon-angelo kon-angelo left a comment

Choose a reason for hiding this comment

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

/lgtm

@gardener-robot gardener-robot added the reviewed/lgtm Has approval for merging label Apr 8, 2024
@kon-angelo kon-angelo merged commit a3d0246 into gardener:master Apr 8, 2024
16 checks passed
@gardener-robot gardener-robot added status/closed Issue is closed (either delivered or triaged) and removed needs/review Needs review labels Apr 8, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ops-productivity Operator productivity related (how to improve operations) area/usability Usability related kind/enhancement Enhancement, improvement, extension needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) platform/gcp Google cloud platform/infrastructure reviewed/lgtm Has approval for merging reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) size/s Size of pull request is small (see gardener-robot robot/bots/size.py) status/closed Issue is closed (either delivered or triaged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants