Skip to content

Commit 45025e4

Browse files
author
Per Goncalves da Silva
committed
Add OLM resource to relatedObjects
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent 7120e60 commit 45025e4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

cmd/cluster-olm-operator/main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
"os"
88
"time"
99

10+
configv1 "github.com/openshift/api/config/v1"
11+
operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1"
12+
1013
_ "github.com/openshift/api/operator/v1alpha1/zz_generated.crd-manifests"
1114
"github.com/openshift/library-go/pkg/controller/controllercmd"
1215
"github.com/openshift/library-go/pkg/controller/factory"
@@ -149,6 +152,14 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
149152
versionGetter := status.NewVersionGetter()
150153
versionGetter.SetVersion("operator", status.VersionForOperatorFromEnv())
151154

155+
// Add OLM resource and openshift-cluster-olm-operator namespace to relatedObjects
156+
// to ensure that must-gather picks them up.
157+
// Note: These two resources are also hard-coded in the ClusterOperator manifest. This way,
158+
// must-gather will pick them up in case of catastrophic failure before we cluster-olm-operator
159+
// gets a chance to dynamically update the relatedObjects. Thus, making the pod logs accessible
160+
// for troubleshooting in the must-gather.
161+
relatedObjects = append(relatedObjects, newOLMObjectReference(), newNamespaceObjectReference())
162+
152163
clusterOperatorController := status.NewClusterOperatorStatusController(
153164
"olm",
154165
relatedObjects,
@@ -189,3 +200,23 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
189200
<-ctx.Done()
190201
return nil
191202
}
203+
204+
// newOLMObjectReference creates a configv1.ObjectReference for
205+
// the cluster scoped OLM resources
206+
func newOLMObjectReference() configv1.ObjectReference {
207+
return configv1.ObjectReference{
208+
Group: operatorv1alpha1.GroupName,
209+
Resource: "olms",
210+
Name: "cluster",
211+
}
212+
}
213+
214+
// newNamespaceObjectReferences creates a configv1.ObjectReference for
215+
// the OCP namespaces where this operator is installed: openshift-cluster-olm-operator
216+
func newNamespaceObjectReference() configv1.ObjectReference {
217+
return configv1.ObjectReference{
218+
Group: "",
219+
Resource: "namespaces",
220+
Name: "openshift-cluster-olm-operator",
221+
}
222+
}

manifests/0000_51_olm_07_cluster_operator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ status:
1010
versions:
1111
- name: operator
1212
version: "0.0.1-snapshot"
13+
relatedObjects:
14+
- group: ""
15+
name: openshift-cluster-olm-operator
16+
resource: namespaces
17+
- group: operator.openshift.io
18+
name: cluster
19+
resource: olms

0 commit comments

Comments
 (0)