Repository: kubernetes-sigs/cloud-provider-azure
Pull request #5634 (2024-03-08 12:41:46)

[release-1.29] fix: nfs file share created in storage account that has smb file share
This is an automated cherry-pick of #5619

/assign andyzhangx

```release-note
fix: nfs file share created in storage account that has smb file share
```


Patch:
diff --git a/pkg/provider/azure_storageaccount.go b/pkg/provider/azure_storageaccount.go
index a26719f80..f6477ff76 100644
--- a/pkg/provider/azure_storageaccount.go
+++ b/pkg/provider/azure_storageaccount.go
@@ -117,6 +117,7 @@ func (az *Cloud) getStorageAccounts(ctx context.Context, accountOptions *Account
 				isTaggedWithSkip(acct) &&
 				isHnsPropertyEqual(acct, accountOptions) &&
 				isEnableNfsV3PropertyEqual(acct, accountOptions) &&
+				isEnableHTTPSTrafficOnlyEqual(acct, accountOptions) &&
 				isAllowBlobPublicAccessEqual(acct, accountOptions) &&
 				isRequireInfrastructureEncryptionEqual(acct, accountOptions) &&
 				isAllowSharedKeyAccessEqual(acct, accountOptions) &&
@@ -861,6 +862,10 @@ func isEnableNfsV3PropertyEqual(account storage.Account, accountOptions *Account
 	return pointer.BoolDeref(accountOptions.EnableNfsV3, false) == pointer.BoolDeref(account.EnableNfsV3, false)
 }
 
+func isEnableHTTPSTrafficOnlyEqual(account storage.Account, accountOptions *AccountOptions) bool {
+	return accountOptions.EnableHTTPSTrafficOnly == pointer.BoolDeref(account.EnableHTTPSTrafficOnly, true)
+}
+
 func isPrivateEndpointAsExpected(account storage.Account, accountOptions *AccountOptions) bool {
 	if accountOptions.CreatePrivateEndpoint == nil {
 		// CreatePrivateEndpoint is not set, match current account


Test patch:
diff --git a/pkg/provider/azure_storageaccount_test.go b/pkg/provider/azure_storageaccount_test.go
index cbf5a2d8c..5290323ab 100644
--- a/pkg/provider/azure_storageaccount_test.go
+++ b/pkg/provider/azure_storageaccount_test.go
@@ -178,6 +178,7 @@ func TestGetStorageAccounts(t *testing.T) {
 	accountOptions := &AccountOptions{
 		ResourceGroup:             "rg",
 		VirtualNetworkResourceIDs: []string{networkID},
+		EnableHTTPSTrafficOnly:    true,
 	}
 
 	mockStorageAccountsClient := mockstorageaccountclient.NewMockInterface(ctrl)
@@ -1079,6 +1080,69 @@ func TestIsEnableNfsV3PropertyEqual(t *testing.T) {
 	}
 }
 
+func TestIsEnableHTTPSTrafficOnly(t *testing.T) {
+	tests := []struct {
+		account        storage.Account
+		accountOptions *AccountOptions
+		expectedResult bool
+	}{
+		{
+			account: storage.Account{
+				AccountProperties: &storage.AccountProperties{
+					EnableHTTPSTrafficOnly: pointer.Bool(true),
+				},
+			},
+			accountOptions: &AccountOptions{},
+			expectedResult: false,
+		},
+		{
+			account: storage.Account{
+				AccountProperties: &storage.AccountProperties{},
+			},
+			accountOptions: &AccountOptions{
+				EnableHTTPSTrafficOnly: false,
+			},
+			expectedResult: false,
+		},
+		{
+			account: storage.Account{
+				AccountProperties: &storage.AccountProperties{
+					EnableHTTPSTrafficOnly: pointer.Bool(true),
+				},
+			},
+			accountOptions: &AccountOptions{
+				EnableHTTPSTrafficOnly: true,
+			},
+			expectedResult: true,
+		},
+		{
+			account: storage.Account{
+				AccountProperties: &storage.AccountProperties{},
+			},
+			accountOptions: &AccountOptions{
+				EnableHTTPSTrafficOnly: true,
+			},
+			expectedResult: true,
+		},
+		{
+			account: storage.Account{
+				AccountProperties: &storage.AccountProperties{
+					EnableHTTPSTrafficOnly: pointer.Bool(true),
+				},
+			},
+			accountOptions: &AccountOptions{
+				EnableHTTPSTrafficOnly: false,
+			},
+			expectedResult: false,
+		},
+	}
+
+	for _, test := range tests {
+		result := isEnableHTTPSTrafficOnlyEqual(test.account, test.accountOptions)
+		assert.Equal(t, test.expectedResult, result)
+	}
+}
+
 func TestIsAllowBlobPublicAccessEqual(t *testing.T) {
 	tests := []struct {
 		account        storage.Account