diff --git a/metaflow/plugins/aip/aip.py b/metaflow/plugins/aip/aip.py index 04b7af03bb5..0f10a91bba6 100644 --- a/metaflow/plugins/aip/aip.py +++ b/metaflow/plugins/aip/aip.py @@ -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}) @@ -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 diff --git a/metaflow/plugins/aip/tests/flows/resources_flow.py b/metaflow/plugins/aip/tests/flows/resources_flow.py index f8b5cbe234a..a162704461a 100644 --- a/metaflow/plugins/aip/tests/flows/resources_flow.py +++ b/metaflow/plugins/aip/tests/flows/resources_flow.py @@ -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() ) @@ -216,4 +217,4 @@ def end(self): if __name__ == "__main__": - ResourcesFlow() + ResourcesFlowLooooooooooooooooooooooongNaaaaaaaaaaaaaaaaaaaaame()