Chandni Singh created SPARK-59925:
-------------------------------------
Summary: DriverResourceDecorator overwrites resource-defined
labels with driver pod labels
Key: SPARK-59925
URL: https://issues.apache.org/jira/browse/SPARK-59925
Project: Spark
Issue Type: Improvement
Components: Kubernetes
Affects Versions: 1.0.0
Reporter: Chandni Singh
{{DriverResourceDecorator}} copies the driver pod's entire label map onto every
driver secondary resource:
{code:java}
new ObjectMetaBuilder(resource.getMetadata())
.addToOwnerReferences(buildOwnerReferenceTo(driverPod))
.addToLabels(driverPod.getMetadata().getLabels())
.build();
{code}
{{addToLabels(Map)}} is a put per key, so a driver pod label silently replaces a
label the user declared on the resource itself through {{serviceMetadata}} in
{{{}DriverServiceIngressSpec{}}}, and since SPARK-58160 also in
{{DriverHttpRouteSpec}} and {{{}DriverGrpcRouteSpec{}}}. The copy is
undocumented
(the class javadoc covers only the owner reference).
*Proposed fix*
Apply the resource's own labels after the pod labels, so the resource's value
wins
on conflict:
{code:java}
Map<String, String> labels = new HashMap<>();
if (driverPod.getMetadata().getLabels() != null) {
labels.putAll(driverPod.getMetadata().getLabels());
}
if (resource.getMetadata().getLabels() != null) {
labels.putAll(resource.getMetadata().getLabels());
}
ObjectMeta metaData =
new ObjectMetaBuilder(resource.getMetadata())
.addToOwnerReferences(buildOwnerReferenceTo(driverPod))
.withLabels(labels)
.build();
{code}
Output is identical to today except on a key collision, where the resource now
wins. Both maps are nullable, since {{serviceMetadata}} is optional.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]