diff --git a/cloud/blockstore/tools/csi_driver/internal/driver/node.go b/cloud/blockstore/tools/csi_driver/internal/driver/node.go index 784a325bfc..9d2ebe3a11 100644 --- a/cloud/blockstore/tools/csi_driver/internal/driver/node.go +++ b/cloud/blockstore/tools/csi_driver/internal/driver/node.go @@ -588,81 +588,14 @@ func (s *nodeService) nodeStageDiskAsVhostSocket( return s.createDummyImgFile(endpointDir) } -func (s *nodeService) nodePublishDiskAsFilesystemDeprecated( - ctx context.Context, - req *csi.NodePublishVolumeRequest) error { - - diskId := req.VolumeId - resp, err := s.startNbsEndpointForNBD(ctx, s.getPodId(req), diskId, req.VolumeContext) - if err != nil { - return fmt.Errorf("failed to start NBS endpoint: %w", err) - } - - if resp.NbdDeviceFile == "" { - return fmt.Errorf("NbdDeviceFile shouldn't be empty") - } - - logVolume(req.VolumeId, "endpoint started with device: %q", resp.NbdDeviceFile) - - mnt := req.VolumeCapability.GetMount() - - fsType := req.VolumeContext["fsType"] - if mnt != nil && mnt.FsType != "" { - fsType = mnt.FsType - } - if fsType == "" { - fsType = "ext4" - } - - err = s.makeFilesystemIfNeeded(diskId, resp.NbdDeviceFile, fsType) - if err != nil { - return err - } - - mounted, _ := s.mounter.IsMountPoint(req.TargetPath) - if !mounted { - targetPerm := os.FileMode(0775) - if err := os.MkdirAll(req.TargetPath, targetPerm); err != nil { - return fmt.Errorf("failed to create target directory: %w", err) - } - - if err := os.Chmod(req.TargetPath, targetPerm); err != nil { - return fmt.Errorf("failed to chmod target path: %w", err) - } - } - - mountOptions := []string{} - if mnt != nil { - for _, flag := range mnt.MountFlags { - mountOptions = append(mountOptions, flag) - } - } - if req.Readonly { - mountOptions = append(mountOptions, "ro") - } - - err = s.mountIfNeeded( - diskId, - resp.NbdDeviceFile, - req.TargetPath, - fsType, - mountOptions) - if err != nil { - return err - } - - return nil -} - func (s *nodeService) nodePublishDiskAsFilesystem( ctx context.Context, req *csi.NodePublishVolumeRequest) error { - // Fallback to previous implementation for already mounted volumes - // Must be removed after migration of all endpoints to the new format mounted, _ := s.mounter.IsMountPoint(req.StagingTargetPath) if !mounted { - return s.nodePublishDiskAsFilesystemDeprecated(ctx, req) + return s.statusErrorf(codes.FailedPrecondition, + "Staging target path is not mounted: %w", req.VolumeId) } mounted, _ = s.mounter.IsMountPoint(req.TargetPath) @@ -748,15 +681,6 @@ func (s *nodeService) nodeStageDiskAsFilesystem( diskId := req.VolumeId resp, err := s.startNbsEndpointForNBD(ctx, "", diskId, req.VolumeContext) if err != nil { - if s.IsMountConflictError(err) { - localEndpoint, err := s.hasLocalEndpoint(ctx, diskId) - if err != nil { - return err - } - if localEndpoint { - return nil - } - } return fmt.Errorf("failed to start NBS endpoint: %w", err) }