mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
Update CRD status for canary revision and rollout stage persistence
This commit is contained in:
@@ -59,8 +59,8 @@ type Metric struct {
|
||||
|
||||
// RolloutStatus is the status for a Rollout resource
|
||||
type RolloutStatus struct {
|
||||
State string `json:"state"`
|
||||
CanaryWeight int32 `json:"canary_weight"`
|
||||
State string `json:"state"`
|
||||
CanaryRevision string `json:"canaryRevision"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
@@ -104,7 +104,7 @@ func (c *Controller) advanceDeploymentRollout(name string, namespace string) {
|
||||
}
|
||||
|
||||
// final stage: mark rollout as finished and scale canary to zero replicas
|
||||
c.checkRolloutStatus(r, "finished")
|
||||
c.updateRolloutStatus(r, "finished")
|
||||
c.recordEventInfof(r, "%s.%s promotion complete! Scaling down %s.%s",
|
||||
r.Name, r.Namespace, canary.GetName(), canary.Namespace)
|
||||
c.scaleToZeroCanary(r)
|
||||
@@ -126,9 +126,11 @@ func (c *Controller) checkRolloutStatus(r *rolloutv1.Rollout, canaryVersion stri
|
||||
if val, ok := r.Annotations[revisionAnnotation]; !ok {
|
||||
r.Annotations[revisionAnnotation] = canaryVersion
|
||||
r.Annotations[statusAnnotation] = "running"
|
||||
r.Status.State = "running"
|
||||
r.Status.CanaryRevision = canaryVersion
|
||||
r, err = c.rolloutClient.AppsV1beta1().Rollouts(r.Namespace).Update(r)
|
||||
if err != nil {
|
||||
c.recordEventErrorf(r, "Rollout %s.%s annotations update failed: %v", r.Name, r.Namespace, err)
|
||||
c.recordEventErrorf(r, "Rollout %s.%s status update failed: %v", r.Name, r.Namespace, err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -139,9 +141,11 @@ func (c *Controller) checkRolloutStatus(r *rolloutv1.Rollout, canaryVersion stri
|
||||
if val != canaryVersion {
|
||||
r.Annotations[revisionAnnotation] = canaryVersion
|
||||
r.Annotations[statusAnnotation] = "running"
|
||||
r.Status.State = "running"
|
||||
r.Status.CanaryRevision = canaryVersion
|
||||
r, err = c.rolloutClient.AppsV1beta1().Rollouts(r.Namespace).Update(r)
|
||||
if err != nil {
|
||||
c.recordEventErrorf(r, "Rollout %s.%s annotations update failed: %v", r.Name, r.Namespace, err)
|
||||
c.recordEventErrorf(r, "Rollout %s.%s status update failed: %v", r.Name, r.Namespace, err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -152,7 +156,8 @@ func (c *Controller) checkRolloutStatus(r *rolloutv1.Rollout, canaryVersion stri
|
||||
|
||||
func (c *Controller) updateRolloutStatus(r *rolloutv1.Rollout, status string) bool {
|
||||
var err error
|
||||
r.Annotations[statusAnnotation] = "running"
|
||||
r.Annotations[statusAnnotation] = status
|
||||
r.Status.State = status
|
||||
r, err = c.rolloutClient.AppsV1beta1().Rollouts(r.Namespace).Update(r)
|
||||
if err != nil {
|
||||
c.recordEventErrorf(r, "Rollout %s.%s status update failed: %v", r.Name, r.Namespace, err)
|
||||
|
||||
@@ -104,7 +104,7 @@ func (c *Controller) getDeploymentCounter(name string, namespace string, metric
|
||||
// istio_request_duration_seconds_bucket
|
||||
func (c *Controller) GetDeploymentHistogram(name string, namespace string, metric string, interval string) (time.Duration, error) {
|
||||
var rate *float64
|
||||
querySt := url.QueryEscape(`histogram_quantile(0.99, sum(irate(` +
|
||||
querySt := url.QueryEscape(`histogram_quantile(0.99, sum(rate(` +
|
||||
metric + `{reporter="destination",destination_workload=~"` +
|
||||
name + `", destination_workload_namespace=~"` +
|
||||
namespace + `"}[` +
|
||||
|
||||
Reference in New Issue
Block a user