Skip to content
Merged
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
31 changes: 31 additions & 0 deletions cmd/cluster-olm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"os"
"time"

configv1 "github.com/openshift/api/config/v1"
operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1"

_ "github.com/openshift/api/operator/v1alpha1/zz_generated.crd-manifests"
"github.com/openshift/library-go/pkg/controller/controllercmd"
"github.com/openshift/library-go/pkg/controller/factory"
Expand Down Expand Up @@ -149,6 +152,14 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
versionGetter := status.NewVersionGetter()
versionGetter.SetVersion("operator", status.VersionForOperatorFromEnv())

// Add OLM resource and openshift-cluster-olm-operator namespace to relatedObjects
// to ensure that must-gather picks them up.
// Note: These two resources are also hard-coded in the ClusterOperator manifest. This way,
// must-gather will pick them up in case of catastrophic failure before we cluster-olm-operator
// gets a chance to dynamically update the relatedObjects. Thus, making the pod logs accessible
// for troubleshooting in the must-gather.
relatedObjects = append(relatedObjects, newOLMObjectReference(), newNamespaceObjectReference())

clusterOperatorController := status.NewClusterOperatorStatusController(
"olm",
relatedObjects,
Expand Down Expand Up @@ -189,3 +200,23 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
<-ctx.Done()
return nil
}

// newOLMObjectReference creates a configv1.ObjectReference for
// the cluster scoped OLM resources
func newOLMObjectReference() configv1.ObjectReference {
return configv1.ObjectReference{
Group: operatorv1alpha1.GroupName,
Resource: "olms",
Name: "cluster",
}
}

// newNamespaceObjectReferences creates a configv1.ObjectReference for
// the OCP namespaces where this operator is installed: openshift-cluster-olm-operator
func newNamespaceObjectReference() configv1.ObjectReference {
return configv1.ObjectReference{
Group: "",
Resource: "namespaces",
Name: "openshift-cluster-olm-operator",
}
}
7 changes: 7 additions & 0 deletions manifests/0000_51_olm_07_cluster_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ status:
versions:
- name: operator
version: "0.0.1-snapshot"
relatedObjects:
- group: ""
name: openshift-cluster-olm-operator
resource: namespaces
- group: operator.openshift.io
name: cluster
resource: olms