Skip to content

Commit

Permalink
Merge pull request #45 from derekwaynecarr/fixup-cluster-operator
Browse files Browse the repository at this point in the history
Fixup cluster operator
  • Loading branch information
openshift-merge-robot authored Feb 18, 2019
2 parents ae47788 + 769d398 commit 80f40c5
Show file tree
Hide file tree
Showing 215 changed files with 14,687 additions and 3,653 deletions.
12 changes: 6 additions & 6 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ required = [
name = "sigs.k8s.io/controller-runtime"
version = "v0.1.4"

[[override]]
name = "github.com/openshift/api"
branch = "master"

[[override]]
name = "github.com/openshift/client-go"
branch = "master"

[[override]]
name = "github.com/openshift/cluster-version-operator"
branch = "master"

[prune]
go-tests = true
non-go = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: config.openshift.io/v1
kind: ClusterOperator
metadata:
name: cluster-autoscaler
spec: {}
17 changes: 15 additions & 2 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package operator

import (
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/cluster-autoscaler-operator/pkg/apis"
"github.com/openshift/cluster-autoscaler-operator/pkg/controller/clusterautoscaler"
"github.com/openshift/cluster-autoscaler-operator/pkg/controller/machineautoscaler"
Expand All @@ -10,7 +11,7 @@ import (
)

// OperatorName is the name of this operator.
const OperatorName = "cluster-autoscaler-operator"
const OperatorName = "cluster-autoscaler"

// Operator represents an instance of the cluster-autoscaler-operator.
type Operator struct {
Expand All @@ -30,7 +31,19 @@ func New(cfg *Config) (*Operator, error) {
return nil, err
}

operator.status, err = NewStatusReporter(clientConfig)
// track set of related namespaces for openshift-must-gather diagnostics
relatedNamespaces := map[string]string{}
relatedNamespaces[cfg.WatchNamespace] = ""
relatedNamespaces[cfg.LeaderElectionNamespace] = ""
relatedNamespaces[cfg.ClusterAutoscalerNamespace] = ""
relatedObjects := []configv1.ObjectReference{}
for k := range relatedNamespaces {
relatedObjects = append(relatedObjects, configv1.ObjectReference{
Resource: "namespaces",
Name: k,
})
}
operator.status, err = NewStatusReporter(clientConfig, relatedObjects)
if err != nil {
return nil, err
}
Expand Down
24 changes: 17 additions & 7 deletions pkg/operator/status.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package operator

import (
"github.com/golang/glog"
"fmt"
"time"

"github.com/golang/glog"
configv1 "github.com/openshift/api/config/v1"
osconfig "github.com/openshift/client-go/config/clientset/versioned"
"github.com/openshift/cluster-autoscaler-operator/pkg/version"
Expand All @@ -24,13 +25,16 @@ const (
// StatusReporter reports the status of the operator to the OpenShift
// cluster-version-operator via ClusterOperator resource status.
type StatusReporter struct {
client *osconfig.Clientset
client *osconfig.Clientset
relatedObjects []configv1.ObjectReference
}

// NewStatusReporter returns a new StatusReporter instance.
func NewStatusReporter(cfg *rest.Config) (*StatusReporter, error) {
func NewStatusReporter(cfg *rest.Config, relatedObjects []configv1.ObjectReference) (*StatusReporter, error) {
var err error
reporter := &StatusReporter{}
reporter := &StatusReporter{
relatedObjects: relatedObjects,
}

// Create a client for OpenShift config objects.
reporter.client, err = osconfig.NewForConfig(cfg)
Expand Down Expand Up @@ -64,7 +68,13 @@ func (r *StatusReporter) GetOrCreateClusterOperator() (*configv1.ClusterOperator
// resource's status.
func (r *StatusReporter) ApplyConditions(conds []configv1.ClusterOperatorStatusCondition) error {
status := configv1.ClusterOperatorStatus{
Version: version.Raw,
Versions: []configv1.OperandVersion{
{
Name: "cluster-autoscaler",
Version: version.Raw,
},
},
RelatedObjects: r.relatedObjects,
}

for _, c := range conds {
Expand Down Expand Up @@ -143,7 +153,7 @@ func (r *StatusReporter) Report(stopCh <-chan struct{}) error {
pollFunc := func() (bool, error) {
ok, err := r.CheckMachineAPI()
if err != nil {
r.Fail(ReasonMissingDependency, "error checking machine-api-operator status")
r.Fail(ReasonMissingDependency, fmt.Sprintf("error checking machine-api operator status %v", err))
return false, nil
}

Expand All @@ -152,7 +162,7 @@ func (r *StatusReporter) Report(stopCh <-chan struct{}) error {
return true, nil
}

r.Fail(ReasonMissingDependency, "machine-api-operator not ready")
r.Fail(ReasonMissingDependency, "machine-api operator not ready")
return false, nil
}

Expand Down
28 changes: 28 additions & 0 deletions vendor/github.com/openshift/api/annotations/annotations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80f40c5

Please sign in to comment.