From 5d54659b8a463ab57652ca6ff55db6d65c659d13 Mon Sep 17 00:00:00 2001 From: Yuvraj Date: Thu, 19 Aug 2021 15:24:45 +0530 Subject: [PATCH] Bug fix in sandbix start (#161) * Added version compare check and bug fix in sandbox start Signed-off-by: Yuvraj --- flytectl/.github/config.yml | 1 + flytectl/.github/workflows/sandbox.yaml | 3 --- flytectl/boilerplate/flyte/welcome_bot/config.yml | 1 + flytectl/cmd/sandbox/start.go | 4 ++-- flytectl/cmd/upgrade/upgrade.go | 2 ++ flytectl/pkg/util/util.go | 8 ++++++-- flytectl/pkg/util/util_test.go | 5 +++++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/flytectl/.github/config.yml b/flytectl/.github/config.yml index f99bcd78f1f..7afe6111f5d 100644 --- a/flytectl/.github/config.yml +++ b/flytectl/.github/config.yml @@ -3,6 +3,7 @@ newPRWelcomeComment: > Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line: + - Most of the repos have a PR template; if not, fill it out to the best of your knowledge. - Sign off your commits (Reference: [DCO Guide](https://github.com/src-d/guide/blob/master/developer-community/fix-DCO.md)). diff --git a/flytectl/.github/workflows/sandbox.yaml b/flytectl/.github/workflows/sandbox.yaml index 62ba9f783b2..cb720479956 100644 --- a/flytectl/.github/workflows/sandbox.yaml +++ b/flytectl/.github/workflows/sandbox.yaml @@ -20,9 +20,6 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} - name: Build Flytectl binary run: make compile - - name: Setup env - run: | - mkdir -p ~/.flyte/k3s && touch ~/.flyte/k3s/k3s.yaml && chmod 666 ~/.flyte/k3s/k3s.yaml - name: Create a sandbox cluster run: bin/flytectl sandbox start - name: Setup flytectl config diff --git a/flytectl/boilerplate/flyte/welcome_bot/config.yml b/flytectl/boilerplate/flyte/welcome_bot/config.yml index f99bcd78f1f..7afe6111f5d 100644 --- a/flytectl/boilerplate/flyte/welcome_bot/config.yml +++ b/flytectl/boilerplate/flyte/welcome_bot/config.yml @@ -3,6 +3,7 @@ newPRWelcomeComment: > Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line: + - Most of the repos have a PR template; if not, fill it out to the best of your knowledge. - Sign off your commits (Reference: [DCO Guide](https://github.com/src-d/guide/blob/master/developer-community/fix-DCO.md)). diff --git a/flytectl/cmd/sandbox/start.go b/flytectl/cmd/sandbox/start.go index b97c3c1dd23..c5559988feb 100644 --- a/flytectl/cmd/sandbox/start.go +++ b/flytectl/cmd/sandbox/start.go @@ -47,7 +47,7 @@ Mount your source code repository inside sandbox bin/flytectl sandbox start --source=$HOME/flyteorg/flytesnacks -Run specific version of flyte, Only available after v0.14.0+ +Run specific version of flyte, Only available after v0.13.0+ :: bin/flytectl sandbox start --version=v0.14.0 @@ -55,7 +55,7 @@ Run specific version of flyte, Only available after v0.14.0+ Usage ` k8sEndpoint = "https://127.0.0.1:30086" - flyteMinimumVersionSupported = "v0.14.0" + flyteMinimumVersionSupported = "v0.13.0" generatedManifest = "/flyteorg/share/flyte_generated.yaml" flyteNamespace = "flyte" diskPressureTaint = "node.kubernetes.io/disk-pressure" diff --git a/flytectl/cmd/upgrade/upgrade.go b/flytectl/cmd/upgrade/upgrade.go index 84f79a915ff..54686a1f768 100644 --- a/flytectl/cmd/upgrade/upgrade.go +++ b/flytectl/cmd/upgrade/upgrade.go @@ -32,6 +32,8 @@ Upgrade flytectl bin/flytectl upgrade +Note: Please use upgrade with sudo, Without sudo it will cause permission issue + Rollback flytectl binary :: diff --git a/flytectl/pkg/util/util.go b/flytectl/pkg/util/util.go index 99a24084580..416ad58c7f7 100644 --- a/flytectl/pkg/util/util.go +++ b/flytectl/pkg/util/util.go @@ -32,7 +32,11 @@ func WriteIntoFile(data []byte, file string) error { // SetupFlyteDir will create .flyte dir if not exist func SetupFlyteDir() error { - if err := os.MkdirAll(f.FilePathJoin(f.UserHomeDir(), ".flyte"), os.ModePerm); err != nil { + if err := os.MkdirAll(f.FilePathJoin(f.UserHomeDir(), ".flyte", "k3s"), os.ModePerm); err != nil { + return err + } + // Created a empty file with right permission + if err := ioutil.WriteFile(docker.Kubeconfig, []byte(""), os.ModePerm); err != nil { return err } return nil @@ -48,7 +52,7 @@ func IsVersionGreaterThan(version1, version2 string) (bool, error) { if err != nil { return false, err } - return semanticVersion2.LessThanOrEqual(semanticVersion1), nil + return semanticVersion1.GreaterThan(semanticVersion2), nil } // PrintSandboxMessage will print sandbox success message diff --git a/flytectl/pkg/util/util_test.go b/flytectl/pkg/util/util_test.go index bbb84b3e337..c123683e867 100644 --- a/flytectl/pkg/util/util_test.go +++ b/flytectl/pkg/util/util_test.go @@ -33,6 +33,11 @@ func TestIsVersionGreaterThan(t *testing.T) { assert.Nil(t, err) assert.Equal(t, true, ok) }) + t.Run("Compare flytectl version greater then for equal value", func(t *testing.T) { + ok, err := IsVersionGreaterThan(testVersion, testVersion) + assert.Nil(t, err) + assert.Equal(t, false, ok) + }) t.Run("Compare flytectl version smaller then", func(t *testing.T) { ok, err := IsVersionGreaterThan("v0.1.19", testVersion) assert.Nil(t, err)