Skip to content

Commit

Permalink
fix: revert sandbox lite image tag prefix to sha (#312)
Browse files Browse the repository at this point in the history
* fix: revert sandbox lite image tag prefix to sha
Signed-off-by: Yuvraj <[email protected]>

* fix: make lint
Signed-off-by: Yuvraj <[email protected]>

* fix: unit test fixed for sandbox lite
Signed-off-by: Yuvraj <[email protected]>

* Remove mentions of sandbox in the docs and remove extraneous space

Signed-off-by: eduardo apolinario <[email protected]>

Co-authored-by: Yuvraj <[email protected]>
Co-authored-by: eduardo apolinario <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2022
1 parent f0930de commit e5e923f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 55 deletions.
3 changes: 2 additions & 1 deletion flytectl/boilerplate/flyte/golang_support_tools/tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

package tools
Expand All @@ -6,6 +7,6 @@ import (
_ "github.com/alvaroloes/enumer"
_ "github.com/flyteorg/flytestdlib/cli/pflags"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/vektra/mockery/cmd/mockery"
_ "github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
_ "github.com/vektra/mockery/cmd/mockery"
)
24 changes: 18 additions & 6 deletions flytectl/cmd/demo/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,43 @@ Starts the demo cluster without any source code:
::
flytectl demo start
Mounts your source code repository inside the demo cluster:
::
flytectl demo start --source=$HOME/flyteorg/flytesnacks
flytectl demo start --source=$HOME/flyteorg/flytesnacks
Specify a Flyte demo compliant image with the registry. This is useful in case you want to use an image from your registry.
::
flytectl demo start --image docker.io/my-override:latest
Note: If image flag is passed then Flytectl will ignore version and pre flags.
Specify a Flyte demo image pull policy. Possible pull policy values are Always, IfNotPresent, or Never:
::
flytectl demo start --image docker.io/my-override:latest --imagePullPolicy Always
flytectl demo start --image docker.io/my-override:latest --imagePullPolicy Always
Runs a specific version of Flyte. Flytectl demo only supports Flyte version available in the Github release, https://github.com/flyteorg/flyte/tags.
::
flytectl demo start --version=v0.14.0
.. note::
Flytectl demo is only supported for Flyte versions >= v1.0.0
Runs the latest pre release of Flyte.
::
flytectl demo start --pre
Start demo cluster passing environment variables. This can be used to pass docker specific env variables or flyte specific env variables.
eg : for passing timeout value in secs for the demo container use the following.
::
flytectl demo start --env FLYTE_TIMEOUT=700
The DURATION can be a positive integer or a floating-point number, followed by an optional unit suffix::
s - seconds (default)
m - minutes
Expand Down Expand Up @@ -199,7 +211,7 @@ func startDemo(ctx context.Context, cli docker.Docker, reader io.Reader) (*bufio
}
demoImage := sandboxConfig.DefaultConfig.Image
if len(demoImage) == 0 {
image, version, err := githubutil.GetFullyQualifiedImageName(sandboxConfig.DefaultConfig.Version, demoImageName, sandboxConfig.DefaultConfig.Prerelease)
image, version, err := githubutil.GetFullyQualifiedImageName("sha", sandboxConfig.DefaultConfig.Version, demoImageName, sandboxConfig.DefaultConfig.Prerelease)
if err != nil {
return nil, err
}
Expand Down
38 changes: 19 additions & 19 deletions flytectl/cmd/demo/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestStartDemoFunc(t *testing.T) {
errCh := make(chan error)
sandboxConfig.DefaultConfig.Version = "v0.19.1"
bodyStatus := make(chan container.ContainerWaitOKBody)
image, _, err := githubutil.GetFullyQualifiedImageName(sandboxConfig.DefaultConfig.Version, demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", sandboxConfig.DefaultConfig.Version, demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestStartDemoFunc(t *testing.T) {
ctx := context.Background()
mockDocker := &mocks.Docker{}
errCh := make(chan error)
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
bodyStatus := make(chan container.ContainerWaitOKBody)
mockDocker.OnContainerCreate(ctx, &container.Config{
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestStartDemoFunc(t *testing.T) {
Source: sandboxConfig.DefaultConfig.Source,
Target: docker.Source,
})
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestStartDemoFunc(t *testing.T) {
Source: absPath,
Target: docker.Source,
})
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestStartDemoFunc(t *testing.T) {
sandboxConfig.DefaultConfig.Version = "v0.18.0"
sandboxConfig.DefaultConfig.Source = ""

image, _, err := githubutil.GetFullyQualifiedImageName(sandboxConfig.DefaultConfig.Version, demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", sandboxConfig.DefaultConfig.Version, demoImageName, false)
assert.Nil(t, err)
volumes := docker.Volumes
mockDocker.OnContainerCreate(ctx, &container.Config{
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestStartDemoFunc(t *testing.T) {
mockDocker := &mocks.Docker{}
sandboxConfig.DefaultConfig.Version = "v0.1444.0"
sandboxConfig.DefaultConfig.Source = ""
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
volumes := docker.Volumes
mockDocker.OnContainerCreate(ctx, &container.Config{
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestStartDemoFunc(t *testing.T) {
errCh := make(chan error)
bodyStatus := make(chan container.ContainerWaitOKBody)
mockDocker := &mocks.Docker{}
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
sandboxConfig.DefaultConfig.Source = f.UserHomeDir()
volumes := docker.Volumes
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestStartDemoFunc(t *testing.T) {
Source: sandboxConfig.DefaultConfig.Source,
Target: docker.Source,
})
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -404,7 +404,7 @@ func TestStartDemoFunc(t *testing.T) {
mockDocker := &mocks.Docker{}
sandboxConfig.DefaultConfig.Source = ""
sandboxConfig.DefaultConfig.Version = ""
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -443,7 +443,7 @@ func TestStartDemoFunc(t *testing.T) {
Source: sandboxConfig.DefaultConfig.Source,
Target: docker.Source,
})
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -483,7 +483,7 @@ func TestStartDemoFunc(t *testing.T) {
Source: sandboxConfig.DefaultConfig.Source,
Target: docker.Source,
})
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestStartDemoFunc(t *testing.T) {
if err != nil {
t.Error(err)
}
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
bodyStatus := make(chan container.ContainerWaitOKBody)
mockDocker.OnContainerCreate(ctx, &container.Config{
Expand Down Expand Up @@ -570,7 +570,7 @@ func TestStartDemoFunc(t *testing.T) {
mockDocker := &mocks.Docker{}
errCh := make(chan error)
bodyStatus := make(chan container.ContainerWaitOKBody)
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
mockDocker.OnContainerCreate(ctx, &container.Config{
Env: docker.Environment,
Expand Down Expand Up @@ -705,26 +705,26 @@ func TestGetNodeTaintStatus(t *testing.T) {

func TestGetDemoImage(t *testing.T) {
t.Run("Get Latest demo cluster", func(t *testing.T) {
image, _, err := githubutil.GetFullyQualifiedImageName("", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "", demoImageName, false)
assert.Nil(t, err)
assert.Equal(t, true, strings.HasPrefix(image, "cr.flyte.org/flyteorg/flyte-sandbox-lite:dind-"))
assert.Equal(t, true, strings.HasPrefix(image, "cr.flyte.org/flyteorg/flyte-sandbox-lite:sha-"))
})

t.Run("Get demo image with version ", func(t *testing.T) {
image, _, err := githubutil.GetFullyQualifiedImageName("v0.14.0", demoImageName, false)
image, _, err := githubutil.GetFullyQualifiedImageName("sha", "v0.14.0", demoImageName, false)
assert.Nil(t, err)
assert.Equal(t, true, strings.HasPrefix(image, demoImageName))
})
t.Run("Get demo image with wrong version ", func(t *testing.T) {
_, _, err := githubutil.GetFullyQualifiedImageName("v100.1.0", demoImageName, false)
_, _, err := githubutil.GetFullyQualifiedImageName("sha", "v100.1.0", demoImageName, false)
assert.NotNil(t, err)
})
t.Run("Get demo image with wrong version ", func(t *testing.T) {
_, _, err := githubutil.GetFullyQualifiedImageName("aaaaaa", demoImageName, false)
_, _, err := githubutil.GetFullyQualifiedImageName("sha", "aaaaaa", demoImageName, false)
assert.NotNil(t, err)
})
t.Run("Get demo image with version that is not supported", func(t *testing.T) {
_, _, err := githubutil.GetFullyQualifiedImageName("v0.10.0", demoImageName, false)
_, _, err := githubutil.GetFullyQualifiedImageName("sha", "v0.10.0", demoImageName, false)
assert.NotNil(t, err)
})

Expand Down
12 changes: 6 additions & 6 deletions flytectl/cmd/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Starts the sandbox cluster without any source code:
::
flytectl sandbox start
Mounts your source code repository inside the sandbox:
::
flytectl sandbox start --source=$HOME/flyteorg/flytesnacks
flytectl sandbox start --source=$HOME/flyteorg/flytesnacks
Runs a specific version of Flyte. Flytectl sandbox only supports Flyte version available in the Github release, https://github.com/flyteorg/flyte/tags.
::
Expand All @@ -59,15 +59,15 @@ Runs the latest pre release of Flyte.
flytectl sandbox start --pre
Note: The pre release flag will be ignored if the user passes the version flag. In that case, Flytectl will use a specific version.
Note: The pre release flag will be ignored if the user passes the version flag. In that case, Flytectl will use a specific version.
Specify a Flyte Sandbox compliant image with the registry. This is useful in case you want to use an image from your registry.
::
flytectl sandbox start --image docker.io/my-override:latest
Note: If image flag is passed then Flytectl will ignore version and pre flags.
Specify a Flyte Sandbox image pull policy. Possible pull policy values are Always, IfNotPresent, or Never:
::
Expand Down Expand Up @@ -191,7 +191,7 @@ func startSandbox(ctx context.Context, cli docker.Docker, reader io.Reader) (*bu
}
sandboxImage := sandboxConfig.DefaultConfig.Image
if len(sandboxImage) == 0 {
image, version, err := githubutil.GetFullyQualifiedImageName(sandboxConfig.DefaultConfig.Version, sandboxImageName, sandboxConfig.DefaultConfig.Prerelease)
image, version, err := githubutil.GetFullyQualifiedImageName("dind", sandboxConfig.DefaultConfig.Version, sandboxImageName, sandboxConfig.DefaultConfig.Prerelease)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit e5e923f

Please sign in to comment.