Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry pick the unlink fset changes in release 2.10.6 #1268

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion driver/csiplugin/connectors/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type SpectrumScaleConnector interface {
DeleteFileset(ctx context.Context, filesystemName string, filesetName string) error
//LinkFileset(filesystemName string, filesetName string) error
LinkFileset(ctx context.Context, filesystemName string, filesetName string, linkpath string) error
UnlinkFileset(ctx context.Context, filesystemName string, filesetName string) error
UnlinkFileset(ctx context.Context, filesystemName string, filesetName string, force bool) error
//ListFilesets(filesystemName string) ([]resources.Volume, error)
ListFileset(ctx context.Context, filesystemName string, filesetName string) (Fileset_v2, error)
ListCSIIndependentFilesets(ctx context.Context, filesystemName string) ([]Fileset_v2, error)
Expand Down
13 changes: 9 additions & 4 deletions driver/csiplugin/connectors/rest_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

const errConnectionRefused string = "connection refused"
const errNoSuchHost string = "no such host"
const errContextDeadlineExceeded string = "context deadline exceeded"
const errContextDeadlineExceeded string = "context deadline exceeded"

var GetLoggerId = utils.GetLoggerId

Expand Down Expand Up @@ -657,10 +657,15 @@ func (s *SpectrumRestV2) LinkFileset(ctx context.Context, filesystemName string,
return nil
}

func (s *SpectrumRestV2) UnlinkFileset(ctx context.Context, filesystemName string, filesetName string) error {
func (s *SpectrumRestV2) UnlinkFileset(ctx context.Context, filesystemName string, filesetName string, force bool) error {
klog.V(4).Infof("[%s] rest_v2 UnlinkFileset. filesystem: %s, fileset: %s", utils.GetLoggerId(ctx), filesystemName, filesetName)

unlinkFilesetURL := fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/link?force=True", filesystemName, filesetName)
var unlinkFilesetURL string
if force {
unlinkFilesetURL = fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/link?force=True", filesystemName, filesetName)
} else {
unlinkFilesetURL = fmt.Sprintf("scalemgmt/v2/filesystems/%s/filesets/%s/link", filesystemName, filesetName)
}
unlinkFilesetResponse := GenericResponse{}

err := s.doHTTP(ctx, unlinkFilesetURL, "DELETE", &unlinkFilesetResponse, nil)
Expand Down Expand Up @@ -1039,7 +1044,7 @@ func (s *SpectrumRestV2) doHTTP(ctx context.Context, urlSuffix string, method st

activeEndpointFound := false
if err != nil {
if strings.Contains(err.Error(), errConnectionRefused) || strings.Contains(err.Error(), errNoSuchHost) || strings.Contains(err.Error(), errContextDeadlineExceeded){
if strings.Contains(err.Error(), errConnectionRefused) || strings.Contains(err.Error(), errNoSuchHost) || strings.Contains(err.Error(), errContextDeadlineExceeded) {
klog.Errorf("[%s] rest_v2 doHTTP: Error in connecting to GUI endpoint %s: %v, checking next endpoint", utils.GetLoggerId(ctx), endpoint, err)
// Out of n endpoints, one has failed already, so loop over the
// remaining n-1 endpoints till we get an active GUI endpoint.
Expand Down
16 changes: 15 additions & 1 deletion driver/csiplugin/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const (

discoverCGFileset = "DISCOVER_CG_FILESET"
discoverCGFilesetDisabled = "DISABLED"

fsetLinkNotFoundErrCode = "EFSSG0449C"
fsetLinkNotFoundErrMsg = "is not linked"
)

type ScaleControllerServer struct {
Expand Down Expand Up @@ -1648,7 +1651,18 @@ func (cs *ScaleControllerServer) DeleteFilesetVol(ctx context.Context, Filesyste
klog.Infof("[%s] there is no snapshot present in the fileset [%v], continue DeleteFilesetVol", loggerId, FilesetName)
}

err := conn.DeleteFileset(ctx, FilesystemName, FilesetName)
err := conn.UnlinkFileset(ctx, FilesystemName, FilesetName, false)
if err != nil {
if strings.Contains(err.Error(), fsetLinkNotFoundErrCode) ||
strings.Contains(err.Error(), fsetLinkNotFoundErrMsg) { // fileset seems to be already unlinked
klog.V(4).Infof("[%s] fileset seems to be already unlinked - %v", loggerId, err)
//return true, nil
} else {
return false, status.Error(codes.Internal, fmt.Sprintf("unable to unlink Fileset [%v] for FS [%v] and clusterId [%v].Error : [%v]", FilesetName, FilesystemName, volumeIdMembers.ClusterId, err))
}
}

err = conn.DeleteFileset(ctx, FilesystemName, FilesetName)
if err != nil {
if strings.Contains(err.Error(), "EFSSG0072C") ||
strings.Contains(err.Error(), "400 Invalid value in 'filesetName'") { // fileset is already deleted
Expand Down