daemon: Avoid erroring out on startup/status with origin unconfigured-state

As part of an earlier cleanup of origin parsing, we started checking
the origin `unconfigured-state` even just starting the daemon, which
is kind of bad.

It's tempting to flip the default for the parser so that we *only* check
unconfigured state if we go to upgrade, but let's not do that in this patch.

Closes: #626
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-02-13 21:01:31 -05:00 committed by Atomic Bot
parent ae90a9d2b8
commit 775c7819b7
4 changed files with 21 additions and 5 deletions

View File

@ -1335,7 +1335,8 @@ clean_pkgcache_orphans (OstreeSysroot *sysroot,
OstreeDeployment *deployment = deployments->pdata[i];
g_autoptr(RpmOstreeOrigin) origin = NULL;
origin = rpmostree_origin_parse_deployment (deployment, error);
origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED,
error);
if (!origin)
return FALSE;

View File

@ -191,7 +191,8 @@ rpmostreed_deployment_generate_variant (OstreeDeployment *deployment,
id = rpmostreed_deployment_generate_id (deployment);
origin = rpmostree_origin_parse_deployment (deployment, error);
origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED,
error);
if (!origin)
return NULL;
@ -281,7 +282,8 @@ rpmostreed_commit_generate_cached_details_variant (OstreeDeployment *deployment,
{
g_autoptr(RpmOstreeOrigin) origin = NULL;
origin = rpmostree_origin_parse_deployment (deployment, error);
origin = rpmostree_origin_parse_deployment_ex (deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED,
error);
if (!origin)
return NULL;
origin_refspec = g_strdup (rpmostree_origin_get_refspec (origin));

View File

@ -1214,7 +1214,8 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error)
g_autoptr(RpmOstreeOrigin) origin = NULL;
/* Don't fail here for unknown origin types */
origin = rpmostree_origin_parse_deployment (merge_deployment, NULL);
origin = rpmostree_origin_parse_deployment_ex (merge_deployment, RPMOSTREE_ORIGIN_PARSE_FLAGS_IGNORE_UNCONFIGURED,
NULL);
if (origin)
{
cached_update = rpmostreed_commit_generate_cached_details_variant (merge_deployment,

View File

@ -24,7 +24,7 @@ export RPMOSTREE_SUPPRESS_REQUIRES_ROOT_CHECK=yes
ensure_dbus
echo "1..15"
echo "1..16"
setup_os_repository "archive-z2" "syslinux"
@ -133,6 +133,18 @@ $OSTREE remote add secureos file://$(pwd)/testos-repo
rpm-ostree rebase --os=testos secureos:$branch gpg-signed
echo "ok deploy from remote with unsigned and signed commits"
originpath=$(ostree admin --sysroot=sysroot --print-current-dir).origin
echo "unconfigured-state=Access to TestOS requires ONE BILLION DOLLARS" >> ${originpath}
pid=$(pgrep -u $(id -u) -f 'rpm-ostree.*daemon')
test -n "${pid}" || assert_not_reached "failed to find rpm-ostree pid"
kill -9 ${pid}
rpm-ostree status
if rpm-ostree upgrade --os=testos 2>err.txt; then
assert_not_reached "Upgraded from unconfigured-state"
fi
assert_file_has_content err.txt 'ONE BILLION DOLLARS'
echo "ok unconfigured status"
# Ensure it returns an error when passing a wrong option.
rpm-ostree --help | awk '/^$/ {in_commands=0} {if(in_commands==1){print $0}} /^Builtin Commands:/ {in_commands=1}' > commands
while read command; do