From 9f9801a51c6177598d752a510f2df37f7de709a5 Mon Sep 17 00:00:00 2001 From: Dawid Korzepa Date: Tue, 4 Jun 2024 07:29:21 +0200 Subject: [PATCH] [ISSUE-1159]: naming refactor --- pkg/node/node.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/node/node.go b/pkg/node/node.go index 20d88a9a2..36c746522 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -153,11 +153,13 @@ func (s *CSINodeService) processFakeAttachInNodeStageVolume( ll *logrus.Entry, volumeCR *volumecrd.Volume, targetPath string, - isFakeAttachNeed bool, + isFakeAttachAnnotation bool, isFakeAttachDR bool, + isErr bool, ) error { volumeID := volumeCR.Spec.Id - if isFakeAttachNeed { + isFakeAttachNeeded := (isErr && isFakeAttachAnnotation) || isFakeAttachDR + if isFakeAttachNeeded { if volumeCR.Annotations[fakeAttachVolumeAnnotation] != fakeAttachVolumeKey { volumeCR.Annotations[fakeAttachVolumeAnnotation] = fakeAttachVolumeKey ll.Warningf("Adding fake-attach annotation to the volume with ID %s", volumeID) @@ -195,7 +197,7 @@ func (s *CSINodeService) processFakeAttachInNodeStageVolume( return nil } -// isFakeAttachNeededForDR checks if fake attach annotation is present and needed for drive replacement. +// isFakeAttachNeed checks if fake attach annotation is present and needed for drive replacement. // // Parameters: // - volumeCR: a pointer to a volumecrd.Volume object representing the volume to check. @@ -203,7 +205,7 @@ func (s *CSINodeService) processFakeAttachInNodeStageVolume( // Returns: // - bool: a boolean indicating whether fake attach annotation is present. // - bool: a boolean indicating whether fake attach is needed in DR. -func (s *CSINodeService) isFakeAttachNeededForDR(volumeCR *volumecrd.Volume) (bool, bool) { +func (s *CSINodeService) isFakeAttachNeed(volumeCR *volumecrd.Volume) (bool, bool) { fakeAttachBasic, fakeAttachDR := false, false pvc, err := s.getPVCForVolume(volumeCR.Spec.Id) @@ -296,7 +298,7 @@ func (s *CSINodeService) NodeStageVolume(ctx context.Context, req *csi.NodeStage } targetPath := getStagingPath(ll, req.GetStagingTargetPath()) - isFakeAttachAnnotation, isFakeAttachDR := s.isFakeAttachNeededForDR(volumeCR) + isFakeAttachAnnotation, isFakeAttachDR := s.isFakeAttachNeed(volumeCR) isErr := false ignoreErrorIfFakeAttach := func(err error) { isErr = true @@ -325,8 +327,9 @@ func (s *CSINodeService) NodeStageVolume(ctx context.Context, req *csi.NodeStage ll, volumeCR, targetPath, - (isErr && isFakeAttachAnnotation) || isFakeAttachDR, + isFakeAttachAnnotation, isFakeAttachDR, + isErr, ); err != nil { return nil, err }