44 "context"
55 goflag "flag"
66 "fmt"
7+ configv1 "github.com/openshift/api/config/v1"
8+ operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1"
79 "os"
810 "time"
911
@@ -30,6 +32,11 @@ import (
3032 catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1"
3133)
3234
35+ const (
36+ olmResourceName = "cluster"
37+ clusterOLMOperatorNamespace = "openshift-cluster-olm-operator"
38+ )
39+
3340func main () {
3441 pflag .CommandLine .SetNormalizeFunc (utilflag .WordSepNormalizeFunc )
3542 pflag .CommandLine .AddGoFlagSet (goflag .CommandLine )
@@ -149,6 +156,14 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
149156 versionGetter := status .NewVersionGetter ()
150157 versionGetter .SetVersion ("operator" , status .VersionForOperatorFromEnv ())
151158
159+ // Add OLM resource and openshift-cluster-olm-operator namespace to relatedObjects
160+ // to ensure that must-gather picks them up.
161+ // Note: These two resources are also hard-coded in the ClusterOperator manifest. This way,
162+ // must-gather will pick them up in case of catastrophic failure before we cluster-olm-operator
163+ // gets a chance to dynamically update the relatedObjects. Thus, making the pod logs accessible
164+ // for troubleshooting in the must-gather.
165+ relatedObjects = append (relatedObjects , newOLMObjectReference (), newNamespaceObjectReference ())
166+
152167 clusterOperatorController := status .NewClusterOperatorStatusController (
153168 "olm" ,
154169 relatedObjects ,
@@ -189,3 +204,23 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
189204 <- ctx .Done ()
190205 return nil
191206}
207+
208+ // newOLMObjectReference creates a configv1.ObjectReference for
209+ // the cluster scoped OLM resources
210+ func newOLMObjectReference () configv1.ObjectReference {
211+ return configv1.ObjectReference {
212+ Group : operatorv1alpha1 .GroupName ,
213+ Resource : "OLM" ,
214+ Name : "cluster" ,
215+ }
216+ }
217+
218+ // newNamespaceObjectReferences creates a configv1.ObjectReference for
219+ // the OCP namespaces where this operator is installed: openshift-cluster-olm-operator
220+ func newNamespaceObjectReference () configv1.ObjectReference {
221+ return configv1.ObjectReference {
222+ Group : "" ,
223+ Resource : "namespaces" ,
224+ Name : "openshift-cluster-olm-operator" ,
225+ }
226+ }
0 commit comments