Rename canary flag name from funcN/funcN-1 to newfunction/oldfunction (#1003)
This commit is contained in:
@@ -158,7 +158,7 @@ func (canaryCfgMgr *canaryConfigMgr) processCanaryConfig(ctx *context.Context, c
|
||||
case <-ticker.C:
|
||||
// every weightIncrementDuration, check if failureThreshold has reached.
|
||||
// if yes, rollback.
|
||||
// else, increment the weight of funcN and decrement funcN-1 by `weightIncrement`
|
||||
// else, increment the weight of new function and decrement old function by `weightIncrement`
|
||||
log.Printf("Processing canary config : %s.%s", canaryConfig.Metadata.Name, canaryConfig.Metadata.Namespace)
|
||||
canaryCfgMgr.RollForwardOrBack(canaryConfig, quit, ticker)
|
||||
|
||||
@@ -205,9 +205,9 @@ func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *crd.CanaryC
|
||||
}
|
||||
|
||||
if triggerObj.Spec.FunctionReference.Type == fission.FunctionReferenceTypeFunctionWeights &&
|
||||
triggerObj.Spec.FunctionReference.FunctionWeights[canaryConfig.Spec.FunctionN] != 0 {
|
||||
triggerObj.Spec.FunctionReference.FunctionWeights[canaryConfig.Spec.NewFunction] != 0 {
|
||||
failurePercent, err := canaryCfgMgr.promClient.GetFunctionFailurePercentage(triggerObj.Spec.RelativeURL, triggerObj.Spec.Method,
|
||||
canaryConfig.Spec.FunctionN, canaryConfig.Metadata.Namespace, canaryConfig.Spec.WeightIncrementDuration)
|
||||
canaryConfig.Spec.NewFunction, canaryConfig.Metadata.Namespace, canaryConfig.Spec.WeightIncrementDuration)
|
||||
|
||||
if err != nil {
|
||||
// silently ignore. wait for next window to increment weight
|
||||
@@ -314,8 +314,8 @@ func (canaryCfgMgr *canaryConfigMgr) updateCanaryConfigStatusWithRetries(cfgName
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) rollback(canaryConfig *crd.CanaryConfig, trigger *crd.HTTPTrigger) error {
|
||||
functionWeights := trigger.Spec.FunctionReference.FunctionWeights
|
||||
functionWeights[canaryConfig.Spec.FunctionN] = 0
|
||||
functionWeights[canaryConfig.Spec.FunctionNminus1] = 100
|
||||
functionWeights[canaryConfig.Spec.NewFunction] = 0
|
||||
functionWeights[canaryConfig.Spec.OldFunction] = 100
|
||||
|
||||
err := canaryCfgMgr.updateHttpTriggerWithRetries(trigger.Metadata.Name, trigger.Metadata.Namespace, functionWeights)
|
||||
|
||||
@@ -329,16 +329,16 @@ func (canaryCfgMgr *canaryConfigMgr) rollForward(canaryConfig *crd.CanaryConfig,
|
||||
doneProcessingCanaryConfig := false
|
||||
|
||||
functionWeights := trigger.Spec.FunctionReference.FunctionWeights
|
||||
if functionWeights[canaryConfig.Spec.FunctionN]+canaryConfig.Spec.WeightIncrement >= 100 {
|
||||
if functionWeights[canaryConfig.Spec.NewFunction]+canaryConfig.Spec.WeightIncrement >= 100 {
|
||||
doneProcessingCanaryConfig = true
|
||||
functionWeights[canaryConfig.Spec.FunctionN] = 100
|
||||
functionWeights[canaryConfig.Spec.FunctionNminus1] = 0
|
||||
functionWeights[canaryConfig.Spec.NewFunction] = 100
|
||||
functionWeights[canaryConfig.Spec.OldFunction] = 0
|
||||
} else {
|
||||
functionWeights[canaryConfig.Spec.FunctionN] += canaryConfig.Spec.WeightIncrement
|
||||
if functionWeights[canaryConfig.Spec.FunctionNminus1]-canaryConfig.Spec.WeightIncrement < 0 {
|
||||
functionWeights[canaryConfig.Spec.FunctionNminus1] = 0
|
||||
functionWeights[canaryConfig.Spec.NewFunction] += canaryConfig.Spec.WeightIncrement
|
||||
if functionWeights[canaryConfig.Spec.OldFunction]-canaryConfig.Spec.WeightIncrement < 0 {
|
||||
functionWeights[canaryConfig.Spec.OldFunction] = 0
|
||||
} else {
|
||||
functionWeights[canaryConfig.Spec.FunctionNminus1] -= canaryConfig.Spec.WeightIncrement
|
||||
functionWeights[canaryConfig.Spec.OldFunction] -= canaryConfig.Spec.WeightIncrement
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ desc "Create a route \(HTTP trigger\) the version-1 of the function with weight
|
||||
run "fission route create --name route-fail --method GET --url /fail --function fn1-v6 --weight 100 --function fn1-v7 --weight 0"
|
||||
|
||||
desc "Create a canary config to gradually increment the weight of version-2 by a step of 20 every 1 minute"
|
||||
run "fission canary-config create --name canary-2 --funcN fn1-v7 --funcN-1 fn1-v6 --httptrigger route-fail --increment-step 30 --increment-interval 30s --failure-threshold 10"
|
||||
run "fission canary-config create --name canary-2 --newfunction fn1-v7 --oldfunction fn1-v6 --httptrigger route-fail --increment-step 30 --increment-interval 30s --failure-threshold 10"
|
||||
|
||||
desc "Fire requests to the route"
|
||||
run "ab -n 10000 -c 1 http://$FISSION_ROUTER/fail"
|
||||
run "ab -n 10000 -c 1 http://$FISSION_ROUTER/fail"
|
||||
|
||||
@@ -33,5 +33,5 @@ desc "Start sending requests to the route"
|
||||
run_bg "hey -n 100000 -c 1 http://$FISSION_ROUTER/canary"
|
||||
|
||||
desc "Create a canary config: with an increment of 10 percent, every 1 minute, rolling back if 10% of requests fail"
|
||||
run "fission canary-config create --name canary-1 --funcN func-v2 --funcN-1 func-v1 --httptrigger route-canary --increment-step 10 --increment-interval 30s --failure-threshold 10"
|
||||
run "fission canary-config create --name canary-1 --newfunction func-v2 --oldfunction func-v1 --httptrigger route-canary --increment-step 10 --increment-interval 30s --failure-threshold 10"
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ desc "Start sending requests to the route"
|
||||
run_bg "hey -n 100000 -c 1 http://$FISSION_ROUTER/canary"
|
||||
|
||||
desc "Create a canary config: with an increment of 10 percent, every 1 minute, rolling back if 10% of requests fail"
|
||||
run "fission canary-config create --name canary-1 --funcN func-v2 --funcN-1 func-v1 --httptrigger route-canary --increment-step 10 --increment-interval 30s --failure-threshold 10"
|
||||
run "fission canary-config create --name canary-1 --newfunction func-v2 --oldfunction func-v1 --httptrigger route-canary --increment-step 10 --increment-interval 30s --failure-threshold 10"
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -41,8 +41,8 @@ func canaryConfigCreate(c *cli.Context) error {
|
||||
}
|
||||
|
||||
trigger := c.String("httptrigger")
|
||||
funcN := c.String("funcN")
|
||||
funcNminus1 := c.String("funcN-1")
|
||||
newFunc := c.String("newfunction")
|
||||
oldFunc := c.String("oldfunction")
|
||||
ns := c.String("fnNamespace")
|
||||
incrementStep := c.Int("increment-step")
|
||||
failureThreshold := c.Int("failure-threshold")
|
||||
@@ -69,18 +69,18 @@ func canaryConfigCreate(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// check that the trigger references same functions in the function weights
|
||||
_, ok := htTrigger.Spec.FunctionReference.FunctionWeights[funcN]
|
||||
_, ok := htTrigger.Spec.FunctionReference.FunctionWeights[newFunc]
|
||||
if !ok {
|
||||
log.Fatal(fmt.Sprintf("HTTP Trigger doesn't reference the function %s in Canary Config", funcN))
|
||||
log.Fatal(fmt.Sprintf("HTTP Trigger doesn't reference the function %s in Canary Config", newFunc))
|
||||
}
|
||||
|
||||
_, ok = htTrigger.Spec.FunctionReference.FunctionWeights[funcNminus1]
|
||||
_, ok = htTrigger.Spec.FunctionReference.FunctionWeights[oldFunc]
|
||||
if !ok {
|
||||
log.Fatal(fmt.Sprintf("HTTP Trigger doesn't reference the function %s in Canary Config", funcNminus1))
|
||||
log.Fatal(fmt.Sprintf("HTTP Trigger doesn't reference the function %s in Canary Config", oldFunc))
|
||||
}
|
||||
|
||||
// check that the functions exist in the same namespace
|
||||
fnList := []string{funcN, funcNminus1}
|
||||
fnList := []string{newFunc, oldFunc}
|
||||
err = util.CheckFunctionExistence(client, fnList, ns)
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Sprintf("checkFunctionExistence err : %v", err))
|
||||
@@ -94,8 +94,8 @@ func canaryConfigCreate(c *cli.Context) error {
|
||||
},
|
||||
Spec: fission.CanaryConfigSpec{
|
||||
Trigger: trigger,
|
||||
FunctionN: funcN,
|
||||
FunctionNminus1: funcNminus1,
|
||||
NewFunction: newFunc,
|
||||
OldFunction: oldFunc,
|
||||
WeightIncrement: incrementStep,
|
||||
WeightIncrementDuration: incrementInterval,
|
||||
FailureThreshold: failureThreshold,
|
||||
@@ -133,7 +133,7 @@ func canaryConfigGet(c *cli.Context) error {
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "TRIGGER", "FUNCTION-N", "FUNCTION-N-1", "WEIGHT-INCREMENT", "INTERVAL", "FAILURE-THRESHOLD", "FAILURE-TYPE", "STATUS")
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.FunctionN, canaryCfg.Spec.FunctionNminus1, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Spec.FailureThreshold, canaryCfg.Spec.FailureType, canaryCfg.Status.Status)
|
||||
|
||||
w.Flush()
|
||||
@@ -226,7 +226,7 @@ func canaryConfigList(c *cli.Context) error {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "TRIGGER", "FUNCTION-N", "FUNCTION-N-1", "WEIGHT-INCREMENT", "INTERVAL", "FAILURE-THRESHOLD", "FAILURE-TYPE", "STATUS")
|
||||
for _, canaryCfg := range canaryCfgs {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.FunctionN, canaryCfg.Spec.FunctionNminus1, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Spec.FailureThreshold, canaryCfg.Spec.FailureType, canaryCfg.Status.Status)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -277,13 +277,13 @@ func main() {
|
||||
// canary configs
|
||||
canaryConfigNameFlag := cli.StringFlag{Name: "name", Usage: "Name for the canary config"}
|
||||
triggerNameFlag := cli.StringFlag{Name: "httptrigger", Usage: "Http trigger that this config references"}
|
||||
funcNFlag := cli.StringFlag{Name: "funcN", Usage: "New version of the function"}
|
||||
funcNminus1Flag := cli.StringFlag{Name: "funcN-1", Usage: "Old stable version of the function"}
|
||||
newFunc := cli.StringFlag{Name: "newfunction", Usage: "New version of the function"}
|
||||
oldFunc := cli.StringFlag{Name: "oldfunction", Usage: "Old stable version of the function"}
|
||||
weightIncrementFlag := cli.IntFlag{Name: "increment-step", Value: 20, Usage: "Weight increment step for function"}
|
||||
incrementIntervalFlag := cli.StringFlag{Name: "increment-interval", Value: "2m", Usage: "Weight increment interval, string representation of time.Duration, ex : 1m, 2h, 2d"}
|
||||
failureThresholdFlag := cli.IntFlag{Name: "failure-threshold", Value: 10, Usage: "Threshold in percentage beyond which the new version of the function is considered unstable"}
|
||||
canarySubCommands := []cli.Command{
|
||||
{Name: "create", Usage: "Create a canary config", Flags: []cli.Flag{canaryConfigNameFlag, triggerNameFlag, funcNFlag, funcNminus1Flag, fnNamespaceFlag, weightIncrementFlag, incrementIntervalFlag, failureThresholdFlag}, Action: canaryConfigCreate},
|
||||
{Name: "create", Usage: "Create a canary config", Flags: []cli.Flag{canaryConfigNameFlag, triggerNameFlag, newFunc, oldFunc, fnNamespaceFlag, weightIncrementFlag, incrementIntervalFlag, failureThresholdFlag}, Action: canaryConfigCreate},
|
||||
{Name: "get", Usage: "View parameters in a canary config", Flags: []cli.Flag{canaryConfigNameFlag, canaryNamespaceFlag}, Action: canaryConfigGet},
|
||||
{Name: "update", Usage: "Update parameters of a canary config", Flags: []cli.Flag{canaryConfigNameFlag, canaryNamespaceFlag, incrementIntervalFlag, weightIncrementFlag, failureThresholdFlag}, Action: canaryConfigUpdate},
|
||||
{Name: "delete", Usage: "Delete a canary config", Flags: []cli.Flag{canaryConfigNameFlag, canaryNamespaceFlag}, Action: canaryConfigDelete},
|
||||
|
||||
@@ -338,8 +338,8 @@ type (
|
||||
// Canary Config Spec
|
||||
CanaryConfigSpec struct {
|
||||
Trigger string `json:"trigger"`
|
||||
FunctionN string `json:"funcn"`
|
||||
FunctionNminus1 string `json:"funcn-1"`
|
||||
NewFunction string `json:"newfunction"`
|
||||
OldFunction string `json:"oldfunction"`
|
||||
WeightIncrement int `json:"weightincrement"`
|
||||
WeightIncrementDuration string `json:"duration"`
|
||||
FailureThreshold int `json:"failurethreshold"`
|
||||
|
||||
@@ -32,7 +32,7 @@ success_scenario() {
|
||||
fission route create --name route-success --method GET --url /success --function fn-v1 --weight 100 --function fn-v2 --weight 0
|
||||
|
||||
log "Create a canary config to gradually increment the weight of version-2 by a step of 50 every 1m"
|
||||
fission canary-config create --name canary-1 --funcN fn-v2 --funcN-1 fn-v1 --httptrigger route-success --increment-step 50 --increment-interval 1m --failure-threshold 10
|
||||
fission canary-config create --name canary-1 --newfunction fn-v2 --oldfunction fn-v1 --httptrigger route-success --increment-step 50 --increment-interval 1m --failure-threshold 10
|
||||
|
||||
sleep 60
|
||||
|
||||
@@ -65,7 +65,7 @@ failure_scenario() {
|
||||
sleep 5
|
||||
|
||||
log "Create a canary config to gradually increment the weight of version-2 by a step of 50 every 1m"
|
||||
fission canary-config create --name canary-2 --funcN fn-v3 --funcN-1 fn-v1 --httptrigger route-fail --increment-step 50 --increment-interval 1m --failure-threshold 10
|
||||
fission canary-config create --name canary-2 --newfunction fn-v3 --oldfunction fn-v1 --httptrigger route-fail --increment-step 50 --increment-interval 1m --failure-threshold 10
|
||||
|
||||
sleep 60
|
||||
|
||||
@@ -97,4 +97,4 @@ main() {
|
||||
cleanup
|
||||
}
|
||||
|
||||
main
|
||||
main
|
||||
|
||||
Reference in New Issue
Block a user