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

kargs: run delete-if-present and append-if-missing failed when there is existing key #4738

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

HuijingHei
Copy link
Member

@HuijingHei HuijingHei commented Dec 20, 2023

Revert part of 1a1ef13

ostree_kernel_args_delete_if_present() calls
ostree_kernel_args_contains() which only looks at the key
part, which makes delete-if-present failed when there is
existing key. append-if-missing will hit the same problem.

]# rpm-ostree kargs --append=crashkernel=1G
]# rpm-ostree kargs
... crashkernel=1G
]# rpm-ostree kargs --unchanged-exit-77 --delete-if-present=crashkernel=auto
error: No karg 'crashkernel=auto' found
]# rpm-ostree kargs --unchanged-exit-77 --append-if-missing=crashkernel=auto
No changes.

And fix corner case when append and append-if-missing with
the same value which will append twice.

Fixes: #4718

Copy link

openshift-ci bot commented Dec 20, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@HuijingHei HuijingHei force-pushed the revert-kargs-delete branch 4 times, most recently from 317a497 to f0d9d87 Compare December 20, 2023 09:51
@HuijingHei HuijingHei marked this pull request as ready for review December 20, 2023 10:28
@cgwalters
Copy link
Member

Can you squash into a single commit too?

@HuijingHei HuijingHei force-pushed the revert-kargs-delete branch 2 times, most recently from 68ed68a to eb4013e Compare December 21, 2023 01:16
when there is existing `key`

Revert part of coreos@1a1ef13

`ostree_kernel_args_delete_if_present()` calls
`ostree_kernel_args_contains()` which only looks at the `key`
part, which makes `delete-if-present` failed when there is
existing `key`. `append-if-missing` will hit the same problem.
```
]# rpm-ostree kargs --append=crashkernel=1G
]# rpm-ostree kargs
... crashkernel=1G
]# rpm-ostree kargs --unchanged-exit-77 --delete-if-present=crashkernel=auto
error: No karg 'crashkernel=auto' found
]# rpm-ostree kargs --unchanged-exit-77 --append-if-missing=crashkernel=auto
No changes.
```

And fix corner case when `append` and `append-if-missing` with
the same value which will append twice.

Fixes: coreos#4718
@HuijingHei
Copy link
Member Author

Can you squash into a single commit too?

Sure, done. Thanks for the review!

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

My main current fear right here is that we had a set of behaviors before #4161 landed - and now have been shipping for a while with new behaviors. I'm a bit worried that we're potentially introducing a new 3rd variation of things - i.e. I'm a bit worried there might be cases that are relying on the current behavior that break with this.

However: the fact that this new code passes the existing units tests gives some confidence at least. (Offhand looking at things it seems to me we could pretty easily create new unit tests for kernel_arg_apply_patching too that run outside of a VM, would be way way cheaper to test)

OK well, it seems like this PR is basically a clean revert of that change, alongside a fix for idempotent append append-if-missing...

@@ -2707,19 +2710,20 @@ kernel_arg_apply_patching (KernelArgTransaction *self, RpmOstreeSysrootUpgrader
for (char **iter = append_if_missing; iter && *iter; iter++)
{
const char *arg = *iter;
if (!ostree_kernel_args_contains (kargs, arg))
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be cleaner with an ostree_kernel_args_contains_value which doesn't strip off the value.

@cgwalters cgwalters merged commit 3b7b276 into coreos:main Jan 2, 2024
17 checks passed
@HuijingHei HuijingHei deleted the revert-kargs-delete branch January 3, 2024 01: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.

kargs delete-if-present / append-if-missing / replace failures
2 participants