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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions cmd/openshift-tests/openshift-tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/openshift/library-go/pkg/serviceability"
"github.com/openshift/origin/pkg/monitor"
"github.com/openshift/origin/pkg/monitor/resourcewatch/cmd"
testginkgo "github.com/openshift/origin/pkg/test/ginkgo"
exutil "github.com/openshift/origin/test/extended/util"
)
Expand Down Expand Up @@ -46,6 +47,7 @@ func main() {
newRunUpgradeCommand(),
newRunTestCommand(),
newRunMonitorCommand(),
cmd.NewRunResourceWatchCommand(),
)

pflag.CommandLine = pflag.NewFlagSet("empty", pflag.ExitOnError)
Expand Down
117 changes: 108 additions & 9 deletions glide.lock

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

4 changes: 4 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ import:
- package: github.com/opencontainers/runc
version: v1.0.0-rc9

# required by openshift-tests resource watch
- package: gopkg.in/src-d/go-git.v4
version: v4.13.1

# required by opencontainers
- package: github.com/sirupsen/logrus
version: 839c75faf7f98a33d445d181f3018b5c3409a45e
Expand Down
20 changes: 20 additions & 0 deletions pkg/monitor/resourcewatch/cmd/resourcewatch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/openshift/library-go/pkg/controller/controllercmd"

"github.com/openshift/origin/pkg/monitor/resourcewatch/operator"
"github.com/openshift/origin/pkg/version"
)

func NewRunResourceWatchCommand() *cobra.Command {
cmd := controllercmd.
NewControllerCommandConfig("run-resourcewatch", version.Get(), operator.RunOperator).
NewCommand()
cmd.Use = "run-resourcewatch"
cmd.Short = "Run watching resource changes"

return cmd
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package clusteroperatormetric

import (
"context"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/legacyregistry"

configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
"github.com/openshift/library-go/pkg/controller/factory"
"github.com/openshift/library-go/pkg/operator/events"
)

var clusterOperatorStateMetric *metrics.GaugeVec

func init() {
clusterOperatorStateMetric = metrics.NewGaugeVec(
&metrics.GaugeOpts{
Name: "openshift_ci_monitor_operator_cluster_operator_status",
Help: "A metric that tracks individual cluster operator status.",
},
[]string{"name", "condition", "status"},
)

legacyregistry.MustRegister(clusterOperatorStateMetric)
}

type ClusterOperatorMetricController struct {
clusterOperatorClient configv1client.ClusterOperatorsGetter
}

func NewClusterOperatorMetricController(clusterOperatorInformer cache.SharedInformer, clusterOperatorGetter configv1client.ClusterOperatorsGetter, recorder events.Recorder) factory.Controller {
c := &ClusterOperatorMetricController{
clusterOperatorClient: clusterOperatorGetter,
}
return factory.New().WithInformers(clusterOperatorInformer).WithSync(c.sync).ResyncEvery(1*time.Minute).ToController("ClusterOperatorMetricController", recorder.WithComponentSuffix("cluster-operator-metric"))
}

func (c *ClusterOperatorMetricController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
clusterOperators, err := c.clusterOperatorClient.ClusterOperators().List(metav1.ListOptions{})
if err != nil {
return err
}
for _, operator := range clusterOperators.Items {
for _, condition := range operator.Status.Conditions {
clusterOperatorStateMetric.WithLabelValues(operator.Name, string(condition.Type), string(condition.Status)).Set(float64(condition.LastTransitionTime.Unix()))
}
}
return nil
}
Loading