Skip to content

Commit 01db278

Browse files
author
Pushkar Acharya
committed
Ensure the use secondary vast cluster feature flag is used
1 parent 4028705 commit 01db278

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

internal/crusoe/nfs_flag.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
const (
1515
nfsFlagRouteTemplate = "%s/projects/%s/storage/nfs/is-using-nfs"
1616
vastUseSecondaryClusterFlagRouteTemplate = "%s/projects/%s/storage/nfs/vast-use-secondary-cluster"
17+
DEBUG = 8
1718
)
1819

1920
var (
@@ -51,7 +52,7 @@ func getFlag(ctx context.Context, crusoeHTTPClient *http.Client, flagRoute strin
5152

5253
klog.Infof("Flag API response - Status: %d, Content-Type: %s, Body length: %d bytes",
5354
resp.StatusCode, resp.Header.Get("Content-Type"), len(bodyBytes))
54-
klog.Infof("Flag API raw response body: %q", string(bodyBytes))
55+
klog.V(DEBUG).Infof("Flag API raw response body: %q", string(bodyBytes))
5556

5657
// Check HTTP status code before unmarshaling
5758
if resp.StatusCode != http.StatusOK {

internal/node/fs/fs_node.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (d *Node) NodePublishVolume(ctx context.Context, request *csi.NodePublishVo
8282
nfsHost := d.NFSHost
8383
nfsRemotePorts := d.NFSRemotePorts
8484
klog.Infof("Host instance location: %q, checking against icatLocation: %q", d.HostInstance.Location, icatLocation)
85-
if d.HostInstance.Location == icatLocation {
85+
if d.useDNSForMount(ctx) {
8686
klog.Infof("Using DNS-based NFS host for ICAT location: %s", crusoeCloudDNSNFSHost)
8787
nfsHost = crusoeCloudDNSNFSHost
8888
nfsRemotePorts = dnsRemotePorts
@@ -102,6 +102,18 @@ func (d *Node) NodePublishVolume(ctx context.Context, request *csi.NodePublishVo
102102
return &csi.NodePublishVolumeResponse{}, nil
103103
}
104104

105+
func (d *Node) useDNSForMount(ctx context.Context) bool {
106+
useSecondaryVast, err := crusoe.GetVastUseSecondaryClusterFlag(
107+
ctx, d.CrusoeHTTPClient, d.CrusoeAPIEndpoint, d.HostInstance.ProjectId)
108+
if err != nil {
109+
klog.Errorf("failed to fetch VastUseSecondaryCluster flag: %s", err.Error())
110+
111+
return false
112+
}
113+
114+
return useSecondaryVast && d.HostInstance.Location == icatLocation
115+
}
116+
105117
func (d *Node) NodeUnpublishVolume(_ context.Context, request *csi.NodeUnpublishVolumeRequest) (
106118
*csi.NodeUnpublishVolumeResponse,
107119
error,

0 commit comments

Comments
 (0)