Skip to content

Conversation

@amoralej
Copy link
Contributor

@amoralej amoralej commented Jan 14, 2025

This PR integrates the creation/update/delete of WatcherAPI in the main Watcher reconcile loop. It:

  • Adds the relevant WatcherAPI CRD atributes into the Watcher CRD.
  • Adds the logic to create/update/delete WatcherAPI from the Watcher CR.
  • Modifty existing envtest functional tests to validate the WatcherAPI creation from the Watcher objects.
  • Modifies kuttl test to validate watcherapi as part of watcher CR creation.

Related: OSPRH-11836

Depends-On: openstack-k8s-operators/install_yamls#996
Depends-On: openstack-k8s-operators/ci-framework#2658

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-k8s-operators/watcher-operator for 38,f0526823974049e7a52f8801d6268cbe8c8aa8af

This patch integrates the creation/update/delete of WatcherAPI in the
main Watcher reconcile loop. It:

- Adds the relevant WatcherAPI CRD atributes into the Watcher CRD.
- Adds the logic to create/update/delete WatcherAPI from the Watcher
  CR.
- Modifty existing envtest functional tests to validate the WatcherAPI
  creation from the Watcher objects.
After integrating watcherapi into watcher we need to validate watcherapi
and the nested resources are properly created as part of the Watcher
creation.

Also, this patch is removing the previous kuttl scenario which created
watcherapi directly without watcher top level CR.
We are defining the command in the TestAssert twice and the second one
is just overriding the first one which is never executed. This patch is
merging both in just one assignment which is what kuttl tests definition
seems to expect.
@amoralej
Copy link
Contributor Author

recheck

@cescgina
Copy link
Contributor

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jan 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cescgina

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

return apiDeployment, op, nil

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will there be some removal from the watcherapi_controller.go at some point then (maybe a followup)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really. The only change is that we will call watcherapi from watcher as-is, not changes neede in watcherapi_controller.go afaik.

Comment on lines +755 to +767
WatcherCommon: watcherv1beta1.WatcherCommon{
ServiceUser: instance.Spec.ServiceUser,
PasswordSelectors: instance.Spec.PasswordSelectors,
MemcachedInstance: instance.Spec.MemcachedInstance,
NodeSelector: instance.Spec.APIServiceTemplate.NodeSelector,
PreserveJobs: instance.Spec.PreserveJobs,
},
WatcherSubCrsCommon: watcherv1beta1.WatcherSubCrsCommon{
ContainerImage: instance.Spec.APIContainerImageURL,
Replicas: instance.Spec.APIServiceTemplate.Replicas,
Resources: instance.Spec.APIServiceTemplate.Resources,
ServiceAccount: "watcher-" + instance.Name,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe this can be simplified/flattened. Since WatcherCommon and WatcherSubCrsCommon are inline structs in the WatcherAPISpec, you don't need to explicitly create them. Instead, you should be able to directly use their fields within WatcherAPISpec itself, i.e.

	watcherAPISpec := watcherv1beta1.WatcherAPISpec{
		Secret: instance.Name,
                // WatcherCommon fields below
	        ServiceUser:       instance.Spec.ServiceUser,
		PasswordSelectors: instance.Spec.PasswordSelectors,
		MemcachedInstance: instance.Spec.MemcachedInstance,
		NodeSelector:      instance.Spec.APIServiceTemplate.NodeSelector,
		PreserveJobs:      instance.Spec.PreserveJobs,
		// WatcherSubCrsCommon fields below
		ContainerImage: instance.Spec.APIContainerImageURL,
		Replicas:       instance.Spec.APIServiceTemplate.Replicas,
		Resources:      instance.Spec.APIServiceTemplate.Resources,
		ServiceAccount: "watcher-" + instance.Name,
	}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you need to be explicit though. I just thought inline worked this way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. I think I am just confusing myself. 😆

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking of composition, not in-lining: https://stackoverflow.com/questions/70094078/what-is-the-proper-way-using-composition-in-golang. And you're doing the latter, not the former, here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I followed the same approach as in nova operator, i.e. in https://github.com/openstack-k8s-operators/nova-operator/blob/70784bbb8ddd11fff955a2f8b5151a3b3cbbb7f3/controllers/nova_controller.go#L1267-L1274 . Do you think we should follow a better way of doing it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is fine. Again, sorry for the confusion.

type: string
required:
- apiContainerImageURL
- apiServiceTemplate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add a webhook validation for apiServiceTemplate? Or Can I include it in this this pr #33 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd bet by adding more validation later, once we have a final definition. I'd propose to keep a basic skeleton of the validation in #33 and complete it when we have the operator in a functional status.

@cescgina
Copy link
Contributor

recheck

@softwarefactory-project-zuul
Copy link

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/c6741871d50d4b8b98b87b9756701995

✔️ noop SUCCESS in 0s
✔️ openstack-meta-content-provider SUCCESS in 1h 56m 04s
✔️ watcher-operator-validation SUCCESS in 1h 25m 25s
watcher-operator-kuttl RETRY_LIMIT in 1h 02m 09s

@cescgina
Copy link
Contributor

recheck

@softwarefactory-project-zuul
Copy link

This change depends on a change that failed to merge.

Change openstack-k8s-operators/ci-framework#2658 is needed.

@cescgina
Copy link
Contributor

recheck

@raukadah
Copy link
Contributor

/lgtm

Overall looks good!

@openshift-ci openshift-ci bot added the lgtm label Jan 17, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit bdd0e99 into openstack-k8s-operators:main Jan 17, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants