Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Remove flytekit image priming (#412)
Browse files Browse the repository at this point in the history
* Remove flytekit image priming

Signed-off-by: Jeev B <jeevb@users.noreply.github.com>

* Fix goreleaser

Signed-off-by: Jeev B <jeevb@users.noreply.github.com>

---------

Signed-off-by: Jeev B <jeevb@users.noreply.github.com>
  • Loading branch information
jeevb authored Jul 5, 2023
1 parent 0cb2bfa commit ac3aa73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
17 changes: 10 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ builds:
ldflags:
- -s -w -X github.com/flyteorg/flytestdlib/version.Version={{.Version}} -X github.com/flyteorg/flytestdlib/version.Build={{.ShortCommit}} -X github.com/flyteorg/flytestdlib/version.BuildTime={{.Date}}
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
- name_template: |-
{{ .ProjectName }}_
{{- if eq .Os "darwin" }}Darwin
{{- else if eq .Os "linux" }}Linux
{{- else if eq .Os "windows" }}Windows
{{- else }}{{ .Os }}{{ end }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
Expand Down
40 changes: 4 additions & 36 deletions pkg/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,30 +248,7 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService
return logReader, nil
}

func primeFlytekitPod(ctx context.Context, podService corev1.PodInterface) {
_, err := podService.Create(ctx, &corev1api.Pod{
ObjectMeta: v1.ObjectMeta{
Name: "py39-cacher",
},
Spec: corev1api.PodSpec{
RestartPolicy: corev1api.RestartPolicyNever,
Containers: []corev1api.Container{
{

Name: "flytekit",
Image: "ghcr.io/flyteorg/flytekit:py3.9-latest",
Command: []string{"echo"},
Args: []string{"Flyte"},
},
},
},
}, v1.CreateOptions{})
if err != nil {
fmt.Printf("Failed to create primer pod - %s", err)
}
}

func StartCluster(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config, primePod bool, defaultImageName string, defaultImagePrefix string, exposedPorts map[nat.Port]struct{}, portBindings map[nat.Port][]nat.PortBinding, consolePort int) error {
func StartCluster(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config, defaultImageName string, defaultImagePrefix string, exposedPorts map[nat.Port]struct{}, portBindings map[nat.Port][]nat.PortBinding, consolePort int) error {
k8sCtxMgr := k8s.NewK8sContextManager()
err := k8sCtxMgr.CheckConfig()
if err != nil {
Expand Down Expand Up @@ -354,16 +331,13 @@ func StartCluster(ctx context.Context, args []string, sandboxConfig *sandboxCmdC
if err := WatchFlyteDeployment(ctx, k8sClient.CoreV1()); err != nil {
return err
}
if primePod {
primeFlytekitPod(ctx, k8sClient.CoreV1().Pods("default"))
}
}
return nil
}

// StartClusterForSandbox is the code for the original multi deploy version of sandbox, should be removed once we
// document the new development experience for plugins.
func StartClusterForSandbox(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config, primePod bool, defaultImageName string, defaultImagePrefix string, exposedPorts map[nat.Port]struct{}, portBindings map[nat.Port][]nat.PortBinding, consolePort int) error {
func StartClusterForSandbox(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config, defaultImageName string, defaultImagePrefix string, exposedPorts map[nat.Port]struct{}, portBindings map[nat.Port][]nat.PortBinding, consolePort int) error {
k8sCtxMgr := k8s.NewK8sContextManager()
err := k8sCtxMgr.CheckConfig()
if err != nil {
Expand Down Expand Up @@ -408,24 +382,19 @@ func StartClusterForSandbox(ctx context.Context, args []string, sandboxConfig *s
if err := WatchFlyteDeployment(ctx, k8sClient.CoreV1()); err != nil {
return err
}
if primePod {
primeFlytekitPod(ctx, k8sClient.CoreV1().Pods("default"))
}

}
return nil
}

func StartDemoCluster(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config) error {
primePod := true
sandboxImagePrefix := "sha"
exposedPorts, portBindings, err := docker.GetDemoPorts()
if err != nil {
return err
}
// K3s will automatically write the file specified by this var, which is mounted from user's local state dir.
sandboxConfig.Env = append(sandboxConfig.Env, k3sKubeConfigEnvVar)
err = StartCluster(ctx, args, sandboxConfig, primePod, demoImageName, sandboxImagePrefix, exposedPorts, portBindings, util.DemoConsolePort)
err = StartCluster(ctx, args, sandboxConfig, demoImageName, sandboxImagePrefix, exposedPorts, portBindings, util.DemoConsolePort)
if err != nil {
return err
}
Expand All @@ -434,13 +403,12 @@ func StartDemoCluster(ctx context.Context, args []string, sandboxConfig *sandbox
}

func StartSandboxCluster(ctx context.Context, args []string, sandboxConfig *sandboxCmdConfig.Config) error {
primePod := false
demoImagePrefix := "dind"
exposedPorts, portBindings, err := docker.GetSandboxPorts()
if err != nil {
return err
}
err = StartClusterForSandbox(ctx, args, sandboxConfig, primePod, sandboxImageName, demoImagePrefix, exposedPorts, portBindings, util.SandBoxConsolePort)
err = StartClusterForSandbox(ctx, args, sandboxConfig, sandboxImageName, demoImagePrefix, exposedPorts, portBindings, util.SandBoxConsolePort)
if err != nil {
return err
}
Expand Down

0 comments on commit ac3aa73

Please sign in to comment.