Skip to content

Commit 856e115

Browse files
committed
resolve comments partially
1 parent 48e275d commit 856e115

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

cmd/sidecar_mounter/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func main() {
5757
ctx, cancel := context.WithCancel(context.Background())
5858

5959
flagsFromDriver := map[string]string{}
60-
defaultingFlagFilePath := *volumeBasePath + driver.FlagFileForDefaultingPath
61-
klog.Infof("Checking if defaulting-flag file exists: %v", defaultingFlagFilePath)
60+
defaultingFlagFilePath := *volumeBasePath + "/" + driver.FlagFileForDefaultingPath
61+
klog.Infof("Checking if defaulting-flag file %q exists", defaultingFlagFilePath)
6262
if _, err := os.Stat(defaultingFlagFilePath); err == nil {
6363
machineTypeBytes, err := os.ReadFile(defaultingFlagFilePath)
6464
if err != nil {

pkg/csi_driver/node.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,18 @@ func (s *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublish
184184
}
185185

186186
// Only pass mountOptions flags for defaulting if sidecar container is managed and satisifies min version requirement
187-
if s.shouldPassDefaultingFlags(pod) {
188-
shouldDisableAutoConfig := s.driver.config.DisableAutoconfig
189-
machineType, ok := node.Labels[clientset.MachineTypeKey]
190-
if ok {
191-
flagMap := map[string]string{"machine-type": machineType, "disable-autoconfig": strconv.FormatBool(shouldDisableAutoConfig)}
192-
if err := PutFlagsFromDriverToTargetPath(flagMap, targetPath, FlagFileForDefaultingPath); err != nil {
193-
return nil, status.Error(codes.Internal, err.Error())
194-
}
195-
} else {
196-
klog.Warningf("Unable to fetch target node %v's machine type", node.Name)
187+
// if s.shouldPassDefaultingFlags(pod) {
188+
shouldDisableAutoConfig := s.driver.config.DisableAutoconfig
189+
machineType, ok := node.Labels[clientset.MachineTypeKey]
190+
if ok {
191+
flagMap := map[string]string{"machine-type": machineType, "disable-autoconfig": strconv.FormatBool(shouldDisableAutoConfig)}
192+
if err := PutFlagsFromDriverToTargetPath(flagMap, targetPath, FlagFileForDefaultingPath); err != nil {
193+
return nil, status.Error(codes.Internal, err.Error())
197194
}
195+
} else {
196+
klog.Warningf("Unable to fetch target node %v's machine type", node.Name)
198197
}
198+
// }
199199

200200
// Check if there is any error from the gcsfuse
201201
code, err := checkGcsFuseErr(isInitContainer, pod, targetPath)

pkg/csi_driver/utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const (
6868
tokenServerSidecarMinVersion = "v1.12.2-gke.0" // #nosec G101
6969
// TODO: Update with actual minimum sidecar version after the first feature release
7070
AutoconfigDefaultingSidecarMinVersion = "v1.99.0-gke.0"
71-
FlagFileForDefaultingPath = "/flags-for-defaulting"
71+
FlagFileForDefaultingPath = "flags-for-defaulting"
7272
)
7373

7474
var volumeIDRegEx = regexp.MustCompile(`:.*$`)
@@ -504,8 +504,8 @@ func PutFlagsFromDriverToTargetPath(flagMap map[string]string, targetPath string
504504
return fmt.Errorf("failed to get emptyDir path: %w", err)
505505
}
506506

507-
absolutePath := filepath.Dir(emptyDirBasePath) + fileName
508-
klog.V(4).Infof("Writing flags needed for gcsfuse defaulting logic to file %v: %v", absolutePath, flagMap)
507+
absolutePath := filepath.Dir(emptyDirBasePath) + "/" + fileName
508+
klog.V(4).Infof("Writing flags needed for gcsfuse defaulting logic to file %q: %v", absolutePath, flagMap)
509509

510510
f, err := os.Create(absolutePath)
511511
if err != nil {

test/e2e/specs/specs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ func (t *TestPod) VerifyDefaultingFlagsArePassed(namespace string, expectedMachi
12591259
expectedMachineTypeFlagString := fmt.Sprintf(`"MachineType":"%s"`, expectedMachineTypeFlag)
12601260

12611261
gomega.Expect(stdout).To(gomega.ContainSubstring(expectedDisableAutoconfigFlagString),
1262-
"Should find DisableAutoconfig flag string %q in stdout:\n%s", expectedDisableAutoconfigFlagString, stdout)
1262+
"Should find DisableAutoconfig flag string %q in stdout", expectedDisableAutoconfigFlagString)
12631263
gomega.Expect(stdout).To(gomega.ContainSubstring(expectedMachineTypeFlagString),
1264-
"Should find MachineType flag string %q in stdout:\n%s", expectedMachineTypeFlagString, stdout)
1264+
"Should find MachineType flag string %q in stdout", expectedMachineTypeFlagString)
12651265
}

0 commit comments

Comments
 (0)