Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions flyteplugins/go/tasks/plugins/k8s/spark/spark.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,20 @@ func createSparkPodSpec(
labels = pluginsUtils.UnionMaps(labels, k8sPod.GetMetadata().GetLabels())
}

sparkEnv := make([]v1.EnvVar, 0)
for _, envVar := range container.Env {
sparkEnv = append(sparkEnv, *envVar.DeepCopy())
for i := range podSpec.Containers {
if podSpec.Containers[i].Name == container.Name {
podSpec.Containers[i].Env = append(podSpec.Containers[i].Env,
v1.EnvVar{Name: "FLYTE_MAX_ATTEMPTS", Value: strconv.Itoa(int(taskCtx.TaskExecutionMetadata().GetMaxAttempts()))})
}
}
sparkEnv = append(sparkEnv, v1.EnvVar{Name: "FLYTE_MAX_ATTEMPTS", Value: strconv.Itoa(int(taskCtx.TaskExecutionMetadata().GetMaxAttempts()))})

spec := sparkOp.SparkPodSpec{
Affinity: podSpec.Affinity,
Annotations: annotations,
Labels: labels,
Env: sparkEnv,
Image: &container.Image,
PodSecurityContext: podSpec.SecurityContext,
SecurityContext: container.SecurityContext,
DNSConfig: podSpec.DNSConfig.DeepCopy(),
Tolerations: podSpec.Tolerations,
SchedulerName: &podSpec.SchedulerName,
NodeSelector: podSpec.NodeSelector,
HostNetwork: &podSpec.HostNetwork,
ServiceAccount: strPtr(serviceAccountName(taskCtx.TaskExecutionMetadata())),
ServiceAccount: strPtr(serviceAccountName(taskCtx.TaskExecutionMetadata())),
Template: &v1.PodTemplateSpec{
Spec: *podSpec,
},
Annotations: annotations,
Labels: labels,
}
return &spec
}
Expand Down Expand Up @@ -236,7 +230,6 @@ func createDriverSpec(ctx context.Context, taskCtx pluginsCore.TaskExecutionCont
},
}
spec.sparkSpec.ServiceAccount = strPtr(serviceAccountName(nonInterruptibleTaskCtx.TaskExecutionMetadata()))
spec.sparkSpec.PriorityClassName = strPtr(podSpec.PriorityClassName)

if cores, err := strconv.ParseInt(sparkConfig["spark.driver.cores"], 10, 32); err == nil {
spec.sparkSpec.Cores = intPtr(int32(cores))
Expand Down Expand Up @@ -291,7 +284,6 @@ func createExecutorSpec(ctx context.Context, taskCtx pluginsCore.TaskExecutionCo
},
serviceAccountName,
}
spec.sparkSpec.PriorityClassName = strPtr(podSpec.PriorityClassName)
if execCores, err := strconv.ParseInt(sparkConfig["spark.executor.cores"], 10, 32); err == nil {
spec.sparkSpec.Cores = intPtr(int32(execCores))
}
Expand Down
Loading
Loading