Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ RUN apt-get update \
&& apt-get install -y openssl curl tini \
&& rm -rf /var/lib/apt/lists/*
COPY hack/gencerts.sh /usr/bin/

ENV HTTP2_DISABLE=true
COPY entrypoint.sh /usr/bin/
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ spec:
type: string
required:
- containerPort
- protocol
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -1439,6 +1440,7 @@ spec:
type: string
required:
- containerPort
- protocol
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -2380,6 +2382,7 @@ spec:
type: string
required:
- containerPort
- protocol
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -2919,6 +2922,7 @@ spec:
type: string
required:
- containerPort
- protocol
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
28 changes: 7 additions & 21 deletions pkg/webhook/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,42 +713,28 @@ func addCustomResources(pod *corev1.Pod, app *v1beta2.SparkApplication) []patchO
resource = app.Spec.Executor.CustomResources
}

var coreContainerRequests corev1.ResourceList
var coreContainerLimits corev1.ResourceList

i := 0
// Find the driver or executor container in the pod.
for ; i < len(pod.Spec.Containers); i++ {
if pod.Spec.Containers[i].Name == config.SparkDriverContainerName ||
pod.Spec.Containers[i].Name == config.SparkExecutorContainerName {
coreContainerRequests = pod.Spec.Containers[i].Resources.Requests
coreContainerLimits = pod.Spec.Containers[i].Resources.Requests
break
}
}
requestsPath := fmt.Sprintf("/spec/containers/%d/resources/requests", i)
limitsPath := fmt.Sprintf("/spec/containers/%d/resources/limits", i)

for k, v := range coreContainerRequests {
if resource.Requests == nil {
resource.Requests = make(corev1.ResourceList)
}
resource.Requests[k] = v
}
for k, v := range coreContainerLimits {
if resource.Limits == nil {
resource.Limits = make(corev1.ResourceList)
}
resource.Limits[k] = v

}

encoder := strings.NewReplacer("~", "~0", "/", "~1")
if len(resource.Requests) != 0 {
ops = append(ops, patchOperation{Op: "add", Path: requestsPath, Value: resource.Requests})
for k, v := range resource.Requests {
ops = append(ops, patchOperation{Op: "add", Path: fmt.Sprintf("%s/%s", requestsPath, encoder.Replace(string(k))), Value: v})
}
}

if len(resource.Limits) != 0 {
ops = append(ops, patchOperation{Op: "add", Path: limitsPath, Value: resource.Limits})
for k, v := range resource.Limits {
ops = append(ops, patchOperation{Op: "add", Path: fmt.Sprintf("%s/%s", limitsPath, encoder.Replace(string(k))), Value: v})
}
}

return ops
Expand Down