Skip to content

Commit db3c6bd

Browse files
authored
fix: update the existing plugin deployment resource (#711)
* fix: update the existing plugin deployment resource Signed-off-by: Chetan Banavikalmutt <[email protected]> * reconcile the deployment spec template Signed-off-by: Chetan Banavikalmutt <[email protected]> --------- Signed-off-by: Chetan Banavikalmutt <[email protected]>
1 parent 300d8d8 commit db3c6bd

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

controllers/consoleplugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (r *ReconcileGitopsService) reconcileDeployment(cr *pipelinesv1alpha1.Gitop
279279
return reconcile.Result{}, err
280280
}
281281
} else {
282-
existingSpecTemplate := existingPluginDeployment.Spec.Template
282+
existingSpecTemplate := &existingPluginDeployment.Spec.Template
283283
newSpecTemplate := newPluginDeployment.Spec.Template
284284
changed := !reflect.DeepEqual(existingPluginDeployment.ObjectMeta.Labels, newPluginDeployment.ObjectMeta.Labels) ||
285285
!reflect.DeepEqual(existingPluginDeployment.Spec.Replicas, newPluginDeployment.Spec.Replicas) ||
@@ -304,7 +304,7 @@ func (r *ReconcileGitopsService) reconcileDeployment(cr *pipelinesv1alpha1.Gitop
304304
existingSpecTemplate.Spec.DNSPolicy = newSpecTemplate.Spec.DNSPolicy
305305
existingPluginDeployment.Spec.Template.Spec.NodeSelector = newPluginDeployment.Spec.Template.Spec.NodeSelector
306306
existingPluginDeployment.Spec.Template.Spec.Tolerations = newPluginDeployment.Spec.Template.Spec.Tolerations
307-
return reconcile.Result{}, r.Client.Update(context.TODO(), newPluginDeployment)
307+
return reconcile.Result{}, r.Client.Update(context.TODO(), existingPluginDeployment)
308308
}
309309
}
310310
return reconcile.Result{}, nil

controllers/consoleplugin_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,6 @@ func TestPlugin_reconcileDeployment_changedTemplateLabels(t *testing.T) {
483483
s := scheme.Scheme
484484
addKnownTypesToScheme(s)
485485

486-
fakeClient := fake.NewClientBuilder().WithScheme(s).WithRuntimeObjects(newGitopsService()).Build()
487-
reconciler := newReconcileGitOpsService(fakeClient, s)
488486
instance := &pipelinesv1alpha1.GitopsService{}
489487
var replicas int32 = 1
490488

@@ -586,9 +584,11 @@ func TestPlugin_reconcileDeployment_changedTemplateLabels(t *testing.T) {
586584
},
587585
},
588586
}
589-
reconciler.Client.Create(context.TODO(), d)
590587

591-
_, err := reconciler.reconcileConsolePlugin(instance, newRequest(serviceNamespace, gitopsPluginName))
588+
fakeClient := fake.NewClientBuilder().WithScheme(s).WithRuntimeObjects(newGitopsService(), d).Build()
589+
reconciler := newReconcileGitOpsService(fakeClient, s)
590+
591+
_, err := reconciler.reconcileDeployment(instance, newRequest(serviceNamespace, gitopsPluginName))
592592
assertNoError(t, err)
593593

594594
deployment := &appsv1.Deployment{}

0 commit comments

Comments
 (0)