Skip to content

Commit

Permalink
Allow configuration of a datastore for migrated volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
gnufied committed Jan 20, 2023
1 parent d7229c9 commit b9b5b96
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/common/cns-lib/vsphere/utils.go
Expand Up @@ -212,6 +212,7 @@ func GetVirtualCenterConfig(ctx context.Context, cfg *config.Config) (*VirtualCe
VCClientTimeout: vcClientTimeout,
QueryLimit: cfg.Global.QueryLimit,
ListVolumeThreshold: cfg.Global.ListVolumeThreshold,
MigrationDataStoreURL: cfg.VirtualCenter[host].MigrationDataStoreURL,
}

log.Debugf("Setting the queryLimit = %v, ListVolumeThreshold = %v", vcConfig.QueryLimit, vcConfig.ListVolumeThreshold)
Expand Down
3 changes: 3 additions & 0 deletions pkg/common/cns-lib/vsphere/virtualcenter.go
Expand Up @@ -131,6 +131,9 @@ type VirtualCenterConfig struct {
// ListVolumeThreshold specifies the maximum number of differences in volume that
// can exist between CNS and kubernetes
ListVolumeThreshold int
// MigrationDataStore specifies datastore which is set as default datastore in legacy cloud-config
// and hence should be used as default datastore.
MigrationDataStoreURL string
}

// clientMutex is used for exclusive connection creation.
Expand Down
7 changes: 3 additions & 4 deletions pkg/common/config/types.go
Expand Up @@ -72,10 +72,6 @@ type Config struct {
// ListVolumeThreshold specifies the maximum number of differences in volume that can exist between CNS
// and kubernetes
ListVolumeThreshold int `gcfg:"list-volume-threshold"`

// MigrationDataStore specifies datastore which is set as default datastore in legacy cloud-config
// and hence should be used as default datastore.
MigrationDataStore string `gcfg:"migration-datastore"`
}

// Multiple sets of Net Permissions applied to all file shares
Expand Down Expand Up @@ -152,6 +148,9 @@ type VirtualCenterConfig struct {
TargetvSANFileShareDatastoreURLs string `gcfg:"targetvSANFileShareDatastoreURLs"`
// TargetvSANFileShareClusters represents file service enabled vSAN clusters on which file volumes can be created.
TargetvSANFileShareClusters string `gcfg:"targetvSANFileShareClusters"`
// MigrationDataStore specifies datastore which is set as default datastore in legacy cloud-config
// and hence should be used as default datastore.
MigrationDataStoreURL string `gcfg:"migration-datastore-url"`
}

// GCConfig contains information used by guest cluster to access a supervisor
Expand Down
3 changes: 3 additions & 0 deletions pkg/csi/service/vanilla/controller.go
Expand Up @@ -704,6 +704,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.InvalidArgument,
"parsing storage class parameters failed with error: %+v", err)
}

if csiMigrationFeatureState && scParams.CSIMigration == "true" {
if len(scParams.Datastore) != 0 {
log.Infof("Converting datastore name: %q to Datastore URL", scParams.Datastore)
Expand Down Expand Up @@ -747,6 +748,8 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.Internal,
"failed to find datastoreURL for datastore name: %q", scParams.Datastore)
}
} else if c.manager.VcenterConfig.MigrationDataStoreURL != "" {
scParams.DatastoreURL = c.manager.VcenterConfig.MigrationDataStoreURL
}
}

Expand Down

0 comments on commit b9b5b96

Please sign in to comment.