fix: max weight for steps fixed

This commit is contained in:
Robert Kwolek 2020-08-25 10:34:59 +02:00
parent ab80bcde44
commit 0ccf97bec1
2 changed files with 13 additions and 5 deletions

View File

@ -29,7 +29,6 @@ canary:
analysis: analysis:
promotion: promotion:
fullWeight: 1000 fullWeight: 1000
maxWeight: 500
stepWeights: [1, 10, 100, 800] stepWeights: [1, 10, 100, 800]
``` ```
This configuration performs analysis starting from 1, going through `stepWeights` values till 800. This configuration performs analysis starting from 1, going through `stepWeights` values till 800.

View File

@ -14,6 +14,18 @@ import (
"github.com/weaveworks/flagger/pkg/router" "github.com/weaveworks/flagger/pkg/router"
) )
func (c *Controller) maxWeight(canary *flaggerv1.Canary) int {
var stepWeightsLen = len(canary.GetAnalysis().StepWeights)
if stepWeightsLen > 0 {
return canary.GetAnalysis().StepWeights[stepWeightsLen-1]
}
if cd.GetAnalysis().MaxWeight > 0 {
maxWeight = cd.GetAnalysis().MaxWeight
}
// set max weight default value to 100%
return 100
}
func (c *Controller) fullWeight(canary *flaggerv1.Canary) int { func (c *Controller) fullWeight(canary *flaggerv1.Canary) int {
if canary.GetAnalysis().FullWeight > 0 { if canary.GetAnalysis().FullWeight > 0 {
return canary.GetAnalysis().FullWeight return canary.GetAnalysis().FullWeight
@ -200,10 +212,7 @@ func (c *Controller) advanceCanary(name string, namespace string) {
return return
} }
maxWeight := c.fullWeight(cd) maxWeight := c.maxWeight(cd)
if cd.GetAnalysis().MaxWeight > 0 {
maxWeight = cd.GetAnalysis().MaxWeight
}
// check primary status // check primary status
if !cd.SkipAnalysis() { if !cd.SkipAnalysis() {