Skip to content

Commit

Permalink
Merge pull request openshift#1764 from openshift-cherrypick-robot/che…
Browse files Browse the repository at this point in the history
…rry-pick-1566-to-release-4.4

Bug 1829645: reconcile relatedObjects and place them in the clusteroperator for CVO
  • Loading branch information
openshift-merge-robot committed Jun 19, 2020
2 parents 2ffa5a0 + 0ca7eed commit b2d3330
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions install/0000_80_machine-config-operator_06_clusteroperator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ status:
versions:
- name: operator
version: "0.0.1-snapshot"
relatedObjects:
- group: ""
name: openshift-machine-config-operator
resource: namespaces
- group: machineconfiguration.openshift.io
name: master
resource: machineconfigpools
- group: machineconfiguration.openshift.io
name: worker
resource: machineconfigpools
- group: machineconfiguration.openshift.io
name: machine-config-controller
resource: controllerconfigs
28 changes: 28 additions & 0 deletions pkg/operator/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
configv1 "github.com/openshift/api/config/v1"
cov1helpers "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -50,6 +51,33 @@ func (optr *Operator) syncVersion() error {
return err
}

// syncRelatedObjects handles reporting the relatedObjects to the clusteroperator
func (optr *Operator) syncRelatedObjects() error {
co, err := optr.fetchClusterOperator()
if err != nil {
return err
}
if co == nil {
return nil
}

coCopy := co.DeepCopy()
// RelatedObjects are consumed by https://github.com/openshift/must-gather
co.Status.RelatedObjects = []configv1.ObjectReference{
{Resource: "namespaces", Name: optr.namespace},
{Group: "machineconfiguration.openshift.io", Resource: "machineconfigpools", Name: "master"},
{Group: "machineconfiguration.openshift.io", Resource: "machineconfigpools", Name: "worker"},
{Group: "machineconfiguration.openshift.io", Resource: "controllerconfigs", Name: "machine-config-controller"},
}

if !equality.Semantic.DeepEqual(coCopy.Status.RelatedObjects, co.Status.RelatedObjects) {
_, err := optr.configClient.ConfigV1().ClusterOperators().UpdateStatus(co)
return err
}

return nil
}

// syncAvailableStatus applies the new condition to the mco's ClusterOperator object.
func (optr *Operator) syncAvailableStatus() error {
co, err := optr.fetchClusterOperator()
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (optr *Operator) syncAll(syncFuncs []syncFunc) error {
return fmt.Errorf("error syncing version: %v", err)
}

if err := optr.syncRelatedObjects(); err != nil {
return fmt.Errorf("error syncing relatedObjects: %v", err)
}

if optr.inClusterBringup && syncErr.err == nil {
glog.Infof("Initialization complete")
optr.inClusterBringup = false
Expand Down

0 comments on commit b2d3330

Please sign in to comment.