Skip to content

Secret create - add ignore option to allow noop#26467

Merged
openshift-merge-bot[bot] merged 1 commit into
podman-container-tools:mainfrom
ygalblum:secret-create-ignore
Jun 26, 2025
Merged

Secret create - add ignore option to allow noop#26467
openshift-merge-bot[bot] merged 1 commit into
podman-container-tools:mainfrom
ygalblum:secret-create-ignore

Conversation

@ygalblum

Copy link
Copy Markdown
Contributor

Does this PR introduce a user-facing change?

Yes

Add --ignore flag to secret create command to allow noop in case the secret already exists 

@openshift-ci openshift-ci Bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 18, 2025
@github-actions github-actions Bot added the kind/api-change Change to remote API; merits scrutiny label Jun 18, 2025
@packit-as-a-service

Copy link
Copy Markdown

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

Comment thread pkg/domain/infra/abi/secrets.go Outdated
Comment on lines +27 to +41
// If ignore flag is set, check if secret already exists
if options.Ignore {
secret, err := manager.Lookup(name)
if err == nil {
// Secret exists, return its ID without error
return &entities.SecretCreateReport{
ID: secret.ID,
}, nil
}
if !errors.Is(err, secrets.ErrNoSuchSecret) {
// Some other error occurred during lookup
return nil, err
}
// Secret doesn't exist, continue with creation
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not "atomic", which means this check might say secret does not exist and then before we call manager.Store() another process might have created it causing the --ignore command to fail with secret already exists which would be totally unexpected.

Logically I think the right thing is to handle that after manager.Store() and inspect if the error is errSecretNameInUse and then return no error. Of course the issue is that errSecretNameInUse is not public so we would first have to export it in c/common

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.

Good catch, thanks.
QQ if we're changing c/common and the change is in the SecretsManager, should we just move the change there? replace is already handled there

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sure implementing it there sounds reasonable to me.

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
@ygalblum ygalblum force-pushed the secret-create-ignore branch from 0d51999 to bfc327a Compare June 24, 2025 19:43
@ygalblum

Copy link
Copy Markdown
Contributor Author

@Luap99 I've updated the code to use the new flag from the secret manager in c/common

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, comment is non blocking as I don't think we would have to backport such a feature ever.

Comment thread go.mod
github.com/containernetworking/plugins v1.7.1
github.com/containers/buildah v1.40.1-0.20250604193037-b8d8cc375f30
github.com/containers/common v0.63.2-0.20250604184922-bb2062b6265c
github.com/containers/common v0.63.2-0.20250624163146-1bc9d1737003

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not blocking but in general (unless there is a API breakage that prevents the compile) it is best to to the vendor bump in a separate commit.
That ensure that the actual code change can be reviewed more easily but also most important if we have to backport this for whatever reason we would like to cherry-pick it and it can only work conflict free without vendor changes.

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.

Thanks for the info. I'll make sure to separate them in the future.
Just for me to understand, this change will not work without the vendor change (as it relies on new code in c/common). So, I don't understand your comment:

it can only work conflict free without vendor changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct it needs the vendor change, however it only needs that one specific new secret option. So in case of a RHEL backport or whatever one would backport your c/common change into an older c/common branch then tag a new release with it and then vendor this into an older podman branch. Then that person still has to backport the podman code change and because the vendor/go.mod stuff differs we get conflicts. With two commits we could most likely cleanly cherry-pick the podman code change which then works with the backported c/common

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.

I see. Thanks for the explanation

@openshift-ci

openshift-ci Bot commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, ygalblum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@ygalblum

Copy link
Copy Markdown
Contributor Author

@containers/podman-maintainers PTAL

@ashley-cui ashley-cui 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.

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 25, 2025
@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

LGTM
Looks like the sqlite test has been unhappy, but someone restarted it.

@openshift-merge-bot openshift-merge-bot Bot merged commit 4942875 into podman-container-tools:main Jun 26, 2025
85 checks passed
@ygalblum ygalblum deleted the secret-create-ignore branch June 26, 2025 15:31
@stale-locking-app stale-locking-app Bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 25, 2025
@stale-locking-app stale-locking-app Bot locked as resolved and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants