diff --git a/pkg/operator/configobserver/node/observe_minimum_kubelet_version.go b/pkg/operator/configobserver/node/observe_minimum_kubelet_version.go deleted file mode 100644 index ea37c99113..0000000000 --- a/pkg/operator/configobserver/node/observe_minimum_kubelet_version.go +++ /dev/null @@ -1,47 +0,0 @@ -package node - -import ( - configv1 "github.com/openshift/api/config/v1" - "github.com/openshift/library-go/pkg/operator/configobserver" - "github.com/openshift/library-go/pkg/operator/events" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/klog/v2" -) - -var minimumKubeletVersionConfigPath = "minimumKubeletVersion" - -// ObserveKubeletMinimumVersion watches the node configuration and generates the minimumKubeletVersion -func ObserveMinimumKubeletVersion(genericListers configobserver.Listers, _ events.Recorder, existingConfig map[string]interface{}) (ret map[string]interface{}, errs []error) { - defer func() { - // Prune the observed config so that it only contains minimumKubeletVersion field. - ret = configobserver.Pruned(ret, []string{minimumKubeletVersionConfigPath}) - }() - nodeLister := genericListers.(NodeLister) - configNode, err := nodeLister.NodeLister().Get("cluster") - // we got an error so without the node object we are not able to determine minimumKubeletVersion - if err != nil { - // if config/v1/node/cluster object is not found, that can be treated as a non-error case, but raise a warning - if apierrors.IsNotFound(err) { - klog.Warningf("ObserveMinimumKubeletVersion: nodes.%s/cluster not found", configv1.GroupName) - } else { - errs = append(errs, err) - } - return existingConfig, errs - } - - if configNode.Spec.MinimumKubeletVersion == "" { - // in case minimum kubelet version is not set on cluster - // return empty set of configs, this helps to unset the config - // values related to the minimumKubeletVersion. - // Also, ensures that this observer doesn't break cluster upgrades/downgrades - return map[string]interface{}{}, errs - } - - ret = map[string]interface{}{} - if err := unstructured.SetNestedField(ret, configNode.Spec.MinimumKubeletVersion, minimumKubeletVersionConfigPath); err != nil { - errs = append(errs, err) - } - - return ret, errs -} diff --git a/pkg/operator/configobserver/node/observe_minimum_kubelet_version_test.go b/pkg/operator/configobserver/node/observe_minimum_kubelet_version_test.go deleted file mode 100644 index f4c9c4be89..0000000000 --- a/pkg/operator/configobserver/node/observe_minimum_kubelet_version_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package node - -import ( - "testing" - "time" - - "github.com/google/go-cmp/cmp" - configv1 "github.com/openshift/api/config/v1" - configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" - "github.com/openshift/library-go/pkg/operator/events" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/tools/cache" - clocktesting "k8s.io/utils/clock/testing" -) - -func TestObserveKubeletMinimumVersion(t *testing.T) { - type Test struct { - name string - existingConfig map[string]interface{} - expectedObservedConfig map[string]interface{} - minimumKubeletVersion string - } - tests := []Test{ - { - name: "empty minimumKubeletVersion", - expectedObservedConfig: map[string]interface{}{}, - minimumKubeletVersion: "", - }, - { - name: "set minimumKubeletVersion", - expectedObservedConfig: map[string]interface{}{ - "minimumKubeletVersion": string("1.30.0"), - }, - minimumKubeletVersion: "1.30.0", - }, - { - name: "existing minimumKubeletVersion", - expectedObservedConfig: map[string]interface{}{ - "minimumKubeletVersion": string("1.30.0"), - }, - existingConfig: map[string]interface{}{ - "minimumKubeletVersion": string("1.29.0"), - }, - minimumKubeletVersion: "1.30.0", - }, - { - name: "existing minimumKubeletVersion unset", - expectedObservedConfig: map[string]interface{}{}, - existingConfig: map[string]interface{}{ - "minimumKubeletVersion": string("1.29.0"), - }, - minimumKubeletVersion: "", - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // test data - eventRecorder := events.NewInMemoryRecorder("", clocktesting.NewFakePassiveClock(time.Now())) - configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) - configNodeIndexer.Add(&configv1.Node{ - ObjectMeta: metav1.ObjectMeta{Name: "cluster"}, - Spec: configv1.NodeSpec{MinimumKubeletVersion: test.minimumKubeletVersion}, - }) - listers := testLister{ - nodeLister: configlistersv1.NewNodeLister(configNodeIndexer), - } - - // act - actualObservedConfig, errs := ObserveMinimumKubeletVersion(listers, eventRecorder, test.existingConfig) - - // validate - if len(errs) > 0 { - t.Fatal(errs) - } - if diff := cmp.Diff(test.expectedObservedConfig, actualObservedConfig); diff != "" { - t.Fatalf("unexpected configuration, diff = %v", diff) - } - }) - } -}