Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Remove sys_ptrace dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
pingsutw committed May 10, 2022
1 parent 4f9cec1 commit 4b98a92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 0 additions & 3 deletions go/tasks/pluginmachinery/flytek8s/container_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,13 @@ func ToK8sContainer(ctx context.Context, taskContainer *core.Container, iFace *c
if errs := validation.IsDNS1123Label(containerName); len(errs) > 0 {
containerName = rand.String(4)
}
preStopHook := v1.Handler{Exec: &v1.ExecAction{Command: []string{"/bin/sh", "-c", "touch /var/outputs/_SUCCESS"}}}

container := &v1.Container{
Name: containerName,
Image: taskContainer.GetImage(),
Args: taskContainer.GetArgs(),
Command: taskContainer.GetCommand(),
Env: ToK8sEnvVar(taskContainer.GetEnv()),
TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError,
Lifecycle: &v1.Lifecycle{PreStop: &preStopHook},
}
if err := AddCoPilotToContainer(ctx, config.GetK8sPluginConfig().CoPilot, container, iFace, taskContainer.DataConfig); err != nil {
return nil, err
Expand Down
2 changes: 0 additions & 2 deletions go/tasks/pluginmachinery/flytek8s/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ func AddCoPilotToPod(ctx context.Context, cfg config.FlyteCoPilotConfig, coPilot
}

logger.Infof(ctx, "CoPilot Enabled for task [%s]", taskExecMetadata.GetTaskExecutionID().GetID().TaskId.Name)
shareProcessNamespaceEnabled := true
coPilotPod.ShareProcessNamespace = &shareProcessNamespaceEnabled
if iFace != nil {
if iFace.Inputs != nil {
inPath := cfg.DefaultInputDataPath
Expand Down
6 changes: 6 additions & 0 deletions go/tasks/plugins/k8s/pod/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ func (containerPodBuilder) buildPodSpec(ctx context.Context, task *core.TaskTemp
}

func (containerPodBuilder) updatePodMetadata(ctx context.Context, pod *v1.Pod, task *core.TaskTemplate, taskCtx pluginsCore.TaskExecutionContext) error {
pilot := task.GetContainer().GetDataConfig()
if pilot == nil || !pilot.Enabled || task.Interface.Outputs == nil {
return nil
}
pod.Annotations = make(map[string]string)
pod.Annotations[RawContainerName] = pod.Spec.Containers[0].Name
return nil
}
14 changes: 14 additions & 0 deletions go/tasks/plugins/k8s/pod/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
const (
podTaskType = "pod"
PrimaryContainerKey = "primary_container_name"
RawContainerName = "raw_container_name"
)

var (
Expand Down Expand Up @@ -121,6 +122,19 @@ func (plugin) GetTaskPhaseWithLogs(ctx context.Context, pluginContext k8s.Plugin
return pluginsCore.PhaseInfoUndefined, nil
}

RawContainerName, exists := r.GetAnnotations()[RawContainerName]
if exists {
// we'll declare the task as "failure" If raw container fail, but the rawContainer
// task requires all containers (raw container and sidecar) to succeed to declare success
for _, s := range pod.Status.ContainerStatuses {
if s.Name == RawContainerName {
if s.State.Terminated != nil && s.State.Terminated.ExitCode != 0 {
return pluginsCore.PhaseInfoRetryableFailure(s.State.Terminated.Reason, s.State.Terminated.Message, &info), nil
}
}
}
}

primaryContainerName, exists := r.GetAnnotations()[PrimaryContainerKey]
if !exists {
// if the primary container annotation dos not exist, then the task requires all containers
Expand Down

0 comments on commit 4b98a92

Please sign in to comment.