Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix canary status prom metric #121

Merged
merged 2 commits into from
Mar 26, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Adds support for AWS App Mesh EKS
#### Fixes

- Copy pod labels from canary to primary [#105](https://github.com/weaveworks/flagger/pull/105)
- Fix canary status Prometheus metric [#121](https://github.com/weaveworks/flagger/pull/121)

## 0.9.0 (2019-03-11)

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func (cr *CanaryRecorder) SetTotal(namespace string, total int) {
}

// SetStatus sets the last known canary analysis status
func (cr *CanaryRecorder) SetStatus(cd *flaggerv1.Canary) {
func (cr *CanaryRecorder) SetStatus(cd *flaggerv1.Canary, phase flaggerv1.CanaryPhase) {
status := 1
switch cd.Status.Phase {
switch phase {
case flaggerv1.CanaryProgressing:
status = 0
case flaggerv1.CanaryFailed:
Expand Down
14 changes: 7 additions & 7 deletions pkg/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (c *Controller) advanceCanary(name string, namespace string, skipLivenessCh
return
}

c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, flaggerv1.CanaryFailed)
return
}

Expand Down Expand Up @@ -312,7 +312,7 @@ func (c *Controller) advanceCanary(name string, namespace string, skipLivenessCh
c.recordEventWarningf(cd, "%v", err)
return
}
c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, flaggerv1.CanarySucceeded)
c.sendNotification(cd, "Canary analysis completed successfully, promotion finished.",
false, false)
return
Expand Down Expand Up @@ -378,7 +378,7 @@ func (c *Controller) advanceCanary(name string, namespace string, skipLivenessCh
c.recordEventWarningf(cd, "%v", err)
return
}
c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, flaggerv1.CanarySucceeded)
c.sendNotification(cd, "Canary analysis completed successfully, promotion finished.",
false, false)
}
Expand Down Expand Up @@ -419,7 +419,7 @@ func (c *Controller) shouldSkipAnalysis(cd *flaggerv1.Canary, meshRouter router.
}

// notify
c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, flaggerv1.CanarySucceeded)
c.recordEventInfof(cd, "Promotion completed! Canary analysis was skipped for %s.%s",
cd.Spec.TargetRef.Name, cd.Namespace)
c.sendNotification(cd, "Canary analysis was skipped, promotion finished.",
Expand All @@ -429,7 +429,7 @@ func (c *Controller) shouldSkipAnalysis(cd *flaggerv1.Canary, meshRouter router.
}

func (c *Controller) checkCanaryStatus(cd *flaggerv1.Canary, shouldAdvance bool) bool {
c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, cd.Status.Phase)
if cd.Status.Phase == flaggerv1.CanaryProgressing {
return true
}
Expand All @@ -439,7 +439,7 @@ func (c *Controller) checkCanaryStatus(cd *flaggerv1.Canary, shouldAdvance bool)
c.logger.With("canary", fmt.Sprintf("%s.%s", cd.Name, cd.Namespace)).Errorf("%v", err)
return false
}
c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, flaggerv1.CanaryInitialized)
c.recordEventInfof(cd, "Initialization done! %s.%s", cd.Name, cd.Namespace)
c.sendNotification(cd, "New deployment detected, initialization completed.",
true, false)
Expand All @@ -458,7 +458,7 @@ func (c *Controller) checkCanaryStatus(cd *flaggerv1.Canary, shouldAdvance bool)
c.logger.With("canary", fmt.Sprintf("%s.%s", cd.Name, cd.Namespace)).Errorf("%v", err)
return false
}
c.recorder.SetStatus(cd)
c.recorder.SetStatus(cd, flaggerv1.CanaryProgressing)
return false
}
return false
Expand Down