Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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