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

Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place #2639

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

HuijingHei
Copy link
Collaborator

@HuijingHei HuijingHei commented Jun 9, 2022

Describe the enhancement

Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place.

Example:

$ sudo ostree admin kargs edit-in-place --append-if-missing=rw
This would be useful for: https://fedoraproject.org/wiki/Changes/Silverblue_Kinoite_readonly_sysroot

@HuijingHei HuijingHei changed the title RFE: Add a hidden option to ostree admin kargs edit-in-place to WIP: RFE: Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place Jun 9, 2022
Copy link
Member

@travier travier left a comment

Choose a reason for hiding this comment

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

Not a full review but looks good.

src/ostree/ot-admin-builtin-kargs.c Show resolved Hide resolved
src/ostree/ot-admin-builtin-kargs.c Outdated Show resolved Hide resolved
src/ostree/ot-admin-kargs-builtin-edit-in-place.c Outdated Show resolved Hide resolved
src/ostree/ot-admin-kargs-builtins.h Outdated Show resolved Hide resolved
tests/test-admin-kargs.sh Show resolved Hide resolved
tests/test-admin-kargs.sh Show resolved Hide resolved
@HuijingHei HuijingHei force-pushed the admin-kargs-edit-in-place branch 3 times, most recently from 3bccc54 to bc08c71 Compare June 13, 2022 14:50
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.

Thanks so much for working on this!

src/libostree/ostree-kernel-args.c Outdated Show resolved Hide resolved
src/libostree/ostree-kernel-args.c Outdated Show resolved Hide resolved
src/libostree/ostree-kernel-args.c Outdated Show resolved Hide resolved
src/libostree/ostree-kernel-args.c Outdated Show resolved Hide resolved
src/ostree/ot-admin-kargs-builtin-edit-in-place.c Outdated Show resolved Hide resolved
src/ostree/ot-admin-kargs-builtin-edit-in-place.c Outdated Show resolved Hide resolved
src/ostree/ot-admin-kargs-builtin-edit-in-place.c Outdated Show resolved Hide resolved
src/ostree/ot-admin-kargs-builtin-edit-in-place.c Outdated Show resolved Hide resolved
@HuijingHei HuijingHei force-pushed the admin-kargs-edit-in-place branch 9 times, most recently from 1131f57 to 4ca6975 Compare June 15, 2022 08:18
{
char *duped = g_strdup (arg);

if (g_hash_table_contains (kargs->table, duped))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • The value that has = like TESTARG=TESTVALUE will be appended again if call twice, for example the result will be like:
# options root=LABEL=MOO quiet ostree=/ostree/boot.1/testos/7bd091ad6955c0e7ef41bab65adb016275664b55efc0d10a0c8cb263da3c1e4e/0 ARGWITHOUTKEY TESTARG=TESTVALUE TESTARG=TESTVALUE
  • But value like ARGWITHOUTKEY will not be appended twice as expected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Parse the key from key=value and call g_hash_table_contains (kargs->table, key)

Copy link
Member

Choose a reason for hiding this comment

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

Right...I think the logic we want here is more like:

  g_autofree char *key = g_strdup (arg);
  const char *val = split_keyeq (key);

  // Don't insert a duplicate key.
  if (g_hash_table_contains (kargs->table, key))
    return; 

  ostree_kernel_args_append (kargs, arg);

or so?

Though, if the argument table already has e.g. TESTARG=VAL1 and we say append_if_missing (TESTARG=VAL2) ...do we expect it to be ignored, or to add a new value, or to replace the existing one? I guess in most cases we want it to be ignored, which is what will happen here.

@HuijingHei HuijingHei force-pushed the admin-kargs-edit-in-place branch 2 times, most recently from e24f60a to 74a3317 Compare June 20, 2022 02:54
@HuijingHei HuijingHei changed the title WIP: RFE: Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place RFE: Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place Jun 20, 2022
@HuijingHei
Copy link
Collaborator Author

/retest

@HuijingHei HuijingHei force-pushed the admin-kargs-edit-in-place branch from 74a3317 to c88370e Compare June 21, 2022 01:35
src/libostree/ostree-kernel-args.c Outdated Show resolved Hide resolved
{
char *duped = g_strdup (arg);

if (g_hash_table_contains (kargs->table, duped))
Copy link
Member

Choose a reason for hiding this comment

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

Right...I think the logic we want here is more like:

  g_autofree char *key = g_strdup (arg);
  const char *val = split_keyeq (key);

  // Don't insert a duplicate key.
  if (g_hash_table_contains (kargs->table, key))
    return; 

  ostree_kernel_args_append (kargs, arg);

or so?

Though, if the argument table already has e.g. TESTARG=VAL1 and we say append_if_missing (TESTARG=VAL2) ...do we expect it to be ignored, or to add a new value, or to replace the existing one? I guess in most cases we want it to be ignored, which is what will happen here.

@HuijingHei HuijingHei force-pushed the admin-kargs-edit-in-place branch 2 times, most recently from 75718f9 to fcc2b40 Compare June 23, 2022 03:26
@HuijingHei
Copy link
Collaborator Author

You are right, this will not add duplicate key.

Update according to your suggestion, and make a little change for const char *val = split_keyeq (key); to split_keyeq (key); to avoid error

src/libostree/ostree-kernel-args.c:824:15: warning: unused variable 'val' [-Wunused-variable]
  824 |   const char *val = split_keyeq (key);

@cgwalters
Copy link
Member

 --- expected-documented.txt	2022-06-23 03:30:28.690917580 +0000
+++ found-documented.txt	2022-06-23 03:30:28.694917654 +0000
@@ -116,7 +116,6 @@
 ostree_kernel_args_append
 ostree_kernel_args_append_argv
 ostree_kernel_args_append_argv_filtered
-ostree_kernel_args_append_if_missing
 ostree_kernel_args_append_proc_cmdline
 ostree_kernel_args_cleanup
 ostree_kernel_args_delete
OK closing connection
ERROR: tests/test-symbols.sh - too few tests run (expected 3, got 1)
ERROR: tests/test-symbols.sh - exited with status 1

Need to also add the new symbol to apidoc/ostree-sections.txt.

update all existing deployments in place

Example:
$ sudo ostree admin kargs edit-in-place --append-if-missing=rw
See ostreedev#2617

This will not add duplicate key, if there is `TESTARG=VAL1` in the
kernel arguments, `--append-if-missing=TESTARG=VAL2` will be ignored.
@HuijingHei HuijingHei force-pushed the admin-kargs-edit-in-place branch from fcc2b40 to 3bc59a5 Compare June 23, 2022 14:31
@HuijingHei
Copy link
Collaborator Author

Need to also add the new symbol to apidoc/ostree-sections.txt.

Update is done, thanks!

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.

Thanks!

@cgwalters
Copy link
Member

/override continuous-integration/jenkins/pr-merge

@openshift-ci
Copy link

openshift-ci bot commented Jun 23, 2022

@cgwalters: Overrode contexts on behalf of cgwalters: continuous-integration/jenkins/pr-merge

In response to this:

/override continuous-integration/jenkins/pr-merge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@cgwalters cgwalters merged commit 578a0c2 into ostreedev:main Jun 23, 2022
@travier
Copy link
Member

travier commented Jun 23, 2022

🎉

@travier
Copy link
Member

travier commented Jun 23, 2022

Thanks for the work here @HuijingHei !

@HuijingHei
Copy link
Collaborator Author

I am much appreciated with the help of @cgwalters and @travier, thanks a lot!

@cgwalters cgwalters changed the title RFE: Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place Add a hidden option to ostree admin kargs edit-in-place to update all existing deployments in place Jun 24, 2022
@HuijingHei HuijingHei deleted the admin-kargs-edit-in-place branch July 14, 2022 01:20
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.

3 participants