diff --git a/cmd/oci-csi-controller-driver/csioptions/csioptions.go b/cmd/oci-csi-controller-driver/csioptions/csioptions.go index 6e478a19c1..0f0934f112 100644 --- a/cmd/oci-csi-controller-driver/csioptions/csioptions.go +++ b/cmd/oci-csi-controller-driver/csioptions/csioptions.go @@ -26,75 +26,73 @@ const ( fssAddressSuffix = "-fss.sock" fssVolumeNameAppendedPrefix = "-fss" CrossNamespaceVolumeDataSource = "CrossNamespaceVolumeDataSource" - VolumeAttributesClass = "VolumeAttributesClass" + VolumeAttributesClass = "VolumeAttributesClass" ) // CSIOptions structure which contains flag values type CSIOptions struct { - Master string - Kubeconfig string - CsiAddress string - Endpoint string - FssCsiAddress string - FssEndpoint string - VolumeNamePrefix string - FssVolumeNamePrefix string - VolumeNameUUIDLength int - ShowVersion bool - RetryIntervalStart time.Duration - RetryIntervalMax time.Duration - WorkerThreads uint - OperationTimeout time.Duration - EnableLeaderElection bool - LeaderElectionType string - LeaderElectionNamespace string - StrictTopology bool - Resync time.Duration - Timeout time.Duration - FeatureGates map[string]bool - FinalizerThreads uint - MetricsAddress string - MetricsPath string - ExtraCreateMetadata bool - ReconcileSync time.Duration - EnableResizer bool - GroupSnapshotNamePrefix string + Master string + Kubeconfig string + CsiAddress string + Endpoint string + FssCsiAddress string + FssEndpoint string + VolumeNamePrefix string + FssVolumeNamePrefix string + VolumeNameUUIDLength int + ShowVersion bool + RetryIntervalStart time.Duration + RetryIntervalMax time.Duration + WorkerThreads uint + OperationTimeout time.Duration + EnableLeaderElection bool + LeaderElectionType string + LeaderElectionNamespace string + StrictTopology bool + Resync time.Duration + Timeout time.Duration + FeatureGates map[string]bool + FinalizerThreads uint + MetricsAddress string + MetricsPath string + ExtraCreateMetadata bool + ReconcileSync time.Duration + EnableResizer bool + GroupSnapshotNamePrefix string GroupSnapshotNameUUIDLength int - } // NewCSIOptions initializes the flag func NewCSIOptions() *CSIOptions { csioptions := CSIOptions{ - Master: *flag.String("master", "", "kube master"), - Kubeconfig: *flag.String("kubeconfig", "", "cluster kube config"), - CsiAddress: *flag.String("csi-address", "/run/csi/socket", "Address of the CSI BV driver socket."), - Endpoint: *flag.String("csi-endpoint", "unix://tmp/csi.sock", "CSI BV endpoint"), - FssCsiAddress: *flag.String("fss-csi-address", "/run/fss/socket", "Address of the CSI FSS driver socket."), - FssEndpoint: *flag.String("fss-csi-endpoint", "unix://tmp/csi-fss.sock", "CSI FSS endpoint"), - VolumeNamePrefix: *flag.String("csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume."), - FssVolumeNamePrefix: *flag.String("fss-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for FSS."), - VolumeNameUUIDLength: *flag.Int("csi-volume-name-uuid-length", -1, "Truncates generated UUID of a created volume to this length. Defaults behavior is to NOT truncate."), - ShowVersion: *flag.Bool("csi-version", false, "Show version."), - RetryIntervalStart: *flag.Duration("csi-retry-interval-start", time.Second, "Initial retry interval of failed provisioning or deletion. It doubles with each failure, up to retry-interval-max."), - RetryIntervalMax: *flag.Duration("csi-retry-interval-max", 5*time.Minute, "Maximum retry interval of failed provisioning or deletion."), - WorkerThreads: *flag.Uint("csi-worker-threads", 100, "Number of provisioner worker threads, in other words nr. of simultaneous CSI calls."), - OperationTimeout: *flag.Duration("csi-op-timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume"), - EnableLeaderElection: *flag.Bool("csi-enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules."), - LeaderElectionType: *flag.String("csi-leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'."), - LeaderElectionNamespace: *flag.String("csi-leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set."), - StrictTopology: *flag.Bool("csi-strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node."), - Resync: *flag.Duration("csi-resync", 10*time.Minute, "Resync interval of the controller."), - Timeout: *flag.Duration("csi-timeout", 15*time.Second, "Timeout for waiting for attaching or detaching the volume."), - FinalizerThreads: *flag.Uint("cloning-protection-threads", 1, "Number of simultaniously running threads, handling cloning finalizer removal"), - MetricsAddress: *flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled."), - MetricsPath: *flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`."), - ExtraCreateMetadata: *flag.Bool("extra-create-metadata", false, "If set, add pv/pvc metadata to plugin create requests as parameters."), - ReconcileSync: *flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler."), - EnableResizer: *flag.Bool("csi-bv-expansion-enabled", false, "Enables go routine csi-resizer."), - GroupSnapshotNamePrefix: *flag.String("groupsnapshot-name-prefix", "groupsnapshot", "Prefix to apply to the name of a created group snapshot"), + Master: *flag.String("master", "", "kube master"), + Kubeconfig: *flag.String("kubeconfig", "", "cluster kube config"), + CsiAddress: *flag.String("csi-address", "/run/csi/socket", "Address of the CSI BV driver socket."), + Endpoint: *flag.String("csi-endpoint", "unix://tmp/csi.sock", "CSI BV endpoint"), + FssCsiAddress: *flag.String("fss-csi-address", "/run/fss/socket", "Address of the CSI FSS driver socket."), + FssEndpoint: *flag.String("fss-csi-endpoint", "unix://tmp/csi-fss.sock", "CSI FSS endpoint"), + VolumeNamePrefix: *flag.String("csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume."), + FssVolumeNamePrefix: *flag.String("fss-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for FSS."), + VolumeNameUUIDLength: *flag.Int("csi-volume-name-uuid-length", -1, "Truncates generated UUID of a created volume to this length. Defaults behavior is to NOT truncate."), + ShowVersion: *flag.Bool("csi-version", false, "Show version."), + RetryIntervalStart: *flag.Duration("csi-retry-interval-start", time.Second, "Initial retry interval of failed provisioning or deletion. It doubles with each failure, up to retry-interval-max."), + RetryIntervalMax: *flag.Duration("csi-retry-interval-max", 5*time.Minute, "Maximum retry interval of failed provisioning or deletion."), + WorkerThreads: *flag.Uint("csi-worker-threads", 100, "Number of provisioner worker threads, in other words nr. of simultaneous CSI calls."), + OperationTimeout: *flag.Duration("csi-op-timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume"), + EnableLeaderElection: *flag.Bool("csi-enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules."), + LeaderElectionType: *flag.String("csi-leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'."), + LeaderElectionNamespace: *flag.String("csi-leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set."), + StrictTopology: *flag.Bool("csi-strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node."), + Resync: *flag.Duration("csi-resync", 10*time.Minute, "Resync interval of the controller."), + Timeout: *flag.Duration("csi-timeout", 15*time.Second, "Timeout for waiting for attaching or detaching the volume."), + FinalizerThreads: *flag.Uint("cloning-protection-threads", 1, "Number of simultaniously running threads, handling cloning finalizer removal"), + MetricsAddress: *flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled."), + MetricsPath: *flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`."), + ExtraCreateMetadata: *flag.Bool("extra-create-metadata", false, "If set, add pv/pvc metadata to plugin create requests as parameters."), + ReconcileSync: *flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler."), + EnableResizer: *flag.Bool("csi-bv-expansion-enabled", false, "Enables go routine csi-resizer."), + GroupSnapshotNamePrefix: *flag.String("groupsnapshot-name-prefix", "groupsnapshot", "Prefix to apply to the name of a created group snapshot"), GroupSnapshotNameUUIDLength: *flag.Int("groupsnapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created group snapshot. Defaults behavior is to NOT truncate."), - } return &csioptions } diff --git a/cmd/oci-csi-node-driver/nodedriver/nodedriver.go b/cmd/oci-csi-node-driver/nodedriver/nodedriver.go index 65570cd88b..61a581fe91 100644 --- a/cmd/oci-csi-node-driver/nodedriver/nodedriver.go +++ b/cmd/oci-csi-node-driver/nodedriver/nodedriver.go @@ -21,7 +21,7 @@ import ( "go.uber.org/zap" ) -//RunNodeDriver main function to start node driver +// RunNodeDriver main function to start node driver func RunNodeDriver(nodeOptions nodedriveroptions.NodeOptions, stopCh <-chan struct{}) error { logger := logging.Logger().Sugar() logger.Sync() diff --git a/cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go b/cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go index 8d7b1856db..e6bdbefe02 100644 --- a/cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go +++ b/cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go @@ -14,7 +14,7 @@ package nodedriveroptions -//NodeCSIOptions contains details about the flag +// NodeCSIOptions contains details about the flag type NodeCSIOptions struct { Endpoint string // Used for Block Volume CSI driver NodeID string @@ -22,8 +22,8 @@ type NodeCSIOptions struct { Master string Kubeconfig string - EnableFssDriver bool - FssEndpoint string + EnableFssDriver bool + FssEndpoint string LustreCsiAddress string LustreKubeletRegistrationPath string LustreEndpoint string diff --git a/pkg/cloudprovider/providers/oci/load_balancer_util_test.go b/pkg/cloudprovider/providers/oci/load_balancer_util_test.go index 034abc9b88..1f0bcade0f 100644 --- a/pkg/cloudprovider/providers/oci/load_balancer_util_test.go +++ b/pkg/cloudprovider/providers/oci/load_balancer_util_test.go @@ -25,9 +25,9 @@ import ( api "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/oracle/oci-cloud-controller-manager/pkg/oci/client" "github.com/oracle/oci-go-sdk/v65/common" "github.com/oracle/oci-go-sdk/v65/loadbalancer" - "github.com/oracle/oci-cloud-controller-manager/pkg/oci/client" "github.com/stretchr/testify/assert" ) diff --git a/pkg/csi-util/lustre_lnet_helper.go b/pkg/csi-util/lustre_lnet_helper.go index 4642e6d2cc..311348ee29 100644 --- a/pkg/csi-util/lustre_lnet_helper.go +++ b/pkg/csi-util/lustre_lnet_helper.go @@ -42,7 +42,8 @@ type Parameter map[string]interface{} /* ValidateLustreVolumeId takes lustreVolumeId as input and returns if its valid or not along with lnetLabel Ex. volume handle : 10.112.10.6@tcp1:/fsname - volume handle : [:]:/ + + volume handle : [:]:/ */ func ValidateLustreVolumeId(lusterVolumeId string) (bool, string) { const minNumOfParamsFromVolumeHandle = 2 @@ -91,9 +92,9 @@ type LnetService struct { type OCILnetConfigurator struct{} -func NewLnetService() *LnetService{ +func NewLnetService() *LnetService { return &LnetService{ - Configurator: &OCILnetConfigurator{}, + Configurator: &OCILnetConfigurator{}, } } @@ -331,7 +332,7 @@ func (ls *LnetService) IsLnetActive(logger *zap.SugaredLogger, lnetLabel string) } func (olc *OCILnetConfigurator) ExecuteCommandOnWorkerNode(args ...string) (string, error) { - + command := exec.Command("chroot-bash", args...) output, err := command.CombinedOutput() @@ -374,7 +375,7 @@ func isValidShellInput(input string) bool { return false } // List of forbidden characters - forbiddenChars := []string{";", "&", "|", "<", ">", "(", ")", "`", "'", "\"","$","!"} + forbiddenChars := []string{";", "&", "|", "<", ">", "(", ")", "`", "'", "\"", "$", "!"} for _, char := range forbiddenChars { if strings.Contains(input, char) { return false @@ -382,7 +383,7 @@ func isValidShellInput(input string) bool { } return true } -func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error { +func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error { if lustreParamsJson == "" { logger.Debug("No lustre parameters specified.") return nil @@ -401,7 +402,7 @@ func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson strin for key, value := range param { logger.Infof("Validating lustre param %s=%s", key, fmt.Sprintf("%v", value)) if !isValidShellInput(key) || !isValidShellInput(fmt.Sprintf("%v", value)) { - invalidParams = append(invalidParams, fmt.Sprintf("%v=%v",key, value)) + invalidParams = append(invalidParams, fmt.Sprintf("%v=%v", key, value)) } } } @@ -411,4 +412,3 @@ func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson strin logger.Infof("Successfully validated lustre parameters.") return nil } - diff --git a/pkg/csi-util/utils.go b/pkg/csi-util/utils.go index 3aed4ad309..51e550d7f8 100644 --- a/pkg/csi-util/utils.go +++ b/pkg/csi-util/utils.go @@ -87,7 +87,6 @@ const ( RawBlockStagingFile = "mountfile" AvailabilityDomainLabel = "csi-ipv6-full-ad-name" - ) // Util interface @@ -117,15 +116,14 @@ type NodeMetadata struct { // CSIConfig represents the structure of the ConfigMap data. type CSIConfig struct { - Lustre *DriverConfig `yaml:"lustre"` + Lustre *DriverConfig `yaml:"lustre"` IsLoaded bool } // DriverConfig represents driver-specific configurations. type DriverConfig struct { - SkipNodeUnstage bool `yaml:"skipNodeUnstage"` + SkipNodeUnstage bool `yaml:"skipNodeUnstage"` SkipLustreParameters bool `yaml:"skipLustreParameters"` - } func (u *Util) LookupNodeID(k kubernetes.Interface, nodeName string) (string, error) { @@ -144,14 +142,14 @@ func (u *Util) LookupNodeID(k kubernetes.Interface, nodeName string) (string, er func (u *Util) WaitForKubeApiServerToBeReachableWithContext(ctx context.Context, k kubernetes.Interface, backOffCap time.Duration) { - waitForKubeApiServerCtx, waitForKubeApiServerCtxCancel := context.WithTimeout(ctx, time.Second * 45) + waitForKubeApiServerCtx, waitForKubeApiServerCtxCancel := context.WithTimeout(ctx, time.Second*45) defer waitForKubeApiServerCtxCancel() backoff := wait.Backoff{ Duration: 1 * time.Second, Factor: 2.0, Steps: 5, - Cap: backOffCap, + Cap: backOffCap, } wait.ExponentialBackoffWithContext( @@ -171,9 +169,9 @@ func (u *Util) WaitForKubeApiServerToBeReachableWithContext(ctx context.Context, ) } -func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.Interface, nodeID string, nodeMetadata *NodeMetadata) (error) { +func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.Interface, nodeID string, nodeMetadata *NodeMetadata) error { - u.WaitForKubeApiServerToBeReachableWithContext(ctx, k, time.Second * 30) + u.WaitForKubeApiServerToBeReachableWithContext(ctx, k, time.Second*30) node, err := k.CoreV1().Nodes().Get(ctx, nodeID, metav1.GetOptions{}) @@ -210,7 +208,7 @@ func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.I u.Logger.With("nodeId", nodeID, "nodeMetadata", nodeMetadata).Info("Node IP family identified.") } nodeMetadata.IsNodeMetadataLoaded = true - return nil + return nil } // waitForPathToExist waits for for a given filesystem path to exist. @@ -652,7 +650,7 @@ func LoadCSIConfigFromConfigMap(csiConfig *CSIConfig, k kubernetes.Interface, co if lustreConfig, exists := cm.Data["lustre"]; exists { if err := yaml.Unmarshal([]byte(lustreConfig), &csiConfig.Lustre); err != nil { - logger.Debugf("Failed to parse lustre key in config map %v. Error: %v",configMapName, err) + logger.Debugf("Failed to parse lustre key in config map %v. Error: %v", configMapName, err) return } logger.Infof("Successfully loaded ConfigMap %v. Using customized configuration for csi driver.", configMapName) diff --git a/pkg/csi-util/utils_test.go b/pkg/csi-util/utils_test.go index dad37fcd59..caefa711b7 100644 --- a/pkg/csi-util/utils_test.go +++ b/pkg/csi-util/utils_test.go @@ -352,21 +352,21 @@ func Test_DiskByPathPatternForPV(t *testing.T) { func Test_LoadNodeMetadataFromApiServer(t *testing.T) { tests := []struct { - name string - nodeName string - want *NodeMetadata - kubeclient kubernetes.Interface - err error + name string + nodeName string + want *NodeMetadata + kubeclient kubernetes.Interface + err error }{ { name: "should return ipv6 for ipv6 preferred node", nodeName: "ipv6Preferred", want: &NodeMetadata{ FullAvailabilityDomain: "xyz:PHX-AD-3", - AvailabilityDomain: "PHX-AD-3", - PreferredNodeIpFamily: Ipv6Stack, - Ipv4Enabled: true, - Ipv6Enabled: true, + AvailabilityDomain: "PHX-AD-3", + PreferredNodeIpFamily: Ipv6Stack, + Ipv4Enabled: true, + Ipv6Enabled: true, }, }, { @@ -374,7 +374,7 @@ func Test_LoadNodeMetadataFromApiServer(t *testing.T) { nodeName: "ipv4Preferred", want: &NodeMetadata{ PreferredNodeIpFamily: Ipv4Stack, - AvailabilityDomain: "PHX-AD-3", + AvailabilityDomain: "PHX-AD-3", Ipv4Enabled: true, Ipv6Enabled: true, }, @@ -383,7 +383,7 @@ func Test_LoadNodeMetadataFromApiServer(t *testing.T) { name: "should return default IPv4 family for no ip preference", nodeName: "noIpPreference", want: &NodeMetadata{ - AvailabilityDomain: "PHX-AD-3", + AvailabilityDomain: "PHX-AD-3", PreferredNodeIpFamily: Ipv4Stack, Ipv4Enabled: true, Ipv6Enabled: false, @@ -410,7 +410,7 @@ func Test_LoadNodeMetadataFromApiServer(t *testing.T) { nodeName: "ipv4Preferred", want: &NodeMetadata{ PreferredNodeIpFamily: Ipv4Stack, - AvailabilityDomain: "PHX-AD-3", + AvailabilityDomain: "PHX-AD-3", Ipv4Enabled: true, Ipv6Enabled: true, }, @@ -424,8 +424,8 @@ func Test_LoadNodeMetadataFromApiServer(t *testing.T) { want: &NodeMetadata{}, err: fmt.Errorf("Failed to get node information from kube api server, please check if kube api server is accessible."), kubeclient: &util.MockKubeClientWithFailingRestClient{ - CoreClient: &util.MockCoreClientWithFailingRestClient{}, - }, + CoreClient: &util.MockCoreClientWithFailingRestClient{}, + }, }, } @@ -438,13 +438,11 @@ func Test_LoadNodeMetadataFromApiServer(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - log.SetOutput(os.Stdout) nodeMetadata := &NodeMetadata{} - ctx, cancel := context.WithTimeout(context.Background(), 10 * time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - var k kubernetes.Interface if tt.kubeclient != nil { k = tt.kubeclient @@ -809,25 +807,24 @@ func Test_ValidateDNSName(t *testing.T) { func Test_LoadCSIConfigFromConfigMap(t *testing.T) { tests := []struct { - name string + name string configMapName string - want *CSIConfig + want *CSIConfig }{ { - name: "Parse Configs correctly when csi config map is present", + name: "Parse Configs correctly when csi config map is present", configMapName: "oci-csi-config", want: &CSIConfig{ Lustre: &DriverConfig{ - SkipNodeUnstage: true, + SkipNodeUnstage: true, SkipLustreParameters: true, }, }, }, { - name: "Return default config if config map is not present", + name: "Return default config if config map is not present", configMapName: "invalid", - want: &CSIConfig{ - }, + want: &CSIConfig{}, }, } diff --git a/pkg/csi/driver/fss_controller.go b/pkg/csi/driver/fss_controller.go index d0f5df6cad..b661ba4c76 100644 --- a/pkg/csi/driver/fss_controller.go +++ b/pkg/csi/driver/fss_controller.go @@ -149,7 +149,7 @@ func (d *FSSControllerDriver) CreateVolume(ctx context.Context, req *csi.CreateV serviceAccountToken = serviceAccountTokenCreated } - ociClientConfig := &client.OCIClientConfig{ SaToken: serviceAccountToken, ParentRptURL: secretParameters.parentRptURL, TenancyId: d.config.Auth.TenancyID } + ociClientConfig := &client.OCIClientConfig{SaToken: serviceAccountToken, ParentRptURL: secretParameters.parentRptURL, TenancyId: d.config.Auth.TenancyID} networkingClient := d.client.Networking(ociClientConfig) if networkingClient == nil { @@ -628,7 +628,7 @@ func extractStorageClassParameters(ctx context.Context, d *FSSControllerDriver, } if client.IsIpv6SingleStackCluster() { - if !strings.Contains(availabilityDomain,":") { + if !strings.Contains(availabilityDomain, ":") { log.Errorf("Full AvailabilityDomain with prefix not provided in storage class for IPv6 single stack cluster.") dimensionsMap[metrics.ComponentDimension] = util.GetMetricDimensionForComponent(util.ErrValidation, util.CSIStorageType) metrics.SendMetricData(d.metricPusher, metrics.FssAllProvision, time.Since(startTime).Seconds(), dimensionsMap) @@ -793,7 +793,7 @@ func provisionMountTarget(ctx context.Context, log *zap.SugaredLogger, c client. SubnetId: &storageClassParameters.mountTargetSubnetOcid, FreeformTags: storageClassParameters.scTags.FreeformTags, DefinedTags: storageClassParameters.scTags.DefinedTags, - NsgIds: storageClassParameters.nsgOcids, + NsgIds: storageClassParameters.nsgOcids, } return fssClient.CreateMountTarget(ctx, createMountTargetDetails) } @@ -833,7 +833,7 @@ func (d *FSSControllerDriver) DeleteVolume(ctx context.Context, req *csi.DeleteV serviceAccountToken = serviceAccountTokenGenerated } - ociClientConfig := &client.OCIClientConfig{ SaToken: serviceAccountToken, ParentRptURL: secretParameters.parentRptURL, TenancyId: d.config.Auth.TenancyID } + ociClientConfig := &client.OCIClientConfig{SaToken: serviceAccountToken, ParentRptURL: secretParameters.parentRptURL, TenancyId: d.config.Auth.TenancyID} fssClient := d.client.FSS(ociClientConfig) @@ -1041,7 +1041,7 @@ func (d *FSSControllerDriver) ValidateVolumeCapabilities(ctx context.Context, re serviceAccountToken = serviceAccountTokenGenerated } - ociClientConfig := &client.OCIClientConfig{ SaToken: serviceAccountToken, ParentRptURL: secretParameters.parentRptURL, TenancyId: d.config.Auth.TenancyID } + ociClientConfig := &client.OCIClientConfig{SaToken: serviceAccountToken, ParentRptURL: secretParameters.parentRptURL, TenancyId: d.config.Auth.TenancyID} networkingClient := d.client.Networking(ociClientConfig) if networkingClient == nil { diff --git a/pkg/csi/driver/fss_controller_test.go b/pkg/csi/driver/fss_controller_test.go index 4a2dbb4cad..be41a506bd 100644 --- a/pkg/csi/driver/fss_controller_test.go +++ b/pkg/csi/driver/fss_controller_test.go @@ -543,12 +543,12 @@ func TestFSSControllerDriver_CreateVolume(t *testing.T) { wantErr: errors.New("Neither Mount Target Ocid nor Mount Target Subnet Ocid provided in storage class"), }, { - name: "Error when invalid JSON string provided for mount target NSGs", + name: "Error when invalid JSON string provided for mount target NSGs", fields: fields{}, args: args{ ctx: context.Background(), req: &csi.CreateVolumeRequest{ - Name: "ut-volume", + Name: "ut-volume", Parameters: map[string]string{"availabilityDomain": "US-ASHBURN-AD-1", "mountTargetSubnetOcid": "oc1.subnet.xxxx", "nsgOcids": ""}, VolumeCapabilities: []*csi.VolumeCapability{{ AccessMode: &csi.VolumeCapability_AccessMode{ @@ -557,7 +557,7 @@ func TestFSSControllerDriver_CreateVolume(t *testing.T) { }}, }, }, - want: nil, + want: nil, wantErr: errors.New("Failed to parse nsgOcids provided in storage class. Please provide valid input."), }, { diff --git a/pkg/csi/driver/lustre_node.go b/pkg/csi/driver/lustre_node.go index 391fa645d4..34af114dd1 100644 --- a/pkg/csi/driver/lustre_node.go +++ b/pkg/csi/driver/lustre_node.go @@ -41,7 +41,6 @@ func (d LustreNodeDriver) NodeStageVolume(ctx context.Context, req *csi.NodeStag return nil, status.Error(codes.InvalidArgument, "Invalid Volume Handle provided.") } - d.loadCSIConfig() if lustrePostMountParameters, exists := req.GetVolumeContext()["lustrePostMountParameters"]; exists && !isSkipLustreParams(d.csiConfig) { @@ -65,7 +64,7 @@ func (d LustreNodeDriver) NodeStageVolume(ctx context.Context, req *csi.NodeStag //Lnet Setup if setupLnet, ok := req.GetVolumeContext()[SetupLnet]; ok && setupLnet == "true" { - lustreSubnetCIDR, ok := req.GetVolumeContext()[LustreSubnetCidr] + lustreSubnetCIDR, ok := req.GetVolumeContext()[LustreSubnetCidr] if !ok { lustreSubnetCIDR = fmt.Sprintf("%s/32", d.nodeID) @@ -90,8 +89,6 @@ func (d LustreNodeDriver) NodeStageVolume(ctx context.Context, req *csi.NodeStag mounter := mount.New(mountPath) - - targetPath := req.StagingTargetPath mountPoint, err := isMountPoint(mounter, targetPath) if err != nil { @@ -130,7 +127,7 @@ func (d LustreNodeDriver) NodeStageVolume(ctx context.Context, req *csi.NodeStag if lustrePostMountParameters, exists := req.GetVolumeContext()["lustrePostMountParameters"]; exists { d.loadCSIConfig() - if !isSkipLustreParams(d.csiConfig) { + if !isSkipLustreParams(d.csiConfig) { err = lnetService.ApplyLustreParameters(logger, lustrePostMountParameters) if err != nil { //Unmounting volume on error as we are failing NodeStageVolume. If we don't unmount and customer deletes workload then volume will remain mounted as NodeUnstageVolume won't be called. @@ -156,7 +153,6 @@ func (d LustreNodeDriver) loadCSIConfig() { d.csiConfig.IsLoaded = true } - func (d LustreNodeDriver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { if req.VolumeId == "" { @@ -214,7 +210,7 @@ func (d LustreNodeDriver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUn logger.With("StagingTargetPath", targetPath).Infof("mount point does not exist") return &csi.NodeUnstageVolumeResponse{}, nil } - return nil, status.Error(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } if !isMountPoint { @@ -222,7 +218,7 @@ func (d LustreNodeDriver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUn err = os.RemoveAll(targetPath) if err != nil { logger.With(zap.Error(err)).Error("Remove target path failed with error") - return nil, status.Error(codes.Internal, "Failed to remove target path") + return nil, status.Error(codes.Internal, "Failed to remove target path") } return &csi.NodeUnstageVolumeResponse{}, nil } @@ -250,7 +246,6 @@ func (d LustreNodeDriver) NodePublishVolume(ctx context.Context, req *csi.NodePu return nil, status.Error(codes.InvalidArgument, "Target Path must be provided") } - logger := d.logger.With("volumeID", req.VolumeId) logger.Debugf("volume context: %v", req.VolumeContext) diff --git a/pkg/oci/client/block_storage.go b/pkg/oci/client/block_storage.go index 0d612b57cf..7924e052c8 100644 --- a/pkg/oci/client/block_storage.go +++ b/pkg/oci/client/block_storage.go @@ -99,7 +99,7 @@ func (c *client) GetBootVolume(ctx context.Context, id string) (*core.BootVolume } resp, err := c.bs.GetBootVolume(ctx, core.GetBootVolumeRequest{ - BootVolumeId: &id, + BootVolumeId: &id, RequestMetadata: c.requestMetadata}) incRequestCounter(err, getVerb, volumeResource) diff --git a/pkg/oci/client/client_test.go b/pkg/oci/client/client_test.go index 7960981ec7..b11454f848 100644 --- a/pkg/oci/client/client_test.go +++ b/pkg/oci/client/client_test.go @@ -194,8 +194,8 @@ func (c *mockComputeClient) ListInstanceDevices(ctx context.Context, request cor } else if *request.InstanceId == "ocid1.one-device-path-available" { return core.ListInstanceDevicesResponse{ Items: []core.Device{{ - Name: &devicePath, - }, + Name: &devicePath, + }, }, }, nil } diff --git a/pkg/oci/client/generic_load_balancer_types.go b/pkg/oci/client/generic_load_balancer_types.go index 5cd5adb590..d13ac156e7 100644 --- a/pkg/oci/client/generic_load_balancer_types.go +++ b/pkg/oci/client/generic_load_balancer_types.go @@ -118,7 +118,7 @@ type GenericCreateLoadBalancerDetails struct { // Only needed for LB Certificates map[string]GenericCertificate - RuleSets map[string]loadbalancer.RuleSetDetails + RuleSets map[string]loadbalancer.RuleSetDetails // Supported only in NLB AssignedPrivateIpv4 *string AssignedIpv6 *string diff --git a/pkg/oci/client/volume_attachment_test.go b/pkg/oci/client/volume_attachment_test.go index 2c7739b739..410bde30ff 100644 --- a/pkg/oci/client/volume_attachment_test.go +++ b/pkg/oci/client/volume_attachment_test.go @@ -11,28 +11,27 @@ import ( func Test_getDevicePath(t *testing.T) { var tests = map[string]struct { - instanceID string - want string - wantErr error + instanceID string + want string + wantErr error }{ "getDevicePathNoDeviceAvailable": { instanceID: "ocid1.device-path-not-available", - wantErr: fmt.Errorf("Max number of volumes are already attached to instance %s. Please schedule workload on different node.", "ocid1.device-path-not-available"), - + wantErr: fmt.Errorf("Max number of volumes are already attached to instance %s. Please schedule workload on different node.", "ocid1.device-path-not-available"), }, "getDevicePathOneDeviceAvailable": { instanceID: "ocid1.one-device-path-available", - want: "/dev/oracleoci/oraclevdac", + want: "/dev/oracleoci/oraclevdac", }, "getDevicePathReturnsError": { instanceID: "ocid1.device-path-returns-error", - wantErr: errNotFound, + wantErr: errNotFound, }, } - + vaClient := &client{ compute: &mockComputeClient{}, - logger: zap.S(), + logger: zap.S(), } for name, tc := range tests { diff --git a/pkg/util/disk/iscsi.go b/pkg/util/disk/iscsi.go index a60cf858e1..fda916ca4d 100644 --- a/pkg/util/disk/iscsi.go +++ b/pkg/util/disk/iscsi.go @@ -90,7 +90,7 @@ type Interface interface { DeviceOpened(pathname string) (bool, error) - IsMounted(devicePath string, targetPath string) (bool, error) + IsMounted(devicePath string, targetPath string) (bool, error) // updates the queue depth for iSCSI target UpdateQueueDepth() error @@ -494,7 +494,7 @@ func (c *iSCSIMounter) IsMounted(devicePath string, targetPath string) (bool, er var diskByPath string notMnt, err := c.mounter.IsLikelyNotMountPoint(targetPath) if err != nil { - if os.IsNotExist(err){ + if os.IsNotExist(err) { return false, nil } return false, fmt.Errorf("failed to check if %s is a mount point: %v", targetPath, err) diff --git a/pkg/util/disk/paravirtualized.go b/pkg/util/disk/paravirtualized.go index c2f5288fde..87ff5c34b4 100644 --- a/pkg/util/disk/paravirtualized.go +++ b/pkg/util/disk/paravirtualized.go @@ -104,7 +104,7 @@ func (c *pvMounter) DeviceOpened(pathname string) (bool, error) { func (c *pvMounter) IsMounted(devicePath string, targetPath string) (bool, error) { notMnt, err := c.mounter.IsLikelyNotMountPoint(targetPath) if err != nil { - if os.IsNotExist(err){ + if os.IsNotExist(err) { return false, nil } return false, fmt.Errorf("failed to check if %s is a mount point: %v", targetPath, err) diff --git a/pkg/util/osinfo/osinfo.go b/pkg/util/osinfo/osinfo.go index b7753051f7..7e84de9f5c 100644 --- a/pkg/util/osinfo/osinfo.go +++ b/pkg/util/osinfo/osinfo.go @@ -12,9 +12,9 @@ var OsName = "" const ( LinuxOsReleaseFile = "/host/etc/os-release" - DebianOSName = "Debian GNU/Linux" + DebianOSName = "Debian GNU/Linux" - UbuntuOSName = "Ubuntu" + UbuntuOSName = "Ubuntu" ) func GetOsName() (name string) { @@ -22,8 +22,8 @@ func GetOsName() (name string) { return OsName } - OsName = parseLinuxReleaseFile(LinuxOsReleaseFile) - return OsName; + OsName = parseLinuxReleaseFile(LinuxOsReleaseFile) + return OsName } func readLines(path string) ([]string, error) { @@ -58,7 +58,6 @@ func parseLinuxReleaseFile(releaseFile string) (name string) { return osName } - func IsUbuntu() bool { return strings.EqualFold(UbuntuOSName, GetOsName()) } diff --git a/pkg/util/signals/signal_posix.go b/pkg/util/signals/signal_posix.go index 9bdb4e7418..a0f00a7321 100644 --- a/pkg/util/signals/signal_posix.go +++ b/pkg/util/signals/signal_posix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows /* diff --git a/test/e2e/cloud-provider-oci/lustre_static.go b/test/e2e/cloud-provider-oci/lustre_static.go index 8bd7a184c0..38b30f9368 100644 --- a/test/e2e/cloud-provider-oci/lustre_static.go +++ b/test/e2e/cloud-provider-oci/lustre_static.go @@ -26,9 +26,9 @@ var _ = Describe("Lustre Static", func() { It("Multiple Pods should be able consume same PVC and read, write to same file", func() { pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-lustre-e2e-test") - pvVolumeAttributes := map[string]string{ "setupLnet": "true"} + pvVolumeAttributes := map[string]string{"setupLnet": "true"} if setupF.LustreSubnetCidr != "" { - pvVolumeAttributes["lustreSubnetCidr"]= setupF.LustreSubnetCidr + pvVolumeAttributes["lustreSubnetCidr"] = setupF.LustreSubnetCidr } pv := pvcJig.CreatePVorFailLustre(f.Namespace.Name, setupF.LustreVolumeHandle, []string{}, pvVolumeAttributes) @@ -55,9 +55,9 @@ var _ = Describe("Lustre Static", func() { //LUSTRE lusterPVCJig := framework.NewPVCTestJig(f.ClientSet, "csi-lustre-e2e-test") - pvVolumeAttributes := map[string]string{ "setupLnet": "true"} + pvVolumeAttributes := map[string]string{"setupLnet": "true"} if setupF.LustreSubnetCidr != "" { - pvVolumeAttributes["lustreSubnetCidr"]= setupF.LustreSubnetCidr + pvVolumeAttributes["lustreSubnetCidr"] = setupF.LustreSubnetCidr } lustrePV := lusterPVCJig.CreatePVorFailLustre(f.Namespace.Name, setupF.LustreVolumeHandle, []string{}, pvVolumeAttributes) lustrePVC := lusterPVCJig.CreateAndAwaitPVCOrFailStaticLustre(f.Namespace.Name, lustrePV.Name, "50Gi", nil) @@ -72,9 +72,9 @@ var _ = Describe("Lustre Static", func() { It("Create PV PVC and POD for CSI-Lustre with mount options", func() { pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-lustre-e2e-test") mountOptions := []string{"flock"} - pvVolumeAttributes := map[string]string{ "setupLnet": "true"} + pvVolumeAttributes := map[string]string{"setupLnet": "true"} if setupF.LustreSubnetCidr != "" { - pvVolumeAttributes["lustreSubnetCidr"]= setupF.LustreSubnetCidr + pvVolumeAttributes["lustreSubnetCidr"] = setupF.LustreSubnetCidr } pv := pvcJig.CreatePVorFailLustre(f.Namespace.Name, setupF.LustreVolumeHandle, mountOptions, pvVolumeAttributes) @@ -85,7 +85,7 @@ var _ = Describe("Lustre Static", func() { It("Create PV PVC and POD for CSI-Lustre with lustre post mount parameters", func() { pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-lustre-e2e-test") - pvVolumeAttributes := map[string]string{ "setupLnet": "true", "lustrePostMountParameters" : "[{\"*.*.*MDT*.lru_size\" : 11201}]"} + pvVolumeAttributes := map[string]string{"setupLnet": "true", "lustrePostMountParameters": "[{\"*.*.*MDT*.lru_size\" : 11201}]"} pv := pvcJig.CreatePVorFailLustre(f.Namespace.Name, setupF.LustreVolumeHandle, []string{}, pvVolumeAttributes) pvc := pvcJig.CreateAndAwaitPVCOrFailStaticLustre(f.Namespace.Name, pv.Name, "50Gi", nil) @@ -98,9 +98,9 @@ var _ = Describe("Lustre Static", func() { It("Verify volume group ownership change for Lustre when fsGroup is defined", func() { pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-lustre-e2e-test") - pvVolumeAttributes := map[string]string{ "setupLnet": "true"} + pvVolumeAttributes := map[string]string{"setupLnet": "true"} if setupF.LustreSubnetCidr != "" { - pvVolumeAttributes["lustreSubnetCidr"]= setupF.LustreSubnetCidr + pvVolumeAttributes["lustreSubnetCidr"] = setupF.LustreSubnetCidr } pv := pvcJig.CreatePVorFailLustre(f.Namespace.Name, setupF.LustreVolumeHandle, []string{}, pvVolumeAttributes) diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 1b979bf426..81cb029234 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -43,22 +43,22 @@ const ( DefaultClusterKubeconfig = "/tmp/clusterkubeconfig" DefaultCloudConfig = "/tmp/cloudconfig" - ClassOCI = "oci" - ClassOCICSI = "oci-bv" - ClassCustom = "oci-bv-custom" - ClassOCICSIExpand = "oci-bv-expand" - ClassOCILowCost = "oci-bv-low" - ClassOCIBalanced = "oci-bal" - ClassOCIHigh = "oci-bv-high" - ClassOCIUHP = "oci-uhp" - ClassOCIKMS = "oci-kms" - ClassOCIExt3 = "oci-ext3" - ClassOCIXfs = "oci-xfs" - ClassFssDynamic = "oci-file-storage-test" - ClassSnapshot = "oci-snapshot-sc" - MinVolumeBlock = "50Gi" - MaxVolumeBlock = "100Gi" - VolumeFss = "1Gi" + ClassOCI = "oci" + ClassOCICSI = "oci-bv" + ClassCustom = "oci-bv-custom" + ClassOCICSIExpand = "oci-bv-expand" + ClassOCILowCost = "oci-bv-low" + ClassOCIBalanced = "oci-bal" + ClassOCIHigh = "oci-bv-high" + ClassOCIUHP = "oci-uhp" + ClassOCIKMS = "oci-kms" + ClassOCIExt3 = "oci-ext3" + ClassOCIXfs = "oci-xfs" + ClassFssDynamic = "oci-file-storage-test" + ClassSnapshot = "oci-snapshot-sc" + MinVolumeBlock = "50Gi" + MaxVolumeBlock = "100Gi" + VolumeFss = "1Gi" VSClassDefault = "oci-snapclass" NodeHostnameLabel = "kubernetes.io/hostname" @@ -87,12 +87,12 @@ var ( reservedIP string // Testing public reserved IP feature architecture string volumeHandle string // The FSS mount volume handle - lustreVolumeHandle string // The Lustre mount volume handle + lustreVolumeHandle string // The Lustre mount volume handle lustreSubnetCidr string // The Lustre Subnet Cidr staticSnapshotCompartmentOCID string // Compartment ID for cross compartment snapshot test - customDriverHandle string // Custom driver handle for custom CSI driver installation + customDriverHandle string // Custom driver handle for custom CSI driver installation runUhpE2E bool // Whether to run UHP E2Es, requires Volume Management Plugin enabled on the node and 16+ cores (check blockvolumeperformance public doc for the exact requirements) - enableParallelRun bool + enableParallelRun bool addOkeSystemTags bool clusterID string // Ocid of the newly created E2E cluster clusterType string // Cluster type can be BASIC_CLUSTER or ENHANCED_CLUSTER (Default: BASIC_CLUSTER) @@ -166,7 +166,7 @@ type Framework struct { ReservedIP string Architecture string - VolumeHandle string + VolumeHandle string LustreVolumeHandle string LustreSubnetCidr string @@ -174,10 +174,10 @@ type Framework struct { // Compartment ID for cross compartment snapshot test StaticSnapshotCompartmentOcid string RunUhpE2E bool - CustomDriverHandle string - BlockProvisionerName string - FSSProvisionerName string - AddOkeSystemTags bool + CustomDriverHandle string + BlockProvisionerName string + FSSProvisionerName string + AddOkeSystemTags bool } // New creates a new a framework that holds the context of the test @@ -204,7 +204,7 @@ func NewWithConfig() *Framework { LustreSubnetCidr: lustreSubnetCidr, StaticSnapshotCompartmentOcid: staticSnapshotCompartmentOCID, RunUhpE2E: runUhpE2E, - CustomDriverHandle: customDriverHandle, + CustomDriverHandle: customDriverHandle, AddOkeSystemTags: addOkeSystemTags, ClusterType: clusterTypeEnum, } diff --git a/test/e2e/framework/volumesnapshotclass_util.go b/test/e2e/framework/volumesnapshotclass_util.go index 3b3d11916a..b5c5cc4afa 100644 --- a/test/e2e/framework/volumesnapshotclass_util.go +++ b/test/e2e/framework/volumesnapshotclass_util.go @@ -49,17 +49,17 @@ func (f *CloudProviderFramework) CreateVolumeSnapshotClassOrFail(name string, dr // does not actually create the storage class. The default storage class has the same name // as the jig func (f *CloudProviderFramework) NewVolumeSnapshotClassTemplate(name string, parameters map[string]string, - driverType string,deletionPolicy snapshot.DeletionPolicy) *snapshot.VolumeSnapshotClass { + driverType string, deletionPolicy snapshot.DeletionPolicy) *snapshot.VolumeSnapshotClass { return &snapshot.VolumeSnapshotClass{ TypeMeta: metav1.TypeMeta{ Kind: "VolumeSnapshotClass", APIVersion: "snapshot.storage.k8s.io/v1", }, ObjectMeta: metav1.ObjectMeta{ - Name: name, + Name: name, }, Driver: driverType, - Parameters: parameters, + Parameters: parameters, DeletionPolicy: deletionPolicy, } }