Skip to content

Commit

Permalink
deploy: added deployer_controller_failed_rollouts metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik committed Jun 23, 2017
1 parent 5a8dfdc commit 1db906c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/deploy/controller/deployer/deployer_controller.go
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package deployment
package deployer

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/controller/deployer/deployer_controller_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package deployment
package deployer

import (
"fmt"
Expand Down
4 changes: 3 additions & 1 deletion pkg/deploy/controller/deployer/factory.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package deployment
package deployer

import (
"fmt"
Expand Down Expand Up @@ -105,6 +105,7 @@ func (c *DeploymentController) addReplicationController(obj interface{}) {
return
}

updateFailedRolloutsMetrics(nil, rc)
c.enqueueReplicationController(rc)
}

Expand All @@ -121,6 +122,7 @@ func (c *DeploymentController) updateReplicationController(old, cur interface{})
return
}

updateFailedRolloutsMetrics(oldRC, curRC)
c.enqueueReplicationController(curRC)
}

Expand Down
35 changes: 35 additions & 0 deletions pkg/deploy/controller/deployer/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package deployer

import (
deployutil "github.com/openshift/origin/pkg/deploy/util"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/kubernetes/pkg/api/v1"
)

// DeployerControllerSubsystem is how this controller is represented in
// prometheus metrics.
const DeployerControllerSubsystem = "deployer_controller"

var (
failedRolloutsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: DeployerControllerSubsystem,
Name: "failed_rollouts",
Help: "Counts total failed rollouts",
},
[]string{},
)
)

func init() {
prometheus.MustRegister(failedRolloutsCounter)
}

func updateFailedRolloutsMetrics(oldRC, newRC *v1.ReplicationController) {
if oldRC != nil && deployutil.IsFailedDeployment(oldRC) {
return
}
if deployutil.IsFailedDeployment(newRC) {
failedRolloutsCounter.WithLabelValues().Inc()
}
}

0 comments on commit 1db906c

Please sign in to comment.