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

Enable deploying Azure Storage account File shares with user specified storage quota. #3611

Merged
merged 7 commits into from
Jan 25, 2025
11 changes: 8 additions & 3 deletions lisa/sut_orchestrator/azure/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,8 @@ def get_share_service_client(
return share_service_client


# Update: Added quota to allow creation of variable sized file share volumes.
# Default is 100 GiB. All units are in GiB.
def get_or_create_file_share(
credential: Any,
subscription_id: str,
Expand All @@ -1984,9 +1986,10 @@ def get_or_create_file_share(
resource_group_name: str,
log: Logger,
protocols: str = "SMB",
quota: int = 100,
shekharsorot marked this conversation as resolved.
Show resolved Hide resolved
) -> str:
"""
Create a Azure Storage file share if it does not exist.
Create an Azure Storage file share if it does not exist.
"""
share_service_client = get_share_service_client(
credential,
Expand All @@ -1996,9 +1999,11 @@ def get_or_create_file_share(
resource_group_name,
)
all_shares = list(share_service_client.list_shares())
if file_share_name not in (x.name for x in all_shares):
if file_share_name not in (x.name for x in all_shares): # type: ignore
log.debug(f"creating file share {file_share_name} with protocols {protocols}")
share_service_client.create_share(file_share_name, protocols=protocols)
share_service_client.create_share(
file_share_name, protocols=protocols, quota=quota
)
return str("//" + share_service_client.primary_hostname + "/" + file_share_name)


Expand Down
10 changes: 9 additions & 1 deletion lisa/sut_orchestrator/azure/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,10 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
self.storage_account_name: str = ""
self.file_share_name: str = ""

def create_share(self) -> None:
def create_share(
self,
quota: int = 100,
) -> None:
platform: AzurePlatform = self._platform # type: ignore
node_context = self._node.capability.get_extended_runbook(AzureNodeSchema)
location = node_context.location
Expand Down Expand Up @@ -2909,6 +2912,7 @@ def create_share(self) -> None:
resource_group_name=resource_group_name,
protocols="NFS",
log=self._log,
quota=quota,
)

storage_account_resource_id = (
Expand Down Expand Up @@ -3442,6 +3446,7 @@ def create_file_share(
kind: str = "StorageV2",
enable_https_traffic_only: bool = True,
enable_private_endpoint: bool = False,
quota: int = 100,
) -> Dict[str, str]:
platform: AzurePlatform = self._platform # type: ignore
information = environment.get_information()
Expand All @@ -3467,6 +3472,8 @@ def create_file_share(
# If enable_private_endpoint is true, SMB share endpoint
# will dns resolve to <share>.privatelink.file.core.windows.net
# No changes need to be done in code calling function
# For Quota, currently all volumes will share same quota number.
# Ensure that you use the highest value applicable for your shares
for share_name in file_share_names:
fs_url_dict[share_name] = get_or_create_file_share(
credential=platform.credential,
Expand All @@ -3476,6 +3483,7 @@ def create_file_share(
file_share_name=share_name,
resource_group_name=resource_group_name,
log=self._log,
quota=quota,
)
# Create file private endpoint, always after all shares have been created
# There is a known issue in API preventing access to data plane
Expand Down
Loading