Skip to content

Commit

Permalink
Merge pull request #76 from bparees/refs
Browse files Browse the repository at this point in the history
add object refs for must gather dump
  • Loading branch information
openshift-merge-robot authored Feb 25, 2019
2 parents 26ae3ac + 7a69d64 commit 3f79b51
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test: test-unit test-e2e

test-unit:
ifndef JUNITFILE
go test $(GOFLAGS) -race ./...
go test $(GOFLAGS) -race ./pkg/... ./cmd/...
else
ifeq (, $(shell which gotest2junit 2>/dev/null))
$(error gotest2junit not found! Get it by `go get -u github.com/openshift/release/tools/gotest2junit`.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ObserveControllerManagerImagesConfig(genericListers configobserver.Listers,

// now gather the cluster config and turn it into the observed config
observedConfig := map[string]interface{}{}
controllerManagerImagesConfigMap, err := listers.ConfigMapLister.ConfigMaps(util.OperatorNamespaceName).Get("openshift-controller-manager-images")
controllerManagerImagesConfigMap, err := listers.ConfigMapLister.ConfigMaps(util.OperatorNamespace).Get("openshift-controller-manager-images")
if errors.IsNotFound(err) {
glog.V(2).Infof("configmap/openshift-controller-manager-images: not found")
return observedConfig, errs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestObserveClusterConfig(t *testing.T) {
cm: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "openshift-controller-manager-images",
Namespace: util.OperatorNamespaceName,
Namespace: util.OperatorNamespace,
},
Data: map[string]string{
"builderImage": "quay.io/sample/origin-builder:v4.0",
Expand All @@ -50,7 +50,7 @@ func TestObserveClusterConfig(t *testing.T) {
cm: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "openshift-controller-manager-images",
Namespace: util.OperatorNamespaceName,
Namespace: util.OperatorNamespace,
},
Data: map[string]string{
"builderImage": "quay.io/sample/origin-builder:v4.0",
Expand All @@ -70,7 +70,7 @@ func TestObserveClusterConfig(t *testing.T) {
cm: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "openshift-controller-manager-images",
Namespace: util.OperatorNamespaceName,
Namespace: util.OperatorNamespace,
},
Data: map[string]string{
"unknownField": "quay.io/sample/origin-builder:v4.0",
Expand All @@ -84,7 +84,7 @@ func TestObserveClusterConfig(t *testing.T) {
cm: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "shall-not-be-found",
Namespace: util.OperatorNamespaceName,
Namespace: util.OperatorNamespace,
},
Data: map[string]string{
"builderImage": "quay.io/sample/origin-builder:v4.0",
Expand Down
17 changes: 8 additions & 9 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ import (
operatorapiv1 "github.com/openshift/api/operator/v1"
operatorclientv1 "github.com/openshift/client-go/operator/clientset/versioned/typed/operator/v1"
operatorinformersv1 "github.com/openshift/client-go/operator/informers/externalversions/operator/v1"
"github.com/openshift/cluster-openshift-controller-manager-operator/pkg/util"
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/v1helpers"
)

const (
kubeAPIServerNamespaceName = "openshift-kube-apiserver"
targetNamespaceName = "openshift-controller-manager"
workQueueKey = "key"
workloadFailingCondition = "WorkloadFailing"
workQueueKey = "key"
workloadFailingCondition = "WorkloadFailing"
)

type OpenShiftControllerManagerOperator struct {
Expand Down Expand Up @@ -112,7 +111,7 @@ func (c OpenShiftControllerManagerOperator) sync() error {

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

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

func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.ResourceEventHandler {
return cache.ResourceEventHandlerFuncs{
Expand All @@ -187,7 +186,7 @@ func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.Resou
if !ok {
c.queue.Add(workQueueKey)
}
if ns.Name == targetNamespaceName {
if ns.Name == util.TargetNamespace {
c.queue.Add(workQueueKey)
}
},
Expand All @@ -196,7 +195,7 @@ func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.Resou
if !ok {
c.queue.Add(workQueueKey)
}
if ns.Name == targetNamespaceName {
if ns.Name == util.TargetNamespace {
c.queue.Add(workQueueKey)
}
},
Expand All @@ -214,7 +213,7 @@ func (c *OpenShiftControllerManagerOperator) namespaceEventHandler() cache.Resou
return
}
}
if ns.Name == targetNamespaceName {
if ns.Name == util.TargetNamespace {
c.queue.Add(workQueueKey)
}
},
Expand Down
12 changes: 9 additions & 3 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
)

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

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

clusterOperatorStatus := status.NewClusterOperatorStatusController(
"openshift-controller-manager",
[]configv1.ObjectReference{},
[]configv1.ObjectReference{
{Group: "operator.openshift.io", Resource: "openshiftcontrollermanagers", Name: "cluster"},
{Resource: "namespaces", Name: util.UserSpecifiedGlobalConfigNamespace},
{Resource: "namespaces", Name: util.MachineSpecifiedGlobalConfigNamespace},
{Resource: "namespaces", Name: util.OperatorNamespace},
{Resource: "namespaces", Name: util.TargetNamespace},
},
configClient.ConfigV1(),
opClient,
status.NewVersionGetter(),
Expand Down
7 changes: 4 additions & 3 deletions pkg/operator/sync_openshiftcontrollermanager_v311_00.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/openshift/library-go/pkg/operator/v1helpers"

"github.com/openshift/cluster-openshift-controller-manager-operator/pkg/operator/v311_00_assets"
"github.com/openshift/cluster-openshift-controller-manager-operator/pkg/util"
)

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

func manageOpenShiftControllerManagerClientCA_v311_00_to_latest(client coreclientv1.CoreV1Interface, recorder events.Recorder) (bool, error) {
const apiserverClientCA = "client-ca"
_, caChanged, err := resourceapply.SyncConfigMap(client, recorder, kubeAPIServerNamespaceName, apiserverClientCA, targetNamespaceName, apiserverClientCA, []metav1.OwnerReference{})
_, caChanged, err := resourceapply.SyncConfigMap(client, recorder, util.KubeAPIServerNamespace, apiserverClientCA, util.TargetNamespace, apiserverClientCA, []metav1.OwnerReference{})
if err != nil {
return false, err
}
Expand All @@ -167,8 +168,8 @@ func manageOpenShiftControllerManagerConfigMap_v311_00_to_latest(kubeClient kube
// we can embed input hashes on our main configmap to drive rollouts when they change.
inputHashes, err := resourcehash.MultipleObjectHashStringMapForObjectReferences(
kubeClient,
resourcehash.NewObjectRef().ForConfigMap().InNamespace(targetNamespaceName).Named("client-ca"),
resourcehash.NewObjectRef().ForSecret().InNamespace(targetNamespaceName).Named("serving-cert"),
resourcehash.NewObjectRef().ForConfigMap().InNamespace(util.TargetNamespace).Named("client-ca"),
resourcehash.NewObjectRef().ForSecret().InNamespace(util.TargetNamespace).Named("serving-cert"),
)
if err != nil {
return nil, false, err
Expand Down
6 changes: 5 additions & 1 deletion pkg/util/consts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package util

const (
OperatorNamespaceName = "openshift-controller-manager-operator"
KubeAPIServerNamespace = "openshift-kube-apiserver"
UserSpecifiedGlobalConfigNamespace = "openshift-config"
MachineSpecifiedGlobalConfigNamespace = "openshift-config-managed"
TargetNamespace = "openshift-controller-manager"
OperatorNamespace = "openshift-controller-manager-operator"
)

0 comments on commit 3f79b51

Please sign in to comment.