-
Notifications
You must be signed in to change notification settings - Fork 196
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
Deployment: add end-of-life #889
Conversation
{ | ||
g_variant_lookup (metadata, "version", "s", &version_commit); | ||
/* avoid double insertion */ | ||
if (prefix != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we only want base commit deployment to have this end-of-life attribute, or all type of deployments should contain end-of-life attribute if they exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think end-of-life is only for base commits, right? It's something we get from the remote repository. Now we could also reflect it in the derived commit, but I'd say it's simplest to only store the data once.
related to #142 |
@cgwalters any thoughts? Thanks in advance :D |
{ | ||
g_variant_lookup (metadata, "version", "s", &version_commit); | ||
/* avoid double insertion */ | ||
if (prefix != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think end-of-life is only for base commits, right? It's something we get from the remote repository. Now we could also reflect it in the derived commit, but I'd say it's simplest to only store the data once.
g_variant_lookup (metadata, "version", "s", &version_commit); | ||
/* avoid double insertion */ | ||
if (prefix != NULL) | ||
g_variant_lookup(metadata, "end-of-life", "s", &end_of_life); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style has space between identifier and parenthesis, i.e. g_variant_lookup (metadata, ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, for ostree metadata there's a convention to use namespace prefixes; for example, most of the metadata that rpm-ostree uses starts with rpmostree.
, like rpmostree.inputhash
. Theversion
metadata key should probably have been ostree.version
.
I think we should have this metadata defined in ostree, so it'd be ostree.end-of-life
. In fact...this is even an example in ostree today:
$ git describe --tags
v2017.8-28-ge87102b7
$ git grep end-of-life
man/ostree-summary.xml: <command>exampleos.end-of-life "@t 1445385600"</command>.
src/libostree/ostree-repo.h: * `exampleos.end-of-life`. The `ostree.` prefix is reserved.
Maybe we make a document upstream that has well-known metadata keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ostreedev/ostree#1024
I also noted that we also have ostree.endoflife
mentioned in the test suite; I think for consistency we should change the bits above to be ostree.endoflife
since we already support ostree.endoflife-rebase
. Want to review my PR and once it lands, do a patch on top of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, for ostree metadata there's a convention to use namespace prefixes
So in order to match the namespace prefixes, it will be 'g_variant_lookup(metadata, "ostree.end-of-life", "s", &end_of_life)' instead?
I think we should have this metadata defined in ostree, so it'd be ostree.end-of-life. In fact...this is even an example in ostree today:
I was thinking earlier that end-of-life attribute may show up in metadata only if OS vendor add it with the commit like
'ostree commit --add-detached-metadata-string="endoflife =" ' , so each commit will potentially not have end-of-life attribute at all. I am assuming if we have this metadata defined in ostree, we would need to include it in every ostree commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I missed the last comment for end-of-life(was typing the respone), currently looking it :p.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also noted that we also have ostree.endoflife mentioned in the test suite; I think for consistency we should change the bits above to be ostree.endoflife since we already support ostree.endoflife-rebase. Want to review my PR and once it lands, do a patch on top of it?
sure, currently looking it
src/app/rpmostree-builtin-status.c
Outdated
|
||
if (end_of_life_string) | ||
{ | ||
g_print("%s", end_of_life_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space between identifier and paren; we also usually don't do curly braces for single lines, but I'm fine keeping it too.
src/app/rpmostree-builtin-status.c
Outdated
|
||
if (end_of_life_string) | ||
{ | ||
g_print("%s", end_of_life_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we prefix it with something, e.g. end-of-life: %s
?
0522b95
to
d99608b
Compare
bot, retest this please |
It seems like when you have multiple deployments(could be wrong), end of life string will be displayed multiple times, because the end-of-life appears in the deployment dictionary, currently working on to find a fix for that. (p.s: problem involves a bit more stuff than I thought, will reconsider this and submit another one) |
8351279
to
bb42b00
Compare
base_checksum = g_strdup (csum); | ||
{ | ||
base_checksum = g_strdup (csum); | ||
/* we would not consider endoflife attribute for layered commits */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still want layered commits to "inherit" the end-of-life aspect though, right? I.e. when I do rpm-ostree status
, I still want to see the end-of-life message even if my commit is a layered one, right?
So really, I think we should just always call variant_add_metadata_attribute()
with base_commit
after this if-statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I was thinking that, once the user has updated the commit to the newest, if end_of_life attribute is present, I am thinking that user should not be able to perform actions such as install/upgrade any more because the upstream branch stopped updating?
As a result, I think if we do not offer install/upgrade actions for that particular upstream branch, theoretically layered commit containing end-of-life attribute should not exist?( I am assuming that layered commits can only be achieved via install/upgrade actions, could be wrong tho)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it still makes sense to allow pkg-layering on the end-of-life commit though. E.g. if a user isn't ready to rebase to the new branch, we don't want to prevent them from staying there as long as they need to by adding artificial limits, right? The status
output will still be there to remind them that they're at the end of the line. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, for that case I agree, your way makes more sense overall :), will work on to change it.
{ | ||
g_variant_lookup (metadata, attribute, "s", &attribute_string_value); | ||
if (attribute_string_value != NULL) | ||
g_variant_dict_insert (dict, attribute, "s", attribute_string_value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it might be called ostree.endoflife
in the ostree commit metadata, but is that what we want it to be called in the deployment GVariant too? The key name chosen here shows up also in the output of rpm-ostree status --json
. Maybe just end-of-life
would be more appropriate there?
Remember to drop the "WIP:" prefix from the PR title before merging, otherwise the merge bot won't accept it! |
bb42b00
to
b91ad0c
Compare
bot, retest this please |
3 similar comments
bot, retest this please |
bot, retest this please |
bot, retest this please |
if (attribute_string_value != NULL) | ||
{ | ||
/* for attributes starting with ostree., remove the prefix */ | ||
if(g_str_has_prefix (attribute, "ostree.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: space between if
and (
.
src/app/rpmostree-builtin-status.c
Outdated
g_variant_dict_lookup (dict, "endoflife", "&s", &end_of_life_string); | ||
|
||
if (end_of_life_string) | ||
g_print ("\n end-of-life: %s", end_of_life_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: there's a space between the new line and the "end-of-life" string. Is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, that space was put there just to make the code look "neater", will remove
base_checksum = g_strdup (csum); | ||
{ | ||
base_checksum = g_strdup (csum); | ||
/* we would not consider endoflife attribute for layered commits */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it still makes sense to allow pkg-layering on the end-of-life commit though. E.g. if a user isn't ready to rebase to the new branch, we don't want to prevent them from staying there as long as they need to by adding artificial limits, right? The status
output will still be there to remind them that they're at the end of the line. :)
g_variant_lookup (metadata, attribute, "s", &attribute_string_value); | ||
if (attribute_string_value != NULL) | ||
{ | ||
/* for attributes starting with ostree., remove the prefix */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems kinda arbitrary to generalize given that it's only used for one field right now. I'd just make attribute
and new_attribute
parameters, though it's up to you!
if(g_str_has_prefix (attribute, "ostree.")) | ||
{ | ||
const char *new_string = strchr (attribute, '.'); | ||
const char *new_attribute = new_string + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just do const char *new_attribute = attribute + strlen ("ostree.");
here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, nice point :D, did not think about that
umm it seems like for f26-compose, the test fails quite frequently with Error: Failed to synchronize cache for repo 'updates', but I dont think any code related to the stuff I added is being called yet, and I dont think any rpm-ostree command is being called yet. is that common for other tests too? @jlebon |
Yeah, it's not related to your changes. See projectatomic/papr#53 |
bot, retest this please |
src/app/rpmostree-builtin-status.c
Outdated
g_variant_dict_lookup (dict, "endoflife", "&s", &end_of_life_string); | ||
|
||
if (end_of_life_string) | ||
g_print ("\nEndOfLife: %s", end_of_life_string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, (sorry for the bikeshedding!), any reason we don't just print it like any other kv using print_kv
? (Preferably in red & bold as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, no worries at all, all of this is helping me to improve(when contributing) next time :D
For the print, there is actually no reason, I just did not think about that :p (may consider more carefully to follow the style of the file next time :p). I also agree it might be better to add the red & bold for the highlights, and use print_kv similar to other key/value pairs. :)
634630d
to
cc63bcb
Compare
That looks great! The only thing missing is a test. :) Maybe just something in |
sure, will take some time to learn the style of vmcheck tests, but working on it :) |
hmm, @jlebon, making an "upstream commit"( assuming that is how upgrade can be performed ) seems difficult, is it fine to just do local ostree commits and a layered commit to check for the functionality?( or is there some documents for simulating a fake "upstream commit" for upgrade?) |
There's a couple of examples around, e.g. check maybe in vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck In your case of course, you'd add vm_build_rpm foo
vm_rpmostree install foo
# check JSON of deployment 0 here using e.g. vm_assert_status_jq or vm_get_deployment_info Maybe put your test in |
When commit metadata contains ostree.endoflife attribute, its information will be added to the deployment Variant, which will later be shown as a red & bold message when 'rpm-ostree status' command is called. A test is added for future regression
26a380e
to
50afe9f
Compare
# Build a layered commit and check if EndOfLife still present | ||
vm_build_rpm foo | ||
vm_rpmostree install foo | ||
vm_assert_status_jq ".deployments[0][\"endoflife\"] == \"${META_ENDOFLIFE_MESSAGE}\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add an "ok" message here? (See the echo "ok ..."
messages up above). These msgs show up in the test output and make it easier to narrow down where testing stopped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sure :)
Great! 👍 LGTM. |
tests/vmcheck/test-basic.sh
Outdated
@@ -59,3 +59,17 @@ echo "ok status doesn't require root" | |||
# Also check that we can do status as non-root non-active | |||
vm_cmd runuser -u bin rpm-ostree status | |||
echo "ok status doesn't require active PAM session" | |||
|
|||
# Add metadata string containing EnfOfLife attribtue | |||
META_ENDOFLIFE_MESSAGE="this_is_a_test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use spaces in this? We need that to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. META_ENDOFLIFE_MESSAGE="Game over! Insert 25¢ to continue."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, the main reason is probably I dont know how to handle with quotes related syntax in shell , thus trying to stay away from it ( a bad habit from school I would say :( ). Currently working on to add it.
tests/vmcheck/test-basic.sh
Outdated
# Add metadata string containing EnfOfLife attribtue | ||
META_ENDOFLIFE_MESSAGE="this_is_a_test" | ||
commit=$(vm_cmd ostree commit -b vmcheck \ | ||
--tree=ref=vmcheck --add-metadata-string=ostree.endoflife=$META_ENDOFLIFE_MESSAGE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this would need to be --add-metadata-string=ostree.endoflife="${META_ENDOFLIFE_MESSAGE}"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above implementation seems not functioning,( which I have no clue why), it seems like when I have the above implementation, there is a random single quote get introduced.
Here is the test output with the above implementation, (the line with single quote starts with the second line)
https://paste.fedoraproject.org/paste/fNGo0KGnJKH~2Q3VSRvOTQ
However, the implementation below seems to pass the test,
--add-metadata-string=ostree.endoflife=\"${META_ENDOFLIFE_MESSAGE}\"
,
but seeing the testing output, it makes me more confused
https://paste.fedoraproject.org/paste/OAenqkrjH-MALc8m6MPzhw, some single quote gets inserted again. However, the output seems valid(no failures) when the double quote gets escaped( but IDK why too .....)
I was trying to look for some problems similar online, but was unable to do so, is there a possible reason for this behaviour(introduction of single quotes) to happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue you're probably hitting is the fact that ssh
(note vm_cmd
uses ssh
) in essence does an sh -c "$cmd $arg1 $arg2 ..."
. This basically means you lose one level of quoting. So you have to combat that by adding another level of quoting. See https://unix.stackexchange.com/a/212298/40299.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see, that makes sense :)
c9fbb60
to
7889a9e
Compare
bot, add author to whitelist |
7889a9e
to
467c40d
Compare
Sorry, I didn't notice that you'd pushed another fixup here! Currently in github we tend to add a comment after pushing an update. Looks good to me, thanks! |
☀️ Test successful - status-atomicjenkins |
if I was going to run an |
Probably the best way is to just "recommit" an existing content set; that's what happens in the tests, see: |
That said of course
|
thanks! that really helps |
When metadata contains end-of-life attribute,
its information will be added to the deployment Variant,
which will later be shown in rpm-ostree status command