-
Notifications
You must be signed in to change notification settings - Fork 26
Integrate WatcherAPI creation and update on the main Watcher reconcile #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate WatcherAPI creation and update on the main Watcher reconcile #38
Conversation
|
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. |
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.
|
recheck |
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| return apiDeployment, op, nil | ||
|
|
||
| } | ||
|
|
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
| 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, | ||
| }, |
There was a problem hiding this comment.
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,
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 😆
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
|
recheck |
|
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/c6741871d50d4b8b98b87b9756701995 ✔️ noop SUCCESS in 0s |
|
recheck |
|
This change depends on a change that failed to merge. Change openstack-k8s-operators/ci-framework#2658 is needed. |
|
recheck |
|
/lgtm Overall looks good! |
bdd0e99
into
openstack-k8s-operators:main
This PR integrates the creation/update/delete of WatcherAPI in the main Watcher reconcile loop. It:
Related: OSPRH-11836
Depends-On: openstack-k8s-operators/install_yamls#996
Depends-On: openstack-k8s-operators/ci-framework#2658