Skip to content

Commit 5852534

Browse files
Merge pull request #867 from flavianmissi/IR-373
IR-373: remove node-ca daemon
2 parents 717e120 + 684ebd2 commit 5852534

File tree

11 files changed

+23
-573
lines changed

11 files changed

+23
-573
lines changed

bindata/assets.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

bindata/nodecadaemon.yaml

Lines changed: 0 additions & 79 deletions
This file was deleted.

pkg/operator/nodecadaemon.go

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"fmt"
66
"time"
77

8-
appsv1 "k8s.io/api/apps/v1"
98
"k8s.io/apimachinery/pkg/api/errors"
10-
utilerrors "k8s.io/apimachinery/pkg/util/errors"
9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1110
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1211
"k8s.io/apimachinery/pkg/util/wait"
1312
appsv1informers "k8s.io/client-go/informers/apps/v1"
@@ -122,65 +121,38 @@ func (c *NodeCADaemonController) sync() error {
122121
Status: operatorv1.ConditionUnknown,
123122
}
124123

125-
dsObj, err := gen.Get()
124+
_, err := gen.Get()
126125
if errors.IsNotFound(err) {
127-
availableCondition.Status = operatorv1.ConditionFalse
128-
availableCondition.Reason = "NotFound"
129-
availableCondition.Message = "The daemon set node-ca does not exist"
126+
availableCondition.Status = operatorv1.ConditionTrue
127+
availableCondition.Reason = "AsExpected"
128+
availableCondition.Message = "The daemon set node-ca is removed"
130129

131-
progressingCondition.Status = operatorv1.ConditionTrue
132-
progressingCondition.Reason = "NotFound"
133-
progressingCondition.Message = "The daemon set node-ca does not exist"
130+
progressingCondition.Status = operatorv1.ConditionFalse
131+
progressingCondition.Reason = "AsExpected"
132+
progressingCondition.Message = "The daemon set node-ca is removed"
134133
} else if err != nil {
135134
availableCondition.Reason = "Unknown"
136-
availableCondition.Message = fmt.Sprintf("Unable to check daemon set availability: %s", err)
135+
availableCondition.Message = fmt.Sprintf("Unable to check daemon set existence: %s", err)
137136

138137
progressingCondition.Reason = "Unknown"
139-
progressingCondition.Message = fmt.Sprintf("Unable to check daemon set progress: %s", err)
138+
progressingCondition.Message = fmt.Sprintf("Unable to check daemon set existence: %s", err)
140139
} else {
141-
ds := dsObj.(*appsv1.DaemonSet)
142-
if ds.Status.NumberAvailable > 0 {
143-
availableCondition.Status = operatorv1.ConditionTrue
144-
availableCondition.Reason = "AsExpected"
145-
availableCondition.Message = "The daemon set node-ca has available replicas"
146-
} else {
147-
availableCondition.Status = operatorv1.ConditionFalse
148-
availableCondition.Reason = "NoAvailableReplicas"
149-
availableCondition.Message = "The daemon set node-ca does not have available replicas"
140+
gracePeriod := int64(0)
141+
propagationPolicy := metav1.DeletePropagationForeground
142+
opts := metav1.DeleteOptions{
143+
GracePeriodSeconds: &gracePeriod,
144+
PropagationPolicy: &propagationPolicy,
150145
}
146+
err := gen.Delete(opts)
147+
if err != nil && !errors.IsNotFound(err) {
148+
availableCondition.Reason = "Unknown"
149+
availableCondition.Message = fmt.Sprintf("Unable to delete daemon set: %s", err)
151150

152-
if ds.Generation != ds.Status.ObservedGeneration {
153-
progressingCondition.Status = operatorv1.ConditionTrue
154-
progressingCondition.Reason = "Progressing"
155-
progressingCondition.Message = "The daemon set node-ca is updating node pods"
156-
} else if ds.Status.NumberUnavailable > 0 {
157-
progressingCondition.Status = operatorv1.ConditionTrue
158-
progressingCondition.Reason = "Unavailable"
159-
progressingCondition.Message = "The daemon set node-ca is deploying node pods"
160-
} else {
161-
progressingCondition.Status = operatorv1.ConditionFalse
162-
progressingCondition.Reason = "AsExpected"
163-
progressingCondition.Message = "The daemon set node-ca is deployed"
151+
progressingCondition.Reason = "Unknown"
152+
progressingCondition.Message = fmt.Sprintf("Unable to delete daemon set: %s", err)
164153
}
165154
}
166155

167-
err = resource.ApplyMutator(gen)
168-
if err != nil {
169-
_, _, updateError := v1helpers.UpdateStatus(
170-
ctx,
171-
c.operatorClient,
172-
v1helpers.UpdateConditionFn(availableCondition),
173-
v1helpers.UpdateConditionFn(progressingCondition),
174-
v1helpers.UpdateConditionFn(operatorv1.OperatorCondition{
175-
Type: "NodeCADaemonControllerDegraded",
176-
Status: operatorv1.ConditionTrue,
177-
Reason: "Error",
178-
Message: err.Error(),
179-
}),
180-
)
181-
return utilerrors.NewAggregate([]error{err, updateError})
182-
}
183-
184156
_, _, err = v1helpers.UpdateStatus(
185157
ctx,
186158
c.operatorClient,

pkg/resource/nodecadaemon.go

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package resource
22

33
import (
44
"context"
5-
"os"
65

76
appsv1 "k8s.io/api/apps/v1"
87
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -11,14 +10,9 @@ import (
1110
appsv1listers "k8s.io/client-go/listers/apps/v1"
1211
corev1listers "k8s.io/client-go/listers/core/v1"
1312

14-
operatorv1 "github.com/openshift/api/operator/v1"
1513
"github.com/openshift/library-go/pkg/operator/events"
16-
"github.com/openshift/library-go/pkg/operator/resource/resourceapply"
17-
"github.com/openshift/library-go/pkg/operator/resource/resourcemerge"
18-
"github.com/openshift/library-go/pkg/operator/resource/resourceread"
1914
"github.com/openshift/library-go/pkg/operator/v1helpers"
2015

21-
assets "github.com/openshift/cluster-image-registry-operator/bindata"
2216
"github.com/openshift/cluster-image-registry-operator/pkg/defaults"
2317
)
2418

@@ -58,52 +52,12 @@ func (ds *generatorNodeCADaemonSet) Get() (runtime.Object, error) {
5852
return ds.daemonSetLister.Get(ds.GetName())
5953
}
6054

61-
func (ds *generatorNodeCADaemonSet) expected() *appsv1.DaemonSet {
62-
daemonSet := resourceread.ReadDaemonSetV1OrDie(assets.MustAsset("nodecadaemon.yaml"))
63-
daemonSet.Spec.Template.Spec.Containers[0].Image = os.Getenv("IMAGE")
64-
return daemonSet
65-
}
66-
6755
func (ds *generatorNodeCADaemonSet) Create() (runtime.Object, error) {
68-
dep, _, err := ds.Update(nil)
69-
return dep, err
56+
return nil, nil
7057
}
7158

7259
func (ds *generatorNodeCADaemonSet) Update(o runtime.Object) (runtime.Object, bool, error) {
73-
desiredDaemonSet := ds.expected()
74-
75-
_, opStatus, _, err := ds.operatorClient.GetOperatorState()
76-
if err != nil {
77-
return nil, false, err
78-
}
79-
actualDaemonSet, updated, err := resourceapply.ApplyDaemonSet(
80-
context.TODO(),
81-
ds.client,
82-
ds.eventRecorder,
83-
desiredDaemonSet,
84-
resourcemerge.ExpectedDaemonSetGeneration(desiredDaemonSet, opStatus.Generations),
85-
)
86-
if err != nil {
87-
return o, updated, err
88-
}
89-
90-
if updated {
91-
updateStatusFn := func(newStatus *operatorv1.OperatorStatus) error {
92-
resourcemerge.SetDaemonSetGeneration(&newStatus.Generations, actualDaemonSet)
93-
return nil
94-
}
95-
96-
_, _, err = v1helpers.UpdateStatus(
97-
context.TODO(),
98-
ds.operatorClient,
99-
updateStatusFn,
100-
)
101-
if err != nil {
102-
return actualDaemonSet, updated, err
103-
}
104-
}
105-
106-
return actualDaemonSet, updated, nil
60+
return nil, false, nil
10761
}
10862

10963
func (ds *generatorNodeCADaemonSet) Delete(opts metav1.DeleteOptions) error {

pkg/resource/nodecadaemon_test.go

Lines changed: 0 additions & 69 deletions
This file was deleted.

test/e2e/aws_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func TestAWSDefaults(t *testing.T) {
7878
framework.EnsureClusterOperatorStatusIsNormal(te)
7979
framework.EnsureOperatorIsNotHotLooping(te)
8080
framework.EnsureServiceCAConfigMap(te)
81-
framework.EnsureNodeCADaemonSetIsAvailable(te)
8281

8382
s3Driver := storages3.NewDriver(context.Background(), nil, &mockLister.StorageListers)
8483
err = s3Driver.UpdateEffectiveConfig()

0 commit comments

Comments
 (0)