diff --git a/cmd/main.go b/cmd/main.go index c7dd6faf..7e793393 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -49,10 +49,11 @@ func init() { } var ( - endpoint = flag.String("endpoint", "unix:/tmp/csi.sock", "CSI endpoint") - metricsAddress = flag.String("metrics-address", "0.0.0.0:9080", "Metrics address") - vendorVersion string - logger *zap.Logger + endpoint = flag.String("endpoint", "unix:/tmp/csi.sock", "CSI endpoint") + metricsAddress = flag.String("metrics-address", "0.0.0.0:9080", "Metrics address") + extraVolumeLabelsStr = flag.String("extra-labels", "", "Extra labels to tag all volumes created by driver. It is a comma separated list of key value pairs like ':,:'.") + vendorVersion string + logger *zap.Logger ) const ( @@ -91,7 +92,7 @@ func handle(logger *zap.Logger) { logger.Info("Controller Mutex Lock enabled", zap.Bool("LockEnabled", *utils.LockEnabled)) // Setup Cloud Provider configPath := filepath.Join(config.GetConfPathDir(), configFileName) - ibmcloudProvider, err := cloudProvider.NewIBMCloudStorageProvider(configPath, logger) + ibmcloudProvider, err := cloudProvider.NewIBMCloudStorageProvider(configPath, *extraVolumeLabelsStr, logger) if err != nil { logger.Fatal("Failed to instantiate IKS-Storage provider", zap.Error(err)) } diff --git a/go.mod b/go.mod index 3775703f..ef260c18 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/kubernetes-sigs/ibm-vpc-block-csi-driver go 1.16 require ( - github.com/IBM/ibm-csi-common v1.0.1-beta5 - github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4 - github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5 + github.com/IBM/ibm-csi-common v1.0.1-beta7 + github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5 + github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7 github.com/container-storage-interface/spec v1.5.0 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/google/uuid v1.1.2 diff --git a/go.sum b/go.sum index 555a5ec4..5f91c064 100644 --- a/go.sum +++ b/go.sum @@ -55,12 +55,12 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7 h1:eHgfQl6IeSmzWUyiSi13CvoFYsovoyq github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs= github.com/IBM/go-sdk-core/v5 v5.9.1 h1:06pXbD9Rgmqqe2HA5YAeQbB4eYRRFgIoOT+Kh3cp1zo= github.com/IBM/go-sdk-core/v5 v5.9.1/go.mod h1:axE2JrRq79gIJTjKPBwV6gWHswvVptBjbcvvCPIxARM= -github.com/IBM/ibm-csi-common v1.0.1-beta5 h1:QjgaIDPa1OPQXetDh+ZbgnboR06s8Ybmwo+ZJZscVDM= -github.com/IBM/ibm-csi-common v1.0.1-beta5/go.mod h1:wRzyBmb6yGf3d1TTcrIt9xlLK6NK3QWNOd9KzRG1/pU= -github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4 h1:h5vUOeIitxpLTV/iD6F8OvuxHvvHoMDaZu3VXcUMfjw= -github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4/go.mod h1:v1aT8G3Tib8pCwdr9VweNFYa94GejBuqIVTysoaVI0g= -github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5 h1:FJk99J6Bk5WFI/EOmlVtxX2JXJMURlkezPJLjvS6+A0= -github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5/go.mod h1:nB0Pk0f7Prvl99DtQRUfpkQdAzFXv34Dd1lkCQrlJyQ= +github.com/IBM/ibm-csi-common v1.0.1-beta7 h1:phljcQfBBKtG6F2Q/hiqayrWJC+w0EtNvUWCXGsiox0= +github.com/IBM/ibm-csi-common v1.0.1-beta7/go.mod h1:k6IHdSHGnsnGOxzqir3n9kczW+ttL+KcRZh/chLyyuk= +github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5 h1:XPNIrp4g7oEx7QOy6eB98jZs7n1tB6DTsUjEigOhouM= +github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5/go.mod h1:v1aT8G3Tib8pCwdr9VweNFYa94GejBuqIVTysoaVI0g= +github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7 h1:3cQCvlTx9fQhBDYm2bn51nebRrLgZGwfAzLu7Zp/gvc= +github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7/go.mod h1:CFBvpt4SKwf0mQg3u53qkZ5SxZH9gZSfdhWBa8GIP3Y= github.com/IBM/secret-common-lib v1.0.3 h1:rhhAtAE1ANSuxhA8Nulzzc2IbXWHGE8reoRSr98rRi8= github.com/IBM/secret-common-lib v1.0.3/go.mod h1:uoYY5M9G1nJVT8ytPIicdTUujcBXKldBw7ijWolU0yU= github.com/IBM/secret-utils-lib v1.0.2 h1:AdhKHo/bMmFLMz7+ZjnqSUHuU22CMQsG5meddvwKaV8= diff --git a/vendor/github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider/volume_provider.go b/vendor/github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider/volume_provider.go index ba8bc522..0d01f88f 100644 --- a/vendor/github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider/volume_provider.go +++ b/vendor/github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider/volume_provider.go @@ -45,7 +45,7 @@ type IBMCloudStorageProvider struct { var _ CloudProviderInterface = &IBMCloudStorageProvider{} // NewIBMCloudStorageProvider ... -func NewIBMCloudStorageProvider(configPath string, logger *zap.Logger) (*IBMCloudStorageProvider, error) { +func NewIBMCloudStorageProvider(configPath string, clusterVolumeLabel string, logger *zap.Logger) (*IBMCloudStorageProvider, error) { logger.Info("NewIBMCloudStorageProvider-Reading provider configuration...") // Load config file conf, err := config.ReadConfig(configPath, logger) @@ -80,6 +80,9 @@ func NewIBMCloudStorageProvider(configPath string, logger *zap.Logger) (*IBMClou logger.Info("Fetched clusterInfo..") } + //Initialize the clusterVolumeLabel once which will be used for tagging by the library. + conf.VPC.ClusterVolumeLabel = clusterVolumeLabel + // Update the CSRF Token if conf.Bluemix.PrivateAPIRoute != "" { conf.Bluemix.CSRFToken = string([]byte{}) // TODO~ Need to remove it diff --git a/vendor/github.com/IBM/ibmcloud-volume-interface/config/config.go b/vendor/github.com/IBM/ibmcloud-volume-interface/config/config.go index 0c80a3a2..046e0973 100644 --- a/vendor/github.com/IBM/ibmcloud-volume-interface/config/config.go +++ b/vendor/github.com/IBM/ibmcloud-volume-interface/config/config.go @@ -182,7 +182,8 @@ type VPCProviderConfig struct { // IKSTokenExchangePrivateURL, for private cluster support hence using for all cluster types IKSTokenExchangePrivateURL string `toml:"iks_token_exchange_endpoint_private_url"` - IsIKS bool `toml:"is_iks,omitempty"` + IsIKS bool `toml:"is_iks,omitempty"` + ClusterVolumeLabel string } //IKSConfig config diff --git a/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/create_volume.go b/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/create_volume.go index d1358a96..f26e35da 100644 --- a/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/create_volume.go +++ b/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/create_volume.go @@ -39,7 +39,7 @@ func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeRespo defer metrics.UpdateDurationFromStart(vpcs.Logger, "CreateVolume", time.Now()) vpcs.Logger.Info("Basic validation for CreateVolume request... ", zap.Reflect("RequestedVolumeDetails", volumeRequest)) - resourceGroup, iops, err := validateVolumeRequest(volumeRequest) + resourceGroup, iops, err := validateVolumeRequest(&volumeRequest, vpcs.Config.VPCConfig.ClusterVolumeLabel) if err != nil { return nil, err } @@ -50,6 +50,7 @@ func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeRespo Name: *volumeRequest.Name, Capacity: int64(*volumeRequest.Capacity), Iops: iops, + UserTags: volumeRequest.VPCVolume.Tags, ResourceGroup: &resourceGroup, Profile: &models.Profile{ Name: volumeRequest.VPCVolume.Profile.Name, @@ -99,7 +100,7 @@ func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeRespo } // validateVolumeRequest validating volume request -func validateVolumeRequest(volumeRequest provider.Volume) (models.ResourceGroup, int64, error) { +func validateVolumeRequest(volumeRequest *provider.Volume, clusterVolumeLabel string) (models.ResourceGroup, int64, error) { resourceGroup := models.ResourceGroup{} var iops int64 iops = 0 @@ -145,5 +146,11 @@ func validateVolumeRequest(volumeRequest provider.Volume) (models.ResourceGroup, // get the resource group ID from resource group name as Name is not supported by RIaaS resourceGroup.Name = volumeRequest.VPCVolume.ResourceGroup.Name } + + //Append the clusterVolumeLabel to existing tag list only if it is non-empty + if len(clusterVolumeLabel) != 0 { + volumeRequest.VPCVolume.Tags = append(volumeRequest.VPCVolume.Tags, clusterVolumeLabel) + } + return resourceGroup, iops, nil } diff --git a/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/util.go b/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/util.go index aa9d99de..c12555f1 100644 --- a/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/util.go +++ b/vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/util.go @@ -270,6 +270,7 @@ func FromProviderToLibVolume(vpcVolume *models.Volume, logger *zap.Logger) (libV libVolume.Az = vpcVolume.Zone.Name } libVolume.CRN = vpcVolume.CRN + libVolume.Tags = vpcVolume.UserTags return } diff --git a/vendor/github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/models/volume.go b/vendor/github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/models/volume.go index 2d404478..fcd24239 100644 --- a/vendor/github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/models/volume.go +++ b/vendor/github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/models/volume.go @@ -40,7 +40,8 @@ type Volume struct { Iops int64 `json:"iops,omitempty"` VolumeEncryptionKey *VolumeEncryptionKey `json:"encryption_key,omitempty"` ResourceGroup *ResourceGroup `json:"resource_group,omitempty"` - Tags []string `json:"tags,omitempty"` + Tags []string `json:"tags,omitempty"` //We need to validate and remove this if not required. + UserTags []string `json:"user_tags,omitempty"` Profile *Profile `json:"profile,omitempty"` Snapshot *Snapshot `json:"snapshot,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 7ab9a2f4..8061b0ed 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -5,7 +5,7 @@ github.com/BurntSushi/toml/internal github.com/IBM-Cloud/ibm-cloud-cli-sdk/common/rest # github.com/IBM/go-sdk-core/v5 v5.9.1 github.com/IBM/go-sdk-core/v5/core -# github.com/IBM/ibm-csi-common v1.0.1-beta5 +# github.com/IBM/ibm-csi-common v1.0.1-beta7 ## explicit github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider github.com/IBM/ibm-csi-common/pkg/messages @@ -14,7 +14,7 @@ github.com/IBM/ibm-csi-common/pkg/metrics github.com/IBM/ibm-csi-common/pkg/mountmanager github.com/IBM/ibm-csi-common/pkg/utils github.com/IBM/ibm-csi-common/pkg/watcher -# github.com/IBM/ibmcloud-volume-interface v1.0.1-beta4 +# github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5 ## explicit github.com/IBM/ibmcloud-volume-interface/config github.com/IBM/ibmcloud-volume-interface/lib/metrics @@ -25,7 +25,7 @@ github.com/IBM/ibmcloud-volume-interface/lib/utils/reasoncode github.com/IBM/ibmcloud-volume-interface/provider/auth github.com/IBM/ibmcloud-volume-interface/provider/iam github.com/IBM/ibmcloud-volume-interface/provider/local -# github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta5 +# github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7 ## explicit github.com/IBM/ibmcloud-volume-vpc/block/provider github.com/IBM/ibmcloud-volume-vpc/block/utils