INTLY-5492 Include stateful sets #32
INTLY-5492 Include stateful sets #32
Conversation
Verified cli against a 2.2.0 cluster CLI built from master:
CLI built from PR:
|
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.
@sergioifg94 Changes look good to me. One inline question on the inclusion of logr
.
Are there plans to have the existing controllers use the generic_controller as well? It may not be worth the effort and testing here since Heimdall will likely be deprecated in the future.
go.mod
Outdated
@@ -5,18 +5,28 @@ go 1.13 | |||
require ( | |||
cloud.google.com/go v0.37.4 // indirect | |||
github.com/coreos/prometheus-operator v0.34.0 | |||
github.com/go-logr/logr v0.1.0 |
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.
This package addition is bringing in additional indirect dependencies and a lot of new packages under the vendor folder. Is there a reason to use this over "sigs.k8s.io/controller-runtime/pkg/runtime/log"
?
https://github.com/integr8ly/heimdall/blob/master/pkg/controller/deployments/controller.go#L25
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.
The only reason this package was added was to declare the logr.Logger
type as a member of the Reconciler
struct: https://github.com/integr8ly/heimdall/pull/32/files#diff-1acebcd3c7162bca673972c513212b1dR52
Variables of this type are being used already but the type was never explicitely declared so I guess that's why it wasn't added to the go.mod
until now. Not sure if there's any way around 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.
Thanks @sergioifg94 . I am not seeing where the logr
package was being used directly already. I think that is what the controller-runtime log package might use under the hood. My preference would be to stay consistent with the existing controllers here and use the controller-runtime log package the same as https://github.com/integr8ly/heimdall/blob/master/pkg/controller/deployments/controller.go#L25
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.
@davidffrench That's the function where I got the logr.Logger
type. It returns an instance of this type but, because so far it has been used with type inference, the type was never explicitely declared. A workaround for this is to let the generic controller create the logger and receive the name so we can avoid importing the logr
package and keep using 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.
I think it is fine to allow the type inference. You can continue using the controller-runtime abstraction on logr as is used in other controllers. The package is still included in our vendor folder as it is a dependency of controller-runtime
log package. https://github.com/integr8ly/heimdall/tree/master/vendor/github.com/go-logr
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.
@davidffrench Just updated the PR. Had to create an interface with the same methods and fortunately go's type system is smart enough to validate that logr.Logger
is assignable to that interface even though they have a different name, so I don't have to explicitly import the package
About the generic controller. I initially thought of refactoring the existing controllers as part of the ticket, but it was a lot of extra work so though of creating a follow up ticket when this is merged. But as you say, if Heimdall is being deprecated there is no point |
/lgtm Successfully verified on a cluster - stateful set annotated, and stateful set pods labelled |
I had a quick look at this but I think you might have missed some change for the
Currently, I think it would just label the deployment / deployment configs -> pods from that particular namespace 🤔
|
Good spot @KevFan , I wasn't aware of that part. I'll have a look at including stateful sets |
Create a new controller that watches StatefulSet objects and inspects their images. Update CLI to generate reports for stateful sets as well. Update ImageMonitor controller to label stateful sets as well. Factor common logic between controllers into a generic reconciler `pkg/controller/generic` that performs the reconcilliation logic delegating the specific logic for each resource into an injected `HeimdallObjectInterface` implementation.
/lgtm |
Just pushed the changes mentioned by @KevFan. Verified it myself on my own cluster but added the verification steps here if anyone wants to double check |
/approve |
@sergioifg94 This needs approval from one of the Heimdall approvers - https://github.com/integr8ly/heimdall/blob/master/OWNERS |
@davidffrench Thanks for the heads up, will ping them 👍 |
Changes look fine to me. Just double checking before i approve that we are happy this will work on OpenShift 3 (It's installed as part of the current 1.x RHMI clusters https://github.com/integr8ly/installation/blob/master/inventories/group_vars/all/manifest.yaml#L137), i can't see why it wouldn't, but it doesn't look like we tested it. |
@mikenairn Good point, I'll do some testing on a 1.x cluster. Thanks! |
@mikenairn Took me a bit but just verified on a 1.x installation that Heimdall still works. Edited the URL where Heimdall resources are downloaded to point to a branch in my fork that uses my image. The operator starts successfully and monitors the resources as expected. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: davidffrench, mikenairn The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Create a new controller that watches StatefulSet objects and inspects their images.
Update CLI to generate reports for stateful sets as well.
Factor common logic between controllers into a generic reconciler
pkg/controller/generic
that performs the reconcilliation logic delegating the specific logic for each resource
into an injected
HeimdallObjectInterface
implementation.Verification steps
You'll need a cluster with RHMI 2.x installation. The Keycloak operator uses stateful sets to deploy the Keycloak pods. The following steps use keycloak to verify this
CLI
redhat-sso-7/sso73-openshift
Cluster
heimdall.monitored: 'true'
to indicate Heimdall to monitor the StatefulSetheimdall.*
annotationsheimdall.*
labels have been added to themImageMonitor verification
heimdall.monitored
label from the StatefulSet and verify that the annotations are removed.heimdall.monitored
label is added to the StatefulSetheimdall.monitored
label is deleted automatically