|
4 | 4 | "context" |
5 | 5 | goflag "flag" |
6 | 6 | "fmt" |
| 7 | + configv1 "github.com/openshift/api/config/v1" |
| 8 | + operatorv1alpha1 "github.com/openshift/api/operator/v1alpha1" |
7 | 9 | "os" |
8 | 10 | "time" |
9 | 11 |
|
@@ -149,6 +151,14 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error |
149 | 151 | versionGetter := status.NewVersionGetter() |
150 | 152 | versionGetter.SetVersion("operator", status.VersionForOperatorFromEnv()) |
151 | 153 |
|
| 154 | + // Add OLM resource and openshift-cluster-olm-operator namespace to relatedObjects |
| 155 | + // to ensure that must-gather picks them up. |
| 156 | + // Note: These two resources are also hard-coded in the ClusterOperator manifest. This way, |
| 157 | + // must-gather will pick them up in case of catastrophic failure before we cluster-olm-operator |
| 158 | + // gets a chance to dynamically update the relatedObjects. Thus, making the pod logs accessible |
| 159 | + // for troubleshooting in the must-gather. |
| 160 | + relatedObjects = append(relatedObjects, newOLMObjectReference(), newNamespaceObjectReference()) |
| 161 | + |
152 | 162 | clusterOperatorController := status.NewClusterOperatorStatusController( |
153 | 163 | "olm", |
154 | 164 | relatedObjects, |
@@ -189,3 +199,23 @@ func runOperator(ctx context.Context, cc *controllercmd.ControllerContext) error |
189 | 199 | <-ctx.Done() |
190 | 200 | return nil |
191 | 201 | } |
| 202 | + |
| 203 | +// newOLMObjectReference creates a configv1.ObjectReference for |
| 204 | +// the cluster scoped OLM resources |
| 205 | +func newOLMObjectReference() configv1.ObjectReference { |
| 206 | + return configv1.ObjectReference{ |
| 207 | + Group: operatorv1alpha1.GroupName, |
| 208 | + Resource: "OLM", |
| 209 | + Name: "cluster", |
| 210 | + } |
| 211 | +} |
| 212 | + |
| 213 | +// newNamespaceObjectReferences creates a configv1.ObjectReference for |
| 214 | +// the OCP namespaces where this operator is installed: openshift-cluster-olm-operator |
| 215 | +func newNamespaceObjectReference() configv1.ObjectReference { |
| 216 | + return configv1.ObjectReference{ |
| 217 | + Group: "", |
| 218 | + Resource: "namespaces", |
| 219 | + Name: "openshift-cluster-olm-operator", |
| 220 | + } |
| 221 | +} |
0 commit comments