Skip to content

Commit

Permalink
[ISSUE-1159]: naming refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
korzepadawid committed Jun 4, 2024
1 parent 128610d commit 9f9801a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -195,15 +197,15 @@ 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.
//
// 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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9f9801a

Please sign in to comment.