Cleanup k8s states after upgrade
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
exec >>/var/log/monok8s/boot.log 2>&1
|
||||||
|
|
||||||
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
|
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
|
||||||
|
|
||||||
@@ -6,4 +9,18 @@ mkdir -p /dev/hugepages
|
|||||||
mountpoint -q /dev/hugepages || mount -t hugetlbfs none /dev/hugepages
|
mountpoint -q /dev/hugepages || mount -t hugetlbfs none /dev/hugepages
|
||||||
echo 640 > /proc/sys/vm/nr_hugepages
|
echo 640 > /proc/sys/vm/nr_hugepages
|
||||||
|
|
||||||
|
CUR=$(grep '^BOOT_PART=' /run/monok8s/boot-state.env | cut -d= -f2-)
|
||||||
|
LAST=$(cat /opt/monok8s/config/.bootpart 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ "$CUR" != "$LAST" ]; then
|
||||||
|
echo "Slot changed ($LAST -> $CUR), cleaning runtime state"
|
||||||
|
|
||||||
|
rm -rf /var/lib/containers \
|
||||||
|
/var/lib/kubelet/pods \
|
||||||
|
/var/lib/kubelet/plugins \
|
||||||
|
/var/lib/kubelet/device-plugins
|
||||||
|
|
||||||
|
mkdir -p /var/lib/containers /var/lib/kubelet
|
||||||
|
fi
|
||||||
|
|
||||||
/usr/local/bin/ctl init --env-file /opt/monok8s/config/cluster.env >>/var/log/monok8s/bootstrap.log 2>&1 &
|
/usr/local/bin/ctl init --env-file /opt/monok8s/config/cluster.env >>/var/log/monok8s/bootstrap.log 2>&1 &
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ DPDK_VERSION=lf-6.18.2-1.0.0
|
|||||||
VPP_VERSION=lf-6.18.2-1.0.0
|
VPP_VERSION=lf-6.18.2-1.0.0
|
||||||
VPP_UPSTREAM_VERSION=23.10
|
VPP_UPSTREAM_VERSION=23.10
|
||||||
|
|
||||||
CRIO_VERSION=cri-o.arm64.v1.33.3
|
CRIO_VERSION=cri-o.arm64.v1.35.2
|
||||||
KUBE_VERSION=v1.33.3
|
KUBE_VERSION=v1.35.3
|
||||||
|
|
||||||
# Mono's tutorial said fsl-ls1046a-rdb.dtb but our shipped board is not that one
|
# Mono's tutorial said fsl-ls1046a-rdb.dtb but our shipped board is not that one
|
||||||
# We need fsl-ls1046a-rdb-sdk.dtb here
|
# We need fsl-ls1046a-rdb-sdk.dtb here
|
||||||
|
|||||||
@@ -326,6 +326,8 @@ func markProgressCompleted(
|
|||||||
|
|
||||||
cur.Status.Phase = monov1alpha1.OSUpgradeProgressPhaseCompleted
|
cur.Status.Phase = monov1alpha1.OSUpgradeProgressPhaseCompleted
|
||||||
cur.Status.Message = message
|
cur.Status.Message = message
|
||||||
|
cur.Status.CurrentVersion = osup.Status.CurrentVersion
|
||||||
|
cur.Status.TargetVersion = osup.Status.TargetVersion
|
||||||
cur.Status.LastUpdatedAt = &now
|
cur.Status.LastUpdatedAt = &now
|
||||||
cur.Status.CompletedAt = &now
|
cur.Status.CompletedAt = &now
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,6 +29,31 @@ func ReleaseControlGate(ctx context.Context, nctx *NodeContext) error {
|
|||||||
return fmt.Errorf("relate control gate: %w", err)
|
return fmt.Errorf("relate control gate: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return WriteLastState(ctx, nctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Required for detecting bootslot changes
|
||||||
|
func WriteLastState(ctx context.Context, nctx *NodeContext) error {
|
||||||
|
stBootPart := filepath.Join(monov1alpha1.EnvConfigDir, ".bootpart")
|
||||||
|
|
||||||
|
state, err := osimage.ReadBootState()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("read boot state: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bootPart := state["BOOT_PART"]
|
||||||
|
if bootPart == "" {
|
||||||
|
return fmt.Errorf("BOOT_PART missing")
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp := stBootPart + ".tmp"
|
||||||
|
if err := os.WriteFile(tmp, []byte(bootPart+"\n"), 0o644); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := os.Rename(tmp, stBootPart); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user