From 80587588cc24fadba2d9f713bfc077e27452a890 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 28 Oct 2024 12:04:28 +0100 Subject: [PATCH 1/3] Fix incorrect conversion between int types (#3205) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/function/scale_workload.go | 4 +-- pkg/function/scale_workload_test.go | 46 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 pkg/function/scale_workload_test.go diff --git a/pkg/function/scale_workload.go b/pkg/function/scale_workload.go index 419c056786..5acae60a01 100644 --- a/pkg/function/scale_workload.go +++ b/pkg/function/scale_workload.go @@ -167,8 +167,8 @@ func (s *scaleWorkloadFunc) setArgs(tp param.TemplateParams, args map[string]int case int64: replicas = int32(val) case string: - var v int - if v, err = strconv.Atoi(val); err != nil { + v, err := strconv.ParseInt(val, 10, 32) + if err != nil { return errkit.Wrap(err, fmt.Sprintf("Cannot convert %s to int", val)) } replicas = int32(v) diff --git a/pkg/function/scale_workload_test.go b/pkg/function/scale_workload_test.go new file mode 100644 index 0000000000..2b74d0b64c --- /dev/null +++ b/pkg/function/scale_workload_test.go @@ -0,0 +1,46 @@ +package function + +import ( + "gopkg.in/check.v1" + + "github.com/kanisterio/kanister/pkg/param" +) + +type ScaleWorkloadSuite struct{} + +var _ = check.Suite(&ScaleWorkloadSuite{}) + +func (s *ScaleWorkloadSuite) TestSetArgs(c *check.C) { + stsParams := ¶m.StatefulSetParams{} + for _, tc := range []struct { + replicas interface{} + expectedReplicas int32 + }{ + { + replicas: 4, + expectedReplicas: 4, + }, + { + replicas: 234324, + expectedReplicas: 234324, + }, + { + replicas: 234324, + expectedReplicas: 234324, + }, + { + replicas: 2147483647, + expectedReplicas: 2147483647, // 2147483647 is the maximum value int32 can hold + }, + } { + s := scaleWorkloadFunc{} + err := s.setArgs(param.TemplateParams{ + StatefulSet: stsParams, + }, map[string]interface{}{ + "replicas": tc.replicas, + }) + + c.Assert(err, check.IsNil) + c.Assert(s.replicas, check.Equals, tc.expectedReplicas) + } +} From c1a82aa713a3418b9206b0549fbef2a35ae3155e Mon Sep 17 00:00:00 2001 From: Tom Manville Date: Mon, 28 Oct 2024 09:09:28 -0700 Subject: [PATCH 2/3] Fix TestParallelStdout: Wait for process to terminate (#3200) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/kanx/kanx_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/kanx/kanx_test.go b/pkg/kanx/kanx_test.go index f4d4604f49..559e80fa49 100644 --- a/pkg/kanx/kanx_test.go +++ b/pkg/kanx/kanx_test.go @@ -12,6 +12,8 @@ import ( "google.golang.org/grpc" . "gopkg.in/check.v1" + + "github.com/kanisterio/kanister/pkg/poll" ) // Hook up gocheck into the "go test" runner. @@ -257,9 +259,13 @@ func (s *KanXSuite) TestParallelStdout(c *C) { err = sp.cmd.Process.Kill() c.Assert(err, IsNil) - ps, err = ListProcesses(ctx, addr) - c.Assert(err, IsNil) - c.Assert(ps, HasLen, 1) + _ = poll.Wait(ctx, func(context.Context) (bool, error) { + ps, err = ListProcesses(ctx, addr) + c.Assert(err, IsNil) + c.Assert(ps, HasLen, 1) + return ps[0].GetState() != ProcessState_PROCESS_STATE_RUNNING, nil + }) + c.Assert(ps[0].GetPid(), Equals, p.GetPid()) c.Assert(ps[0].GetState(), Equals, ProcessState_PROCESS_STATE_FAILED) c.Assert(ps[0].GetExitErr(), Equals, "signal: killed") From 1708d6cb57d329cca1b932a5e4fa9c9afacfe1d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:22:02 -0700 Subject: [PATCH 3/3] deps(go): bump the k8s group with 7 updates (#3207) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 16 ++++++++-------- go.sum | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index d66d629333..ee2f7f3eeb 100644 --- a/go.mod +++ b/go.mod @@ -55,13 +55,13 @@ require ( gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 //pinned k8s.io to v0.29.x tag - k8s.io/api v0.29.9 - k8s.io/apiextensions-apiserver v0.29.9 - k8s.io/apimachinery v0.29.9 - k8s.io/cli-runtime v0.29.9 - k8s.io/client-go v0.29.9 - k8s.io/code-generator v0.29.9 - k8s.io/kubectl v0.29.9 + k8s.io/api v0.29.10 + k8s.io/apiextensions-apiserver v0.29.10 + k8s.io/apimachinery v0.29.10 + k8s.io/cli-runtime v0.29.10 + k8s.io/client-go v0.29.10 + k8s.io/code-generator v0.29.10 + k8s.io/kubectl v0.29.10 sigs.k8s.io/controller-runtime v0.16.6 sigs.k8s.io/yaml v1.3.0 @@ -224,7 +224,7 @@ require ( gopkg.in/kothar/go-backblaze.v0 v0.0.0-20210124194846-35409b867216 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/component-base v0.29.9 // indirect + k8s.io/component-base v0.29.10 // indirect k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 diff --git a/go.sum b/go.sum index 3d789ef579..fb685a524e 100644 --- a/go.sum +++ b/go.sum @@ -834,23 +834,23 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw= -k8s.io/api v0.29.9 h1:FwdflpNsfMUYUOblMZNWJ4K/q0OSL5A4jGa0iOgcJco= -k8s.io/api v0.29.9/go.mod h1:fNhmzRfKaSEHCmczA/jRx6CiDKhYOnFLJBERMJAXEk8= -k8s.io/apiextensions-apiserver v0.29.9 h1:EB6RK06kFJjbzBwU1YiVznxrcgBE0hhDWt6EQQIcOy4= -k8s.io/apiextensions-apiserver v0.29.9/go.mod h1:jcaHG6R/bB1iU6XzC1DMhB1x2ktTJLt2KKpg6B65Z2c= +k8s.io/api v0.29.10 h1:Fao3HOxccbGRC1HZtXD+Y41xJhP0tEToVo5W7EEUBm0= +k8s.io/api v0.29.10/go.mod h1:rF0sRh64w1hMNAVGh4YYniSxODyHye3GLmymAbWBDvY= +k8s.io/apiextensions-apiserver v0.29.10 h1:2k2AHrWgs4S+07HrOjEdcyrQ/UqYlvBi6uon1fox1KE= +k8s.io/apiextensions-apiserver v0.29.10/go.mod h1:3rrJC52bW5frHf10N3JvaDpl++hgrzD9Gs6IZpKWMoc= k8s.io/apimachinery v0.19.0/go.mod h1:DnPGDnARWFvYa3pMHgSxtbZb7gpzzAZ1pTfaUNDVlmA= -k8s.io/apimachinery v0.29.9 h1:YZ8HUid1TzQVz94cnNlsQjLdH0VoAhWSqz7t0q6B12A= -k8s.io/apimachinery v0.29.9/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= -k8s.io/cli-runtime v0.29.9 h1:rryHH2SZtZePv0gj9RM5ftXYcK8v2jbMLOzbORnzzw4= -k8s.io/cli-runtime v0.29.9/go.mod h1:IHgU0jdyAOcrfkpvaDXZRqPe+RJYlUgbufl88Z6EUyo= +k8s.io/apimachinery v0.29.10 h1:57OLNqOJUgp5KlRRY3JOBFOTTa5Rt/LVkmKiiN2cvaQ= +k8s.io/apimachinery v0.29.10/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= +k8s.io/cli-runtime v0.29.10 h1:iX8bo6jmxvmoq046YX/Ry+s3Vc21sfxmYzjKLfEaP6M= +k8s.io/cli-runtime v0.29.10/go.mod h1:sGE4CX6FM600SEX8h/tPS0WGFYkTH+W5oU9eyp5Xtpc= k8s.io/client-go v0.19.0/go.mod h1:H9E/VT95blcFQnlyShFgnFT9ZnJOAceiUHM3MlRC+mU= -k8s.io/client-go v0.29.9 h1:4f/Wz6li3rEyIPFj32XAQMtOGMM1tg7KQi1oeS6ibPg= -k8s.io/client-go v0.29.9/go.mod h1:2N1drQEZ5yiYrWVaE2Un8JiISUhl47D8pyZlYLszke4= +k8s.io/client-go v0.29.10 h1:hPmG1pmKslRhmCIzVd90sA58B0sJwNwduNgXFWsFqhI= +k8s.io/client-go v0.29.10/go.mod h1:gnMCQiRXGL9K0VtlW8gTkhzptGrHm2BJ4qBbujNemc4= k8s.io/code-generator v0.19.0/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk= -k8s.io/code-generator v0.29.9 h1:57k53ZbD4W4NFlTV2iH7nKfmoLP4Q6yW2o2H2nyZpF0= -k8s.io/code-generator v0.29.9/go.mod h1:7TYnI0dYItL2cKuhhgPSuF3WED9uMdELgbVXFfn/joE= -k8s.io/component-base v0.29.9 h1:lPENvp3CCwdeMEWGjiTfn5b287qQYuK7gX32OBOovmA= -k8s.io/component-base v0.29.9/go.mod h1:NGDa6Ih0EdcLA2G4K2ZYySoiB+2Tn+rmSqPyudCPgDY= +k8s.io/code-generator v0.29.10 h1:Tj2comS0HYcs9yTt/g5PtiSxnprR7W/3oHLrarmWU5c= +k8s.io/code-generator v0.29.10/go.mod h1:7TYnI0dYItL2cKuhhgPSuF3WED9uMdELgbVXFfn/joE= +k8s.io/component-base v0.29.10 h1:YQrQ/bpzGPGqIPEPaBzxjH0/1DJOI+yZPZNbbz7ZCBY= +k8s.io/component-base v0.29.10/go.mod h1:IbwsBob2DnYiAONsSHIuYenchqcDycbHSLHrXshuLgM= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= @@ -862,8 +862,8 @@ k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= -k8s.io/kubectl v0.29.9 h1:8DJIPkRk5a6WonxRAbicJIn0DNwacOxaLxO4EDwf/hc= -k8s.io/kubectl v0.29.9/go.mod h1:ylJbHUuPTYiwxAKx97nAyU3TKh3vHlEW+Pp44Usolvw= +k8s.io/kubectl v0.29.10 h1:9LLAI52kRG98Kicn+JUPY3ZVg8MPcJVsHPoaMM//9cA= +k8s.io/kubectl v0.29.10/go.mod h1:HxsflBafbaRcMyQjiD6elLHr+erlGmnQgLzSDYjEth0= k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=