Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion internal/controller/ansibletest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
ServiceName: ansibletest.ServiceName,
NeedsNetworkAttachments: false,
NeedsConfigMaps: false,
NeedsFinalizer: false,
SupportsWorkflow: true,

BuildPod: func(ctx context.Context, instance *testv1beta1.AnsibleTest, labels, annotations map[string]string, workflowStepIndex int, pvcIndex int) (*corev1.Pod, error) {
Expand Down
13 changes: 8 additions & 5 deletions internal/controller/common_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ type TestResourceConfig[T TestResource] struct {
// NeedsConfigMaps indicates if ServiceConfigReadyCondition is needed
NeedsConfigMaps bool

// NeedsFinalizer indicates if the controller needs finalizer handling
NeedsFinalizer bool

// SupportsWorkflow indicates if the controller supports workflow feature
SupportsWorkflow bool

Expand Down Expand Up @@ -154,14 +151,20 @@ func CommonReconcile[T TestResource](

// If we're not deleting this and the service object doesn't have our
// finalizer, add it.
if config.NeedsFinalizer && instance.GetDeletionTimestamp().IsZero() &&
if instance.GetDeletionTimestamp().IsZero() &&
controllerutil.AddFinalizer(instance, helper.GetFinalizer()) {
return ctrl.Result{}, nil
}

// Handle service delete
if config.NeedsFinalizer && !instance.GetDeletionTimestamp().IsZero() {
if !instance.GetDeletionTimestamp().IsZero() {
Log.Info("Reconciling Service delete")

if lockReleased, err := r.ReleaseLock(ctx, instance); !lockReleased {
Log.Info(fmt.Sprintf(InfoCanNotReleaseLock, testOperatorLockName))
return ctrl.Result{RequeueAfter: RequeueAfterValue}, err
}

controllerutil.RemoveFinalizer(instance, helper.GetFinalizer())
Log.Info("Reconciled Service delete successfully")
return ctrl.Result{}, nil
Expand Down
1 change: 0 additions & 1 deletion internal/controller/horizontest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (r *HorizonTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
ServiceName: horizontest.ServiceName,
NeedsNetworkAttachments: false,
NeedsConfigMaps: true,
NeedsFinalizer: false,
SupportsWorkflow: false,

GenerateServiceConfigMaps: func(ctx context.Context, helper *helper.Helper, labels map[string]string, instance *testv1beta1.HorizonTest, _ int) error {
Expand Down
1 change: 0 additions & 1 deletion internal/controller/tempest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (r *TempestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
ServiceName: tempest.ServiceName,
NeedsNetworkAttachments: true,
NeedsConfigMaps: true,
NeedsFinalizer: true,
SupportsWorkflow: true,

GenerateServiceConfigMaps: func(ctx context.Context, helper *helper.Helper, _ map[string]string, instance *testv1beta1.Tempest, workflowStep int) error {
Expand Down
1 change: 0 additions & 1 deletion internal/controller/tobiko_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (r *TobikoReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
ServiceName: tobiko.ServiceName,
NeedsNetworkAttachments: true,
NeedsConfigMaps: true,
NeedsFinalizer: false,
SupportsWorkflow: true,

GenerateServiceConfigMaps: func(ctx context.Context, helper *helper.Helper, labels map[string]string, instance *testv1beta1.Tobiko, workflowStepIndex int) error {
Expand Down
6 changes: 6 additions & 0 deletions test/functional/ansibletest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ var _ = Describe("AnsibleTest controller", func() {
Expect(ansibleTest.Spec.AnsibleGitRepo).ShouldNot(BeEmpty())
Expect(ansibleTest.Spec.AnsiblePlaybookPath).ShouldNot(BeEmpty())
})

It("should have a finalizer", func() {
Eventually(func() []string {
return GetAnsibleTest(ansibleTestName).Finalizers
}, timeout, interval).Should(ContainElement("openstack.org/ansibletest"))
})
})

When("All dependencies are ready", func() {
Expand Down
6 changes: 6 additions & 0 deletions test/functional/horizontest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ var _ = Describe("HorizonTest controller", func() {
Expect(horizonTest.Spec.DashboardUrl).ShouldNot(BeEmpty())
Expect(horizonTest.Spec.AuthUrl).ShouldNot(BeEmpty())
})

It("should have a finalizer", func() {
Eventually(func() []string {
return GetHorizonTest(horizonTestName).Finalizers
}, timeout, interval).Should(ContainElement("openstack.org/horizontest"))
})
})

When("All dependencies are ready", func() {
Expand Down
2 changes: 0 additions & 2 deletions test/functional/tempest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ var _ = Describe("Tempest controller", func() {
})

It("should have a finalizer", func() {
// the reconciler loop adds the finalizer so we have to wait for
// it to run
Eventually(func() []string {
return GetTempest(tempestName).Finalizers
}, timeout, interval).Should(ContainElement("openstack.org/tempest"))
Expand Down
5 changes: 5 additions & 0 deletions test/functional/tobiko_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ var _ = Describe("Tobiko controller", func() {
Expect(tobiko.Spec.Testenv).Should(Equal("sanity"))
})

It("should have a finalizer", func() {
Eventually(func() []string {
return GetTobiko(tobikoName).Finalizers
}, timeout, interval).Should(ContainElement("openstack.org/tobiko"))
})
})

When("All dependencies are ready", func() {
Expand Down