Applying canary rollout update 04/11204/1
authorYouhwan Seol <yh.seol@samsung.com>
Tue, 21 Feb 2023 05:31:24 +0000 (14:31 +0900)
committerYouhwan Seol <yh.seol@samsung.com>
Wed, 24 May 2023 09:34:31 +0000 (18:34 +0900)
Change-Id: I482f39c9dc47bbc0f01477f68f20cc5cf506d570
Signed-off-by: Youhwan Seol <yh.seol@samsung.com>
pkg/api/v1/deployment/deployment.go
pkg/controller/v1/adapter/controller.go
pkg/controller/v1/adapter/utils.go

index 94d9ac2..93df005 100644 (file)
@@ -105,7 +105,9 @@ func (Executor) Update(c *gin.Context) {
                return
        }
 
-       _, err := ipsAdapter.Update(name, version)
+       canaryTrafficRatio := c.Query("canary")
+
+       _, err := ipsAdapter.Update(name, version, canaryTrafficRatio)
        if err != nil {
                utils.WriteError(c.Writer, err)
                return
index 0587c8a..2e34cdf 100644 (file)
@@ -31,7 +31,7 @@ import (
 type Command interface {
        Deploy(name string, version string) (string, error)
        Delete(name string) error
-       Update(name string, version string) (string, error)
+       Update(name string, version string, canaryTrafficRatio string) (string, error)
 }
 
 type Executor struct {
@@ -102,7 +102,7 @@ func (Executor) Delete(name string) (err error) {
        return
 }
 
-func (Executor) Update(name string, version string) (revision string, err error) {
+func (Executor) Update(name string, version string, canaryTrafficRatio string) (revision string, err error) {
        logger.Logging(logger.DEBUG, "IN")
        defer logger.Logging(logger.DEBUG, "OUT")
 
@@ -118,6 +118,8 @@ func (Executor) Update(name string, version string) (revision string, err error)
                return
        }
 
+       setCanaryTrafficRatio(&values, canaryTrafficRatio)
+
        ifsv, err := kserveClient.Get(name)
        if err != nil {
                return
index 52605c6..63799c6 100644 (file)
@@ -22,6 +22,7 @@ package adapter
 import (
        "os"
        "path/filepath"
+       "strconv"
 
        "gopkg.in/yaml.v1"
 
@@ -75,3 +76,14 @@ func getValuesFilePath(root string) (path string, err error) {
        path = filepath.Join(path, "values.yaml")
        return
 }
+
+func setCanaryTrafficRatio(values *types.Values, ratio string) {
+       logger.Logging(logger.DEBUG, "IN")
+       defer logger.Logging(logger.DEBUG, "OUT")
+
+       trafficRatio, err := strconv.Atoi(ratio)
+       if err != nil {
+               trafficRatio = -1
+       }
+       values.CanaryTrafficPercent = int64(trafficRatio)
+}