Skip to content

Commit 1bffe82

Browse files
Merge pull request #4822 from sairameshv/remove_cgrpv1
OCPNODE-2842: Set Upgradeable=False when cluster is on cgroup v1
2 parents d7ef09e + 3f3df1b commit 1bffe82

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

Diff for: pkg/operator/operator_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
fakeconfigclientset "github.com/openshift/client-go/config/clientset/versioned/fake"
1111
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
1212
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
13+
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
1314
"github.com/openshift/machine-config-operator/test/helpers"
1415
"github.com/prometheus/client_golang/prometheus/testutil"
1516
"github.com/stretchr/testify/assert"
@@ -70,6 +71,14 @@ func TestMetrics(t *testing.T) {
7071
operatorIndexer.Add(co)
7172
operatorIndexer.Add(kasOperator)
7273

74+
configNode := &configv1.Node{
75+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.ClusterNodeInstanceName},
76+
Spec: configv1.NodeSpec{},
77+
}
78+
configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
79+
optr.nodeClusterLister = configlistersv1.NewNodeLister(configNodeIndexer)
80+
configNodeIndexer.Add(configNode)
81+
7382
optr.configClient = fakeconfigclientset.NewSimpleClientset(co, kasOperator)
7483
err := optr.syncAll([]syncFunc{
7584
{name: "fn1",

Diff for: pkg/operator/status.go

+9
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ func (optr *Operator) syncUpgradeableStatus(co *configv1.ClusterOperator) error
280280
Reason: asExpectedReason,
281281
}
282282

283+
configNode, err := optr.nodeClusterLister.Get(ctrlcommon.ClusterNodeInstanceName)
284+
if err != nil {
285+
return err
286+
}
287+
if configNode.Spec.CgroupMode == configv1.CgroupModeV1 {
288+
coStatusCondition.Status = configv1.ConditionFalse
289+
coStatusCondition.Reason = "ClusterOnCgroupV1"
290+
coStatusCondition.Message = "Cluster is using deprecated cgroup v1 and is not upgradable. Please update the `CgroupMode` in the `nodes.config.openshift.io` object to 'v2'. Once upgraded, the cluster cannot be changed back to cgroup v1"
291+
}
283292
var updating, degraded, interrupted bool
284293
for _, pool := range pools {
285294
// collect updating status but continue to check each pool to see if any pool is degraded

Diff for: pkg/operator/status_test.go

+37
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,14 @@ func TestOperatorSyncStatus(t *testing.T) {
691691
configMapIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
692692
optr.mcoCmLister = corelisterv1.NewConfigMapLister(configMapIndexer)
693693

694+
configNode := &configv1.Node{
695+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.ClusterNodeInstanceName},
696+
Spec: configv1.NodeSpec{},
697+
}
698+
configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
699+
optr.nodeClusterLister = configlistersv1.NewNodeLister(configNodeIndexer)
700+
configNodeIndexer.Add(configNode)
701+
694702
for j, sync := range testCase.syncs {
695703
optr.inClusterBringup = sync.inClusterBringUp
696704
if sync.nextVersion != "" {
@@ -756,6 +764,14 @@ func TestInClusterBringUpStayOnErr(t *testing.T) {
756764
},
757765
},
758766
}
767+
configNode := &configv1.Node{
768+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.ClusterNodeInstanceName},
769+
Spec: configv1.NodeSpec{},
770+
}
771+
configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
772+
optr.nodeClusterLister = configlistersv1.NewNodeLister(configNodeIndexer)
773+
configNodeIndexer.Add(configNode)
774+
759775
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse}, clock.RealClock{})
760776
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse}, clock.RealClock{})
761777
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorDegraded, Status: configv1.ConditionFalse}, clock.RealClock{})
@@ -822,6 +838,13 @@ func TestKubeletSkewUnSupported(t *testing.T) {
822838
})
823839

824840
co := &configv1.ClusterOperator{}
841+
configNode := &configv1.Node{
842+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.ClusterNodeInstanceName},
843+
Spec: configv1.NodeSpec{},
844+
}
845+
configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
846+
optr.nodeClusterLister = configlistersv1.NewNodeLister(configNodeIndexer)
847+
configNodeIndexer.Add(configNode)
825848
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse}, clock.RealClock{})
826849
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse}, clock.RealClock{})
827850
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorDegraded, Status: configv1.ConditionFalse}, clock.RealClock{})
@@ -921,6 +944,13 @@ func TestCustomPoolKubeletSkewUnSupported(t *testing.T) {
921944
})
922945

923946
co := &configv1.ClusterOperator{}
947+
configNode := &configv1.Node{
948+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.ClusterNodeInstanceName},
949+
Spec: configv1.NodeSpec{},
950+
}
951+
configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
952+
optr.nodeClusterLister = configlistersv1.NewNodeLister(configNodeIndexer)
953+
configNodeIndexer.Add(configNode)
924954
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse}, clock.RealClock{})
925955
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse}, clock.RealClock{})
926956
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorDegraded, Status: configv1.ConditionFalse}, clock.RealClock{})
@@ -1018,6 +1048,13 @@ func TestKubeletSkewSupported(t *testing.T) {
10181048
})
10191049

10201050
co := &configv1.ClusterOperator{}
1051+
configNode := &configv1.Node{
1052+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.ClusterNodeInstanceName},
1053+
Spec: configv1.NodeSpec{},
1054+
}
1055+
configNodeIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
1056+
optr.nodeClusterLister = configlistersv1.NewNodeLister(configNodeIndexer)
1057+
configNodeIndexer.Add(configNode)
10211058
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse}, clock.RealClock{})
10221059
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorProgressing, Status: configv1.ConditionFalse}, clock.RealClock{})
10231060
cov1helpers.SetStatusCondition(&co.Status.Conditions, configv1.ClusterOperatorStatusCondition{Type: configv1.OperatorDegraded, Status: configv1.ConditionFalse}, clock.RealClock{})

0 commit comments

Comments
 (0)