Skip to content

Clarifiy error message when using an improperly formatted secret with kube #26586

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

Merged

Conversation

Craig-Spencer-12
Copy link
Contributor

Using an improperly formatted secret with kube returns a generic error message
Error: failed to create volume "my-volume": error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type v1.Secret

This PR updates the error message to include why the failure occured:
Error: failed to create volume "my-volume": only secrets created via the kube yaml file are supported: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type v1.Secret

Closes: #26561

Does this PR introduce a user-facing change?

Clarified error message when using an improperly formatted secret with kube

@Craig-Spencer-12
Copy link
Contributor Author

Failing because this PR doesn't add any tests. I don't think this PR requires a new test since its just tweaking an existing error message.

Let me know if I'm wrong and I'll whip up a test.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

A test case would be good to just to make sure we keep it working and this is indeed the right place. You could have a look at "secret as volume support - simple" in test/e2e/play_kube_test.go and then instead add a case where you created the secret with podman secret create and make sure it errors with the proper message.

Also FYI please add Fixes: #26561 as part of the commit message itself not just in the PR description.
https://github.com/containers/podman/blob/main/CONTRIBUTING.md#describe-your-changes-in-commit-messages

Craig-Spencer-12 added a commit to Craig-Spencer-12/podman that referenced this pull request Jul 8, 2025
…h kube

Fixes: containers#26586

Signed-off-by: Craig Spencer craig.spencer812@gmail.com
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

Craig-Spencer-12 added a commit to Craig-Spencer-12/podman that referenced this pull request Jul 8, 2025
…h kube

Fixes: containers#26586

Signed-off-by: Craig Spencer craig.spencer812@gmail.com
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Jul 8, 2025
@Craig-Spencer-12
Copy link
Contributor Author

I copied the test secret as volume support - simple but the test is a bit long since I couldn't reuse all the functions used in that test.

  • createAndTestSecret - creates its secret with kube play so I had to tweak that
  • testPodWithSecret - I couldn't find a way to assert its output from outside the function and I didn't want to change the function itself
  • deleteAndTestSecret - reusable

I could definitely slim the test down a bit but I'm curious what you guys think.

@Craig-Spencer-12
Copy link
Contributor Author

Also a spent a long time trying to solve a bug on my end where podman didn't recognize crun. Turns out I had an old version installed that was messing things up so I reinstalled it from source manually.

Not sure if this is a common issue but I figured I'd mention it somewhere since it blocked me for a while. But lessons learned and now my debugging and testing setup is running smoothly!

@mheon
Copy link
Member

mheon commented Jul 9, 2025

Restarted 3 flakes.

@mheon
Copy link
Member

mheon commented Jul 9, 2025

DCO check is complaining about one of your commits, though.

@mheon
Copy link
Member

mheon commented Jul 9, 2025

One nit, code LGTM

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Thanks, please squash all commits into one as we merge commit as is and there should be no wip commits and the likes. And we prefer chnage and test to be part of the same commit.

There seem to be some weird merge commits in here. Our general workflow is to rebase PRs again main to keep it up to date with the latest changes.

Craig-Spencer-12 added a commit to Craig-Spencer-12/podman that referenced this pull request Jul 10, 2025
…h kube

Fixes: containers#26586

Signed-off-by: Craig Spencer craig.spencer812@gmail.com
Craig-Spencer-12 added a commit to Craig-Spencer-12/podman that referenced this pull request Jul 10, 2025
…h kube

Fixes: containers#26586

Signed-off-by: Craig Spencer craig.spencer812@gmail.com
…h kube

Fixes: containers#26586

Signed-off-by: Craig Spencer <craig.spencer812@gmail.com>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

/lgtm

Thank you

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2025
Copy link
Contributor

openshift-ci bot commented Jul 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Craig-Spencer-12, Luap99

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 9f26485 into containers:main Jul 10, 2025
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube play not able to mount podman secret as a file
4 participants