Skip to content

Commit 3f79b51

Browse files
Merge pull request #76 from bparees/refs
add object refs for must gather dump
2 parents 26ae3ac + 7a69d64 commit 3f79b51

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test: test-unit test-e2e
1818

1919
test-unit:
2020
ifndef JUNITFILE
21-
go test $(GOFLAGS) -race ./...
21+
go test $(GOFLAGS) -race ./pkg/... ./cmd/...
2222
else
2323
ifeq (, $(shell which gotest2junit 2>/dev/null))
2424
$(error gotest2junit not found! Get it by `go get -u github.com/openshift/release/tools/gotest2junit`.)

pkg/operator/configobservation/deployimages/observe_deployimages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func ObserveControllerManagerImagesConfig(genericListers configobserver.Listers,
4545

4646
// now gather the cluster config and turn it into the observed config
4747
observedConfig := map[string]interface{}{}
48-
controllerManagerImagesConfigMap, err := listers.ConfigMapLister.ConfigMaps(util.OperatorNamespaceName).Get("openshift-controller-manager-images")
48+
controllerManagerImagesConfigMap, err := listers.ConfigMapLister.ConfigMaps(util.OperatorNamespace).Get("openshift-controller-manager-images")
4949
if errors.IsNotFound(err) {
5050
glog.V(2).Infof("configmap/openshift-controller-manager-images: not found")
5151
return observedConfig, errs

pkg/operator/configobservation/deployimages/observe_deployimages_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestObserveClusterConfig(t *testing.T) {
2525
cm: &corev1.ConfigMap{
2626
ObjectMeta: metav1.ObjectMeta{
2727
Name: "openshift-controller-manager-images",
28-
Namespace: util.OperatorNamespaceName,
28+
Namespace: util.OperatorNamespace,
2929
},
3030
Data: map[string]string{
3131
"builderImage": "quay.io/sample/origin-builder:v4.0",
@@ -50,7 +50,7 @@ func TestObserveClusterConfig(t *testing.T) {
5050
cm: &corev1.ConfigMap{
5151
ObjectMeta: metav1.ObjectMeta{
5252
Name: "openshift-controller-manager-images",
53-
Namespace: util.OperatorNamespaceName,
53+
Namespace: util.OperatorNamespace,
5454
},
5555
Data: map[string]string{
5656
"builderImage": "quay.io/sample/origin-builder:v4.0",
@@ -70,7 +70,7 @@ func TestObserveClusterConfig(t *testing.T) {
7070
cm: &corev1.ConfigMap{
7171
ObjectMeta: metav1.ObjectMeta{
7272
Name: "openshift-controller-manager-images",
73-
Namespace: util.OperatorNamespaceName,
73+
Namespace: util.OperatorNamespace,
7474
},
7575
Data: map[string]string{
7676
"unknownField": "quay.io/sample/origin-builder:v4.0",
@@ -84,7 +84,7 @@ func TestObserveClusterConfig(t *testing.T) {
8484
cm: &corev1.ConfigMap{
8585
ObjectMeta: metav1.ObjectMeta{
8686
Name: "shall-not-be-found",
87-
Namespace: util.OperatorNamespaceName,
87+
Namespace: util.OperatorNamespace,
8888
},
8989
Data: map[string]string{
9090
"builderImage": "quay.io/sample/origin-builder:v4.0",

pkg/operator/operator.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ import (
2222
operatorapiv1 "github.com/openshift/api/operator/v1"
2323
operatorclientv1 "github.com/openshift/client-go/operator/clientset/versioned/typed/operator/v1"
2424
operatorinformersv1 "github.com/openshift/client-go/operator/informers/externalversions/operator/v1"
25+
"github.com/openshift/cluster-openshift-controller-manager-operator/pkg/util"
2526
"github.com/openshift/library-go/pkg/operator/events"
2627
"github.com/openshift/library-go/pkg/operator/v1helpers"
2728
)
2829

2930
const (
30-
kubeAPIServerNamespaceName = "openshift-kube-apiserver"
31-
targetNamespaceName = "openshift-controller-manager"
32-
workQueueKey = "key"
33-
workloadFailingCondition = "WorkloadFailing"
31+
workQueueKey = "key"
32+
workloadFailingCondition = "WorkloadFailing"
3433
)
3534

3635
type OpenShiftControllerManagerOperator struct {
@@ -112,7 +111,7 @@ func (c OpenShiftControllerManagerOperator) sync() error {
112111

113112
case operatorapiv1.Removed:
114113
// TODO probably need to watch until the NS is really gone
115-
if err := c.kubeClient.CoreV1().Namespaces().Delete(targetNamespaceName, nil); err != nil && !apierrors.IsNotFound(err) {
114+
if err := c.kubeClient.CoreV1().Namespaces().Delete(util.TargetNamespace, nil); err != nil && !apierrors.IsNotFound(err) {
116115
return err
117116
}
118117
// TODO report that we are removing?
@@ -178,7 +177,7 @@ func (c *OpenShiftControllerManagerOperator) eventHandler() cache.ResourceEventH
178177
}
179178

180179
// this set of namespaces will include things like logging and metrics which are used to drive
181-
var interestingNamespaces = sets.NewString(targetNamespaceName)
180+
var interestingNamespaces = sets.NewString(util.TargetNamespace)
182181

183182
func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.ResourceEventHandler {
184183
return cache.ResourceEventHandlerFuncs{
@@ -187,7 +186,7 @@ func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.Resou
187186
if !ok {
188187
c.queue.Add(workQueueKey)
189188
}
190-
if ns.Name == targetNamespaceName {
189+
if ns.Name == util.TargetNamespace {
191190
c.queue.Add(workQueueKey)
192191
}
193192
},
@@ -196,7 +195,7 @@ func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.Resou
196195
if !ok {
197196
c.queue.Add(workQueueKey)
198197
}
199-
if ns.Name == targetNamespaceName {
198+
if ns.Name == util.TargetNamespace {
200199
c.queue.Add(workQueueKey)
201200
}
202201
},
@@ -214,7 +213,7 @@ func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.Resou
214213
return
215214
}
216215
}
217-
if ns.Name == targetNamespaceName {
216+
if ns.Name == util.TargetNamespace {
218217
c.queue.Add(workQueueKey)
219218
}
220219
},

pkg/operator/starter.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
5252
)
5353

5454
operatorConfigInformers := operatorinformers.NewSharedInformerFactory(operatorclient, 10*time.Minute)
55-
kubeInformersForOpenshiftControllerManagerNamespace := informers.NewSharedInformerFactoryWithOptions(kubeClient, 10*time.Minute, informers.WithNamespace(targetNamespaceName))
56-
kubeInformersForOperatorNamespace := informers.NewSharedInformerFactoryWithOptions(kubeClient, 10*time.Minute, informers.WithNamespace(util.OperatorNamespaceName))
55+
kubeInformersForOpenshiftControllerManagerNamespace := informers.NewSharedInformerFactoryWithOptions(kubeClient, 10*time.Minute, informers.WithNamespace(util.TargetNamespace))
56+
kubeInformersForOperatorNamespace := informers.NewSharedInformerFactoryWithOptions(kubeClient, 10*time.Minute, informers.WithNamespace(util.OperatorNamespace))
5757
configInformers := configinformers.NewSharedInformerFactory(configClient, 10*time.Minute)
5858

5959
operator := NewOpenShiftControllerManagerOperator(
@@ -79,7 +79,13 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
7979

8080
clusterOperatorStatus := status.NewClusterOperatorStatusController(
8181
"openshift-controller-manager",
82-
[]configv1.ObjectReference{},
82+
[]configv1.ObjectReference{
83+
{Group: "operator.openshift.io", Resource: "openshiftcontrollermanagers", Name: "cluster"},
84+
{Resource: "namespaces", Name: util.UserSpecifiedGlobalConfigNamespace},
85+
{Resource: "namespaces", Name: util.MachineSpecifiedGlobalConfigNamespace},
86+
{Resource: "namespaces", Name: util.OperatorNamespace},
87+
{Resource: "namespaces", Name: util.TargetNamespace},
88+
},
8389
configClient.ConfigV1(),
8490
opClient,
8591
status.NewVersionGetter(),

pkg/operator/sync_openshiftcontrollermanager_v311_00.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/openshift/library-go/pkg/operator/v1helpers"
2323

2424
"github.com/openshift/cluster-openshift-controller-manager-operator/pkg/operator/v311_00_assets"
25+
"github.com/openshift/cluster-openshift-controller-manager-operator/pkg/util"
2526
)
2627

2728
// syncOpenShiftControllerManager_v311_00_to_latest takes care of synchronizing (not upgrading) the thing we're managing.
@@ -149,7 +150,7 @@ func syncOpenShiftControllerManager_v311_00_to_latest(c OpenShiftControllerManag
149150

150151
func manageOpenShiftControllerManagerClientCA_v311_00_to_latest(client coreclientv1.CoreV1Interface, recorder events.Recorder) (bool, error) {
151152
const apiserverClientCA = "client-ca"
152-
_, caChanged, err := resourceapply.SyncConfigMap(client, recorder, kubeAPIServerNamespaceName, apiserverClientCA, targetNamespaceName, apiserverClientCA, []metav1.OwnerReference{})
153+
_, caChanged, err := resourceapply.SyncConfigMap(client, recorder, util.KubeAPIServerNamespace, apiserverClientCA, util.TargetNamespace, apiserverClientCA, []metav1.OwnerReference{})
153154
if err != nil {
154155
return false, err
155156
}
@@ -167,8 +168,8 @@ func manageOpenShiftControllerManagerConfigMap_v311_00_to_latest(kubeClient kube
167168
// we can embed input hashes on our main configmap to drive rollouts when they change.
168169
inputHashes, err := resourcehash.MultipleObjectHashStringMapForObjectReferences(
169170
kubeClient,
170-
resourcehash.NewObjectRef().ForConfigMap().InNamespace(targetNamespaceName).Named("client-ca"),
171-
resourcehash.NewObjectRef().ForSecret().InNamespace(targetNamespaceName).Named("serving-cert"),
171+
resourcehash.NewObjectRef().ForConfigMap().InNamespace(util.TargetNamespace).Named("client-ca"),
172+
resourcehash.NewObjectRef().ForSecret().InNamespace(util.TargetNamespace).Named("serving-cert"),
172173
)
173174
if err != nil {
174175
return nil, false, err

pkg/util/consts.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package util
22

33
const (
4-
OperatorNamespaceName = "openshift-controller-manager-operator"
4+
KubeAPIServerNamespace = "openshift-kube-apiserver"
5+
UserSpecifiedGlobalConfigNamespace = "openshift-config"
6+
MachineSpecifiedGlobalConfigNamespace = "openshift-config-managed"
7+
TargetNamespace = "openshift-controller-manager"
8+
OperatorNamespace = "openshift-controller-manager-operator"
59
)

0 commit comments

Comments
 (0)