Skip to content

Commit 7d0aca3

Browse files
committed
setting nodestate annotation with 'sriovnetwork.openshift.io/use-external-drainer=true' in case exteranl drainer is enabled
The motivation is for external drainer verification, that SRIOV operator is set with external drainer Signed-off-by: Ido Heyvi <[email protected]>
1 parent ae77281 commit 7d0aca3

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

controllers/drain_controller_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ var _ = Describe("Drain Controller", Ordered, func() {
129129
})
130130

131131
Context("when there is only one node", func() {
132+
It("should not drain node on drain require while use-external-drainer annotation is set",
133+
func(ctx context.Context) {
134+
node, nodeState := createNode(ctx, "node1", true)
135+
136+
simulateDaemonSetAnnotation(node, constants.DrainRequired)
137+
138+
expectNodeStateAnnotation(nodeState, constants.DrainIdle)
139+
expectNodeIsSchedulable(node)
140+
141+
})
132142

133143
It("should drain single node on drain require", func(ctx context.Context) {
134144
node, nodeState := createNode(ctx, "node1", false)
@@ -442,7 +452,7 @@ func createNode(ctx context.Context, nodeName string, useExternalDrainer bool) (
442452
ObjectMeta: metav1.ObjectMeta{
443453
Name: nodeName,
444454
Namespace: vars.Namespace,
445-
Labels: map[string]string{
455+
Annotations: map[string]string{
446456
constants.NodeStateDrainAnnotationCurrent: constants.DrainIdle,
447457
},
448458
},

deployment/sriov-network-operator-chart/templates/operator.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ spec:
8686
value: {{ .Values.operator.metricsExporter.certificates.secretName }}
8787
- name: METRICS_EXPORTER_KUBE_RBAC_PROXY_IMAGE
8888
value: {{ .Values.images.metricsExporterKubeRbacProxy }}
89-
- name: USE_EXTERNAL_DRAINER
90-
value: {{ .Values.operator.externalDrainer.enabled | quote }}
89+
{{- if .Values.operator.externalDrainer.enabled }}
90+
- name: USE_EXTERNAL_DRAINER
91+
value: {{ .Values.operator.externalDrainer.enabled | quote }}
92+
{{- end }}
9193
{{- if .Values.operator.metricsExporter.prometheusOperator.enabled }}
9294
- name: METRICS_EXPORTER_PROMETHEUS_OPERATOR_ENABLED
9395
value: {{ .Values.operator.metricsExporter.prometheusOperator.enabled | quote}}

main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func main() {
208208
os.Exit(1)
209209
}
210210

211-
if err := setupDrainController(mgr, restConfig, platformsHelper, scheme); err != nil {
211+
if err := setupDrainController(mgr, restConfig, platformsHelper, mgr.GetScheme()); err != nil {
212212
setupLog.Error(err, "unable to setup drain controller")
213213
os.Exit(1)
214214
}
@@ -274,8 +274,7 @@ func main() {
274274
func setupDrainController(mgr ctrl.Manager, restConfig *rest.Config,
275275
platformsHelper platforms.Interface, scheme *runtime.Scheme) error {
276276
if vars.UseExternalDrainer {
277-
setupLog.Info("internal drain controller is disabled, draining will be done externally by the maintenance operator")
278-
return nil
277+
setupLog.Info("'UseExternalDrainer' is set, draining will be done externally")
279278
}
280279

281280
// we need a client that doesn't use the local cache for the objects

0 commit comments

Comments
 (0)