From 0ad9507bb5af86e006f1eacc77e13a1575ee878a Mon Sep 17 00:00:00 2001 From: Benjamin Schimke Date: Fri, 7 Mar 2025 20:13:00 +0100 Subject: [PATCH] Fix: Temporarily disable snap/k8sd config sync during snap upgrade (#1164) The snap and k8sd configurations are synchronized via k8s x-snapd-config in the configure hook. However, this process requires access to the k8sd API, which may be unavailable during an upgrade. For instance, in a clustered setup with microcluster, the upgrade process can be blocked until all nodes are on the same version, causing the reconciliation to time out. We now explicitly disable the config sync during the snap upgrade to avoid such scenarios. --- snap/hooks/post-refresh | 10 ++++++++++ snap/hooks/pre-refresh | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 snap/hooks/post-refresh create mode 100644 snap/hooks/pre-refresh diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh new file mode 100644 index 000000000..f8dc38552 --- /dev/null +++ b/snap/hooks/post-refresh @@ -0,0 +1,10 @@ +#!/bin/bash -e +. "$SNAP/k8s/lib.sh" + +k8s::common::setup_env + +# Enable the snap config reconciler after the snap refresh completes. +# The reconcile command will synchronize the k8sd configuration with the snap config +# and then set the meta orb to "snapd," effectively re-enabling the sync process. +echo "Re-enabling snapd config sync after snap refresh" +k8s::cmd::k8s x-snapd-config reconcile diff --git a/snap/hooks/pre-refresh b/snap/hooks/pre-refresh new file mode 100644 index 000000000..69420a199 --- /dev/null +++ b/snap/hooks/pre-refresh @@ -0,0 +1,9 @@ +#!/bin/bash -e +. "$SNAP/k8s/lib.sh" + +k8s::common::setup_env + +# disable snap set/get on snap refresh as microcluster need to sync first. +# the sync will be enabled again after the refresh. +echo "Disabling snapd config sync during snap refresh" +k8s::cmd::k8s x-snapd-config disable