From 51a36294a3a3503bcaf2e0f4da1655cf70808bc1 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 30 May 2024 08:33:22 +0200 Subject: [PATCH] kubeadm: check only for `RuntimeReady` condition We only check for the `RuntimeReady` condition instead of anything else like the `NetworkReady` to allow kubeadm to provision the cluster. Refers to https://github.com/kubernetes/kubernetes/pull/124685#issuecomment-2138655482 Follow-up on: https://github.com/kubernetes/kubernetes/pull/124685 Signed-off-by: Sascha Grunert --- cmd/kubeadm/app/util/runtime/runtime.go | 3 ++- cmd/kubeadm/app/util/runtime/runtime_test.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/util/runtime/runtime.go b/cmd/kubeadm/app/util/runtime/runtime.go index 28bde230f1b..4b6800e583f 100644 --- a/cmd/kubeadm/app/util/runtime/runtime.go +++ b/cmd/kubeadm/app/util/runtime/runtime.go @@ -104,7 +104,8 @@ func (runtime *CRIRuntime) IsRunning() error { } for _, condition := range res.GetStatus().GetConditions() { - if !condition.GetStatus() { + if condition.GetType() == runtimeapi.RuntimeReady && // NetworkReady will not be tested on purpose + !condition.GetStatus() { return errors.Errorf( "container runtime condition %q is not true. reason: %s, message: %s", condition.GetType(), condition.GetReason(), condition.GetMessage(), diff --git a/cmd/kubeadm/app/util/runtime/runtime_test.go b/cmd/kubeadm/app/util/runtime/runtime_test.go index caeacb75f73..e7c2652662e 100644 --- a/cmd/kubeadm/app/util/runtime/runtime_test.go +++ b/cmd/kubeadm/app/util/runtime/runtime_test.go @@ -95,6 +95,7 @@ func TestIsRunning(t *testing.T) { mock.StatusReturns(&v1.StatusResponse{Status: &v1.RuntimeStatus{ Conditions: []*v1.RuntimeCondition{ { + Type: v1.RuntimeReady, Status: false, }, }, @@ -103,6 +104,21 @@ func TestIsRunning(t *testing.T) { }, shouldError: true, }, + { + name: "valid: runtime condition type does not match", + prepare: func(mock *fakeImpl) { + mock.StatusReturns(&v1.StatusResponse{Status: &v1.RuntimeStatus{ + Conditions: []*v1.RuntimeCondition{ + { + Type: v1.NetworkReady, + Status: false, + }, + }, + }, + }, nil) + }, + shouldError: false, + }, } { t.Run(tc.name, func(t *testing.T) { containerRuntime := NewContainerRuntime("")