From d983e44308b677b07d2d135f0e73349cfb7e0ca8 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 16 Jul 2024 17:24:03 +0400 Subject: [PATCH] fix: panic on shutdown Fixes #9017 Don't assume the config is there before trying to access it. Signed-off-by: Andrey Smirnov --- .../app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer.go b/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer.go index 26fb92f131..00beac3ebd 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer.go @@ -377,11 +377,13 @@ func (*Sequencer) Reset(r runtime.Runtime, in runtime.ResetOptions) []runtime.Ph // Shutdown is the shutdown sequence. func (*Sequencer) Shutdown(r runtime.Runtime, in *machineapi.ShutdownRequest) []runtime.Phase { + skipNodeRegistration := r.Config() != nil && r.Config().Machine() != nil && r.Config().Machine().Kubelet().SkipNodeRegistration() + phases := PhaseList{}.Append( "storeShudown", StoreShutdownEmergency, ).AppendWhen( - !in.GetForce() && !r.Config().Machine().Kubelet().SkipNodeRegistration(), + !in.GetForce() && !skipNodeRegistration, "drain", CordonAndDrainNode, ).Append(