Skip to content

Commit

Permalink
Merge pull request #314 from zillow/tz/AIP-8595-trunc-volume-name
Browse files Browse the repository at this point in the history
AIP-8595 truncate volume name
  • Loading branch information
talebzeghmi authored Sep 17, 2024
2 parents 5922dce + 0ac13aa commit 64236a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions metaflow/plugins/aip/aip.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,9 @@ def _create_volume(
size: str,
volume_type: Optional[str],
) -> Tuple[ResourceOp, PipelineVolume]:
volume_name = "{{pod.name}}"
# AIP-8595(talebz): to avoid volume name "must be no more than 63 characters error"
# truncate from the beginning (the suffix has more entropy)
volume_name = "{{=sprig.trunc(-63, pod.name)}}"
attribute_outputs = {"size": "{.status.capacity.storage}"}
requested_resources = V1ResourceRequirements(requests={"storage": size})

Expand Down Expand Up @@ -999,9 +1001,7 @@ def _create_volume(
)
self._set_container_labels(resource)

volume = PipelineVolume(
name=f"{volume_name}-volume", pvc=resource.outputs["name"]
)
volume = PipelineVolume(name=f"{volume_name}", pvc=resource.outputs["name"])
return (resource, volume)

@staticmethod
Expand Down
5 changes: 3 additions & 2 deletions metaflow/plugins/aip/tests/flows/resources_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def __repr__(self):
return "Dataset"


class ResourcesFlow(FlowSpec):
# AIP-8595(talebz): To validate that volume names are truncated to 63 characters
class ResourcesFlowLooooooooooooooooooooooongNaaaaaaaaaaaaaaaaaaaaame(FlowSpec):
json_param: Dict = Parameter(
"json_param", default=default_dict, type=TestTypeClass()
)
Expand Down Expand Up @@ -216,4 +217,4 @@ def end(self):


if __name__ == "__main__":
ResourcesFlow()
ResourcesFlowLooooooooooooooooooooooongNaaaaaaaaaaaaaaaaaaaaame()

0 comments on commit 64236a4

Please sign in to comment.