Skip to content

Commit

Permalink
controllers: fix available crd
Browse files Browse the repository at this point in the history
The PR does the following
1. gcr.io/distroless/static:nonroot does not allow us to run
bash scripts, since with available crd we are capturing the exit
via a bash script, moving to use
registry.access.redhat.com/ubi9/ubi-minimal as the base
2. remove caching only storageCluster crd
3. fix panic while logging

Signed-off-by: Rewant Soni <[email protected]>
  • Loading branch information
rewantsoni committed Oct 14, 2024
1 parent a38421d commit 401b166
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN make go-build

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
FROM registry.access.redhat.com/ubi9/ubi-minimal
WORKDIR /
COPY --from=builder /workspace/bin/manager .
COPY --from=builder /workspace/bin/status-reporter .
Expand Down
5 changes: 0 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

storageclustersSelector := fields.SelectorFromSet(fields.Set{"metadata.name": "storageclusters.ocs.openshift.io"})
subscriptionwebhookSelector := fields.SelectorFromSet(fields.Set{"metadata.name": templates.SubscriptionWebhookName})
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Expand All @@ -114,10 +113,6 @@ func main() {
LeaderElectionID: "7cb6f2e5.ocs.openshift.io",
Cache: cache.Options{
ByObject: map[client.Object]cache.ByObject{
&extv1.CustomResourceDefinition{}: {
// only cache storagecluster crd
Field: storageclustersSelector,
},
&admrv1.ValidatingWebhookConfiguration{}: {
// only cache our validation webhook
Field: subscriptionwebhookSelector,
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func CrdCreateAndDeletePredicate(log *logr.Logger, crdName string, crdExists boo
return predicate.Funcs{
CreateFunc: func(_ event.CreateEvent) bool {
if !crdExists {
log.Info("CustomResourceDefinition %s was Created.", crdName)
log.Info("CustomResourceDefinition %s was Created.", "CustomResourceDefinition", crdName)
}
return !crdExists
},
DeleteFunc: func(_ event.DeleteEvent) bool {
if crdExists {
log.Info("CustomResourceDefinition %s was Deleted.", crdName)
log.Info("CustomResourceDefinition %s was Deleted.", "CustomResourceDefinition", crdName)
}
return crdExists
},
Expand Down

0 comments on commit 401b166

Please sign in to comment.