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

app: smarter deployment change detection #984

Closed
wants to merge 4 commits into from

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Sep 11, 2017

Commands like upgrade and deploy need to know if a new deployment
was actually laid down so that it may print a pkg diff if so. This is
implemented by listening for changes to the DefaultDeployment D-Bus
property. D-Bus emits a signal when the deployment variant changes
value.

However, in #595, with the introduction of pending-* related keys, the
deployment variant no longer represents data solely tied to that
specific deployment. In this case, because deploy operations currently
set the ref to the resolved checksum, it can happen that deploying the
same base commit when the current refspec isn't pointing to that base
commit will result in the pending-* keys dropping out and a default
deployment change notification going out.

In this patch, we strengthen how we determine whether a new deployment
was laid down by actually looking at the deployment id, rather than just
assuming that a change to the property implies a new deployment.

Closes: #981

Currently, when setting the `override-commit` key in the origin, the
upgrader pulls that commit checksum directly and then updates the
refspec to point to it. This behaviour was inherited from its ostree
version; at the time it was implemented, the pull code didn't support
passing a specific commit for a given refspec. However, we now have
the override-commit-ids option, which will make libostree update the ref
for us.

We change the code here to make use of it and simplify the function.
This also fixes the corner case of local branches: we shouldn't change
the ref if we're on a local branch. This is actually what drove me to
this patch as I was debugging coreos#981.

(Aside: I'm still not convinced updating the refspec is always the
correct thing to do even in the remote case, though it's a bit messy to
disentangle).
Also something I noticed while working on coreos#981. When sitting on a livefs
commit, once a user does `rpm-ostree cleanup --pending --rollback`, it's
impossible to redeploy the same booted commit. Let's allow users to do
this.
Commands like `upgrade` and `deploy` need to know if a new deployment
was actually laid down so that it may print a pkg diff if so. This is
implemented by listening for changes to the DefaultDeployment D-Bus
property. D-Bus emits a signal when the deployment variant changes
value.

However, in coreos#595, with the introduction of `pending-*` related keys, the
deployment variant no longer represents data solely tied to that
specific deployment. In this case, because `deploy` operations currently
set the ref to the resolved checksum, it can happen that deploying the
same base commit when the current refspec *isn't* pointing to that base
commit will result in the `pending-*` keys dropping out and a default
deployment change notification going out.

In this patch, we strengthen how we determine whether a new deployment
was laid down by actually looking at the deployment id, rather than just
assuming that a change to the property implies a new deployment.

Closes: coreos#981
@jlebon
Copy link
Member Author

jlebon commented Sep 11, 2017

Hmm, not sure what's going on with the CentOS one:

Error: Package: rpm-build-4.11.3-21.el7.x86_64 (base)
           Requires: rpm = 4.11.3-21.el7
           Installed: rpm-4.11.3-25.el7.x86_64 (@CentOS)
               rpm = 4.11.3-25.el7
           Available: rpm-4.11.3-21.el7.x86_64 (base)
               rpm = 4.11.3-21.el7

Seems like the packages in the image are newer than those in the repos.

g_autoptr(GVariantDict) dict = g_variant_dict_new (deployment);
g_autofree char *id;
g_assert (g_variant_dict_lookup (dict, "id", "s", &id));
return g_steal_pointer (&id);
Copy link
Member

Choose a reason for hiding this comment

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

Why not just g_variant_lookup(deployment, "id", "&s", &id) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I had it return a new string because we weren't keeping a reference to the associated GVariant. In the new approach, we do.

g_autoptr(GVariant) default_deployment = rpmostree_os_dup_default_deployment (os_proxy);
g_autofree char *original_id = get_id_from_deployment_variant (default_deployment);

/* we use a quark here so original_id automatically gets freed with os_proxy (but also as
Copy link
Member

Choose a reason for hiding this comment

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

I tend to view gobject data as a hack - it is a practical tool but the problem comes when you start using it a lot. Which we aren't at all, this would be the first. I'm OK keeping this but would be happier with a struct. Though hum I forget now...is there some reason we can't just query the deployment property before and after?

Copy link
Member Author

Choose a reason for hiding this comment

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

No reason, just wanted to make it easy for callers to use it without much prep. :)
Though it turned out pretty straightforward still. Fixup! ⬇️

# https://github.com/projectatomic/rpm-ostree/issues/981
vm_rpmostree cleanup -rp
csum=$(vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck)
# restart to make daemon see the pending cheksum
Copy link
Member

Choose a reason for hiding this comment

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

checksum

@cgwalters
Copy link
Member

Very nice work on all of this! The commit messages are great!

@cgwalters
Copy link
Member

Ah yep definitely nicer. Hmm...the signal before thing may have actually been an obscure workaround for the real bug in 454139d originally?

@rh-atomic-bot r+ 789305b

@rh-atomic-bot
Copy link

⌛ Testing commit 789305b with merge 4ad3ea5...

rh-atomic-bot pushed a commit that referenced this pull request Sep 12, 2017
Also something I noticed while working on #981. When sitting on a livefs
commit, once a user does `rpm-ostree cleanup --pending --rollback`, it's
impossible to redeploy the same booted commit. Let's allow users to do
this.

Closes: #984
Approved by: cgwalters
rh-atomic-bot pushed a commit that referenced this pull request Sep 12, 2017
Commands like `upgrade` and `deploy` need to know if a new deployment
was actually laid down so that it may print a pkg diff if so. This is
implemented by listening for changes to the DefaultDeployment D-Bus
property. D-Bus emits a signal when the deployment variant changes
value.

However, in #595, with the introduction of `pending-*` related keys, the
deployment variant no longer represents data solely tied to that
specific deployment. In this case, because `deploy` operations currently
set the ref to the resolved checksum, it can happen that deploying the
same base commit when the current refspec *isn't* pointing to that base
commit will result in the `pending-*` keys dropping out and a default
deployment change notification going out.

In this patch, we strengthen how we determine whether a new deployment
was laid down by actually looking at the deployment id, rather than just
assuming that a change to the property implies a new deployment.

Closes: #981

Closes: #984
Approved by: cgwalters
@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: cgwalters
Pushing 4ad3ea5 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR:src/app/rpmostree-libbuiltin.c:83:rpmostree_print_treepkg_diff: assertion failed: (deployments->len > 1)
3 participants