Skip to content

Commit 50fee32

Browse files
authored
Enable deploying Azure Storage account File shares with user specified storage quota. (#3611)
* update azure file share function to accept quota * fix for incorrect documentation stating value in bytes * Update common.py * change quota to quota_in_gb for better readibility * missing comma,BLK100
1 parent 0f04e73 commit 50fee32

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lisa/sut_orchestrator/azure/common.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,8 @@ def get_share_service_client(
19751975
return share_service_client
19761976

19771977

1978+
# Update: Added quota to allow creation of variable sized file share volumes.
1979+
# Default is 100 GiB. All units are in GiB.
19781980
def get_or_create_file_share(
19791981
credential: Any,
19801982
subscription_id: str,
@@ -1984,9 +1986,10 @@ def get_or_create_file_share(
19841986
resource_group_name: str,
19851987
log: Logger,
19861988
protocols: str = "SMB",
1989+
quota_in_gb: int = 100,
19871990
) -> str:
19881991
"""
1989-
Create a Azure Storage file share if it does not exist.
1992+
Create an Azure Storage file share if it does not exist.
19901993
"""
19911994
share_service_client = get_share_service_client(
19921995
credential,
@@ -1998,7 +2001,11 @@ def get_or_create_file_share(
19982001
all_shares = list(share_service_client.list_shares())
19992002
if file_share_name not in (x.name for x in all_shares):
20002003
log.debug(f"creating file share {file_share_name} with protocols {protocols}")
2001-
share_service_client.create_share(file_share_name, protocols=protocols)
2004+
share_service_client.create_share(
2005+
file_share_name,
2006+
protocols=protocols,
2007+
quota=quota_in_gb,
2008+
)
20022009
return str("//" + share_service_client.primary_hostname + "/" + file_share_name)
20032010

20042011

lisa/sut_orchestrator/azure/features.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,10 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
29162916
self.storage_account_name: str = ""
29172917
self.file_share_name: str = ""
29182918

2919-
def create_share(self) -> None:
2919+
def create_share(
2920+
self,
2921+
quota_in_gb: int = 100,
2922+
) -> None:
29202923
platform: AzurePlatform = self._platform # type: ignore
29212924
node_context = self._node.capability.get_extended_runbook(AzureNodeSchema)
29222925
location = node_context.location
@@ -2947,6 +2950,7 @@ def create_share(self) -> None:
29472950
resource_group_name=resource_group_name,
29482951
protocols="NFS",
29492952
log=self._log,
2953+
quota_in_gb=quota_in_gb,
29502954
)
29512955

29522956
storage_account_resource_id = (
@@ -3480,6 +3484,7 @@ def create_file_share(
34803484
kind: str = "StorageV2",
34813485
enable_https_traffic_only: bool = True,
34823486
enable_private_endpoint: bool = False,
3487+
quota_in_gb: int = 100,
34833488
) -> Dict[str, str]:
34843489
platform: AzurePlatform = self._platform # type: ignore
34853490
information = environment.get_information()
@@ -3505,6 +3510,8 @@ def create_file_share(
35053510
# If enable_private_endpoint is true, SMB share endpoint
35063511
# will dns resolve to <share>.privatelink.file.core.windows.net
35073512
# No changes need to be done in code calling function
3513+
# For Quota, currently all volumes will share same quota number.
3514+
# Ensure that you use the highest value applicable for your shares
35083515
for share_name in file_share_names:
35093516
fs_url_dict[share_name] = get_or_create_file_share(
35103517
credential=platform.credential,
@@ -3514,6 +3521,7 @@ def create_file_share(
35143521
file_share_name=share_name,
35153522
resource_group_name=resource_group_name,
35163523
log=self._log,
3524+
quota_in_gb=quota_in_gb,
35173525
)
35183526
# Create file private endpoint, always after all shares have been created
35193527
# There is a known issue in API preventing access to data plane

0 commit comments

Comments
 (0)