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

apply: Use staged deployment on booted systems #298

Merged
merged 3 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 54 additions & 30 deletions eos-updater/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ apply_internal (ApplyData *apply_data,
g_autoptr(GKeyFile) origin = NULL;
g_autoptr(OstreeSysroot) sysroot = NULL;
const gchar *osname = get_test_osname ();
gboolean staged_deploy;
g_autoptr(GError) local_error = NULL;

sysroot = ostree_sysroot_new_default ();
Expand Down Expand Up @@ -269,21 +270,62 @@ apply_internal (ApplyData *apply_data,

origin = ostree_sysroot_origin_new_from_refspec (sysroot, update_refspec);

if (!ostree_sysroot_deploy_tree (sysroot,
osname,
update_id,
origin,
booted_deployment,
NULL,
&new_deployment,
cancellable,
error))
return FALSE;
/* When booted into an OSTree system, stage the deployment so that the
* /etc merge happens during shutdown. Otherwise (primarily the test
* suite), deploy the finalized tree immediately.
*/
staged_deploy = ostree_sysroot_is_booted (sysroot);
if (staged_deploy)
{
g_message ("Creating staged deployment for revision %s", update_id);
if (!ostree_sysroot_stage_tree (sysroot,
osname,
update_id,
origin,
booted_deployment,
NULL,
&new_deployment,
cancellable,
error))
return FALSE;
}
else
{
g_message ("Creating finalized deployment for revision %s", update_id);
if (!ostree_sysroot_deploy_tree (sysroot,
osname,
update_id,
origin,
booted_deployment,
NULL,
&new_deployment,
cancellable,
error))
return FALSE;

if (!ostree_sysroot_simple_write_deployment (sysroot,
osname,
new_deployment,
booted_deployment,
OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN,
cancellable,
error))
return FALSE;
}

g_message ("New deployment: index: %d, OS name: %s, deploy serial: %d, "
"checksum: %s, boot checksum: %s, boot serial: %d",
ostree_deployment_get_index (new_deployment),
ostree_deployment_get_osname (new_deployment),
ostree_deployment_get_deployserial (new_deployment),
ostree_deployment_get_csum (new_deployment),
ostree_deployment_get_bootcsum (new_deployment),
ostree_deployment_get_bootserial (new_deployment));

/* If the original refspec is not the update refspec, then we may have
* a ref to a no longer needed tree. Delete that remote ref so the
* cleanup done in simple_write_deployment() really removes that tree
* if no deployments point to it anymore.
* sysroot cleanup below really removes that tree if no deployments
* point to it anymore.
*/
if (g_strcmp0 (update_refspec, orig_refspec) != 0)
{
Expand All @@ -304,24 +346,6 @@ apply_internal (ApplyData *apply_data,
}
}

if (!ostree_sysroot_simple_write_deployment (sysroot,
osname,
new_deployment,
booted_deployment,
OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN,
cancellable,
error))
return FALSE;

g_message ("New deployment: index: %d, OS name: %s, deploy serial: %d, "
"checksum: %s, boot checksum: %s, boot serial: %d",
ostree_deployment_get_index (new_deployment),
ostree_deployment_get_osname (new_deployment),
ostree_deployment_get_deployserial (new_deployment),
ostree_deployment_get_csum (new_deployment),
ostree_deployment_get_bootcsum (new_deployment),
ostree_deployment_get_bootserial (new_deployment));

/* FIXME: Cleaning up after update should be non-fatal, since we've
* already successfully deployed the new OS. This clearly is a
* workaround for a more serious issue, likely related to concurrent
Expand Down
2 changes: 1 addition & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ foreach test_name, extra_args : test_programs
exe,
env: envs,
suite: ['eos-updater'] + extra_args.get('suite', []),
timeout: extra_args.get('slow', false) ? 360 : 60,
timeout: extra_args.get('slow', false) ? 600 : 60,
is_parallel: extra_args.get('parallel', true),
)
endforeach
Expand Down