Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIP-8595 truncate volume name #314

Merged
merged 2 commits into from
Sep 17, 2024
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
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)}}"
cloudw marked this conversation as resolved.
Show resolved Hide resolved
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()
Loading