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:
promotion:
fullWeight: 1000
maxWeight: 500
stepWeights: [1, 10, 100, 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"
)
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 {
if canary.GetAnalysis().FullWeight > 0 {
return canary.GetAnalysis().FullWeight
@ -200,10 +212,7 @@ func (c *Controller) advanceCanary(name string, namespace string) {
return
}
maxWeight := c.fullWeight(cd)
if cd.GetAnalysis().MaxWeight > 0 {
maxWeight = cd.GetAnalysis().MaxWeight
}
maxWeight := c.maxWeight(cd)
// check primary status
if !cd.SkipAnalysis() {