diff --git a/.golangci.yml b/.golangci.yml index 8c4314529d..a99c01395d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -114,34 +114,34 @@ linters: - perfsprint - revive - gosec - - gochecknoglobals # TODO FIXME + - godot # End all godoc comments with period disable: - govet # We already run with `make verify/govet` # We do not use - gomoddirectives # We need `replace` in `go.mod` - depguard # We don't guard against dependencies - - testpackage # Requires separate test package - - funlen # Long names happen - - maintidx # Maintainability Index + - testpackage # Require separate test package to catch leaky unexported dependencies + - funlen # Long func names happen + - varnamelen # Long var names happen + - maintidx # Maintainability index - cyclop # Cyclomatic complexity + - gocognit # Cognitive complexity - wsl # Too strict of a whitespace linter # TODO Investigate FIXME - - dupl # TODO FIXME (tests + non-tests) - - err113 # TODO FIXME - - wrapcheck # Many false positives - - varnamelen # Many false positives - - mnd # Many false positives - - gomnd # Many false positives - - paralleltest # TODO FIXME (Too many tests that aren't parallelized right now) - - nestif # Many false positives - - gocognit # Many false positives - - godox # TODO FIXME - # Ask team + - err113 # TODO FIXME do not create errors dynamically from scratch. Instead wrap static (package-level) error. 2 points + - wrapcheck # TODO ^^ + - gochecknoglobals # TODO FIXME A whole 2 point task on its own + - paralleltest # TODO FIXME (Too many tests that aren't parallelized right now, probably half a day to attempt to mark the ones we can) + - nestif # TODO whole refactoring/readability task, should split up + - godox # TODO FIXME audit our project TODOs + # TODO Q: Consult with team - lll # Limit line length - - godot # TODO Ask team if we want to end all godoc comments with period - - gofumpt # TODO Ask team if we want to rely on gofumpt - - ireturn # ask team if we want to accept interfaces return concrete types - - nlreturn # Meh, ask team newline return - - nonamedreturns # Ask team, maybe nolint a few of the places it actually leads to cleaner code - - exhaustruct # Seems REALLY painful for kubernetes structs... - - interfacebloat # Cloud and Mounter have 15 instead of 10... Smell or necessary? We can nolint + - gofumpt # Rely on gofumpt's stricter formatting opinions + - ireturn # Always accept interfaces return concrete types (gopherism) + - nlreturn # Always have emptyline before return + - nonamedreturns # No using named returns in functions. Maybe nolint a few of the places it actually leads to cleaner code + - exhaustruct # Forces you to explicitly instantiate all structs. REALLY painful for kubernetes structs... + - interfacebloat # Cloud and Mounter have 15 methods instead of linter's recommended 10... Smell or necessary? We can nolint specific ones + - mnd # Magic Number Detection. Many false positives, still worth with nolint? + - gomnd # Many false positives, still worth with nolint? + - dupl # Tracks code duplication. Brutal amount of duplication in tests. False positives in non-tests. diff --git a/cmd/hooks/prestop.go b/cmd/hooks/prestop.go index b1e07396a6..d948673fd3 100644 --- a/cmd/hooks/prestop.go +++ b/cmd/hooks/prestop.go @@ -47,7 +47,7 @@ const clusterAutoscalerTaint = "ToBeDeletedByClusterAutoscaler" const v1KarpenterTaint = "karpenter.sh/disrupted" const v1beta1KarpenterTaint = "karpenter.sh/disruption" -// drainTaints includes taints used by K8s or autoscalers that signify node draining or pod eviction +// drainTaints includes taints used by K8s or autoscalers that signify node draining or pod eviction. var drainTaints = map[string]struct{}{ v1.TaintNodeUnschedulable: {}, // Kubernetes common eviction taint (kubectl drain) clusterAutoscalerTaint: {}, diff --git a/pkg/cloud/cloud.go b/pkg/cloud/cloud.go index 8ccf1d5f6e..f4c8194e1e 100644 --- a/pkg/cloud/cloud.go +++ b/pkg/cloud/cloud.go @@ -41,7 +41,7 @@ import ( "k8s.io/klog/v2" ) -// AWS volume types +// AWS volume types. const ( // VolumeTypeIO1 represents a provisioned IOPS SSD type of volume. VolumeTypeIO1 = "io1" @@ -111,13 +111,13 @@ const ( MaxTagValueLength = 256 ) -// Defaults +// Defaults. const ( // DefaultVolumeSize represents the default volume size. DefaultVolumeSize int64 = 100 * util.GiB ) -// Tags +// Tags. const ( // VolumeNameTagKey is the key value that refers to the volume's name. VolumeNameTagKey = "CSIVolumeName" @@ -127,11 +127,11 @@ const ( KubernetesTagKeyPrefix = "kubernetes.io" // AWSTagKeyPrefix is the prefix of the key value that is reserved for AWS. AWSTagKeyPrefix = "aws:" - // AwsEbsDriverTagKey is the tag to identify if a volume/snapshot is managed by ebs csi driver + // AwsEbsDriverTagKey is the tag to identify if a volume/snapshot is managed by ebs csi driver. AwsEbsDriverTagKey = "ebs.csi.aws.com/cluster" ) -// Batcher +// Batcher. const ( volumeIDBatcher volumeBatcherType = iota volumeTagBatcher @@ -162,23 +162,23 @@ var ( ErrAlreadyExists = errors.New("resource already exists") // ErrMultiSnapshots is returned when multiple snapshots are found - // with the same ID + // with the same ID. ErrMultiSnapshots = errors.New("multiple snapshots with the same name found") - // ErrInvalidMaxResults is returned when a MaxResults pagination parameter is between 1 and 4 + // ErrInvalidMaxResults is returned when a MaxResults pagination parameter is between 1 and 4. ErrInvalidMaxResults = errors.New("maxResults parameter must be 0 or greater than or equal to 5") - // ErrVolumeNotBeingModified is returned if volume being described is not being modified + // ErrVolumeNotBeingModified is returned if volume being described is not being modified. ErrVolumeNotBeingModified = errors.New("volume is not being modified") - // ErrInvalidArgument is returned if parameters were rejected by cloud provider + // ErrInvalidArgument is returned if parameters were rejected by cloud provider. ErrInvalidArgument = errors.New("invalid argument") - // ErrInvalidRequest is returned if parameters were rejected by driver + // ErrInvalidRequest is returned if parameters were rejected by driver. ErrInvalidRequest = errors.New("invalid request") ) -// Set during build time via -ldflags +// Set during build time via -ldflags. var driverVersion string var invalidParameterErrorCodes = map[string]struct{}{ @@ -192,7 +192,7 @@ var invalidParameterErrorCodes = map[string]struct{}{ "ValidationError": {}, } -// Disk represents a EBS volume +// Disk represents a EBS volume. type Disk struct { VolumeID string CapacityGiB int32 @@ -202,7 +202,7 @@ type Disk struct { Attachments []string } -// DiskOptions represents parameters to create an EBS volume +// DiskOptions represents parameters to create an EBS volume. type DiskOptions struct { CapacityBytes int64 Tags map[string]string @@ -222,20 +222,20 @@ type DiskOptions struct { SnapshotID string } -// ModifyDiskOptions represents parameters to modify an EBS volume +// ModifyDiskOptions represents parameters to modify an EBS volume. type ModifyDiskOptions struct { VolumeType string IOPS int32 Throughput int32 } -// ModifyTagsOptions represents parameter to modify the tags of an existing EBS volume +// ModifyTagsOptions represents parameter to modify the tags of an existing EBS volume. type ModifyTagsOptions struct { TagsToAdd map[string]string TagsToDelete []string } -// Snapshot represents an EBS volume snapshot +// Snapshot represents an EBS volume snapshot. type Snapshot struct { SnapshotID string SourceVolumeID string @@ -244,19 +244,19 @@ type Snapshot struct { ReadyToUse bool } -// ListSnapshotsResponse is the container for our snapshots along with a pagination token to pass back to the caller +// ListSnapshotsResponse is the container for our snapshots along with a pagination token to pass back to the caller. type ListSnapshotsResponse struct { Snapshots []*Snapshot NextToken string } -// SnapshotOptions represents parameters to create an EBS volume +// SnapshotOptions represents parameters to create an EBS volume. type SnapshotOptions struct { Tags map[string]string OutpostArn string } -// ec2ListSnapshotsResponse is a helper struct returned from the AWS API calling function to the main ListSnapshots function +// ec2ListSnapshotsResponse is a helper struct returned from the AWS API calling function to the main ListSnapshots function. type ec2ListSnapshotsResponse struct { Snapshots []types.Snapshot NextToken *string @@ -333,7 +333,7 @@ type cloud struct { var _ Cloud = &cloud{} // NewCloud returns a new instance of AWS cloud -// It panics if session is invalid +// It panics if session is invalid. func NewCloud(region string, awsSdkDebugLog bool, userAgentExtra string, batching bool) (Cloud, error) { c := newEC2Cloud(region, awsSdkDebugLog, userAgentExtra, batching) return c, nil @@ -705,7 +705,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions * return &Disk{CapacityGiB: size, VolumeID: volumeID, AvailabilityZone: zone, SnapshotID: snapshotID, OutpostArn: outpostArn}, nil } -// execBatchDescribeVolumesModifications executes a batched DescribeVolumesModifications API call +// execBatchDescribeVolumesModifications executes a batched DescribeVolumesModifications API call. func execBatchDescribeVolumesModifications(svc EC2API, input []string) (map[string]*types.VolumeModification, error) { klog.V(7).InfoS("execBatchDescribeVolumeModifications", "volumeIds", input) request := &ec2.DescribeVolumesModificationsInput{ @@ -861,7 +861,7 @@ func (c *cloud) DeleteDisk(ctx context.Context, volumeID string) (bool, error) { return true, nil } -// execBatchDescribeInstances executes a batched DescribeInstances API call +// execBatchDescribeInstances executes a batched DescribeInstances API call. func execBatchDescribeInstances(svc EC2API, input []string) (map[string]*types.Instance, error) { klog.V(7).InfoS("execBatchDescribeInstances", "instanceIds", input) request := &ec2.DescribeInstancesInput{ @@ -1401,7 +1401,7 @@ func (c *cloud) ListSnapshots(ctx context.Context, volumeID string, maxResults i }, nil } -// Helper method converting EC2 snapshot type to the internal struct +// Helper method converting EC2 snapshot type to the internal struct. func (c *cloud) ec2SnapshotResponseToStruct(ec2Snapshot types.Snapshot) *Snapshot { snapshotSize := *ec2Snapshot.VolumeSize snapshot := &Snapshot{ @@ -1557,7 +1557,7 @@ func (c *cloud) getSnapshot(ctx context.Context, request *ec2.DescribeSnapshotsI } } -// listSnapshots returns all snapshots based from a request +// listSnapshots returns all snapshots based from a request. func (c *cloud) listSnapshots(ctx context.Context, request *ec2.DescribeSnapshotsInput) (*ec2ListSnapshotsResponse, error) { var snapshots []types.Snapshot var nextToken *string @@ -1643,7 +1643,7 @@ func isAWSErrorInvalidAttachmentNotFound(err error) bool { } // isAWSErrorModificationNotFound returns a boolean indicating whether the given -// error is an AWS InvalidVolumeModification.NotFound error +// error is an AWS InvalidVolumeModification.NotFound error. func isAWSErrorModificationNotFound(err error) bool { return isAWSError(err, "InvalidVolumeModification.NotFound") } @@ -1657,7 +1657,7 @@ func isAWSErrorSnapshotNotFound(err error) bool { // isAWSErrorIdempotentParameterMismatch returns a boolean indicating whether the // given error is an AWS IdempotentParameterMismatch error. -// This error is reported when the two request contains same client-token but different parameters +// This error is reported when the two request contains same client-token but different parameters. func isAWSErrorIdempotentParameterMismatch(err error) bool { return isAWSError(err, "IdempotentParameterMismatch") } @@ -1794,7 +1794,7 @@ func (c *cloud) getLatestVolumeModification(ctx context.Context, volumeID string } // randomAvailabilityZone returns a random zone from the given region -// the randomness relies on the response of DescribeAvailabilityZones +// the randomness relies on the response of DescribeAvailabilityZones. func (c *cloud) randomAvailabilityZone(ctx context.Context) (string, error) { request := &ec2.DescribeAvailabilityZonesInput{} response, err := c.ec2.DescribeAvailabilityZones(ctx, request) @@ -1810,7 +1810,7 @@ func (c *cloud) randomAvailabilityZone(ctx context.Context) (string, error) { return zones[0], nil } -// AvailabilityZones returns availability zones from the given region +// AvailabilityZones returns availability zones from the given region. func (c *cloud) AvailabilityZones(ctx context.Context) (map[string]struct{}, error) { response, err := c.ec2.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{}) if err != nil { diff --git a/pkg/cloud/cloud_test.go b/pkg/cloud/cloud_test.go index bf31712438..3b09e107ff 100644 --- a/pkg/cloud/cloud_test.go +++ b/pkg/cloud/cloud_test.go @@ -1451,7 +1451,7 @@ func TestCreateDisk(t *testing.T) { } } -// Test client error IdempotentParameterMismatch by forcing it to progress twice +// Test client error IdempotentParameterMismatch by forcing it to progress twice. func TestCreateDiskClientToken(t *testing.T) { t.Parallel() diff --git a/pkg/cloud/devicemanager/allocator.go b/pkg/cloud/devicemanager/allocator.go index 59d23ed4cb..95567396fb 100644 --- a/pkg/cloud/devicemanager/allocator.go +++ b/pkg/cloud/devicemanager/allocator.go @@ -46,7 +46,7 @@ var _ NameAllocator = &nameAllocator{} // It does this by using a list of legal EBS device names from device_names.go // // likelyBadNames is a map of names that have previously returned an "in use" error when attempting to mount to them -// These names are unlikely to result in a successful mount, and may be permanently unavailable, so use them last +// These names are unlikely to result in a successful mount, and may be permanently unavailable, so use them last. func (d *nameAllocator) GetNext(existingNames ExistingNames, likelyBadNames *sync.Map) (string, error) { for _, name := range deviceNames { _, existing := existingNames[name] diff --git a/pkg/cloud/devicemanager/manager.go b/pkg/cloud/devicemanager/manager.go index 08e42e77ff..85d4d18ec6 100644 --- a/pkg/cloud/devicemanager/manager.go +++ b/pkg/cloud/devicemanager/manager.go @@ -44,7 +44,7 @@ func (d *Device) Release(force bool) { } } -// Taint marks the device as no longer reusable +// Taint marks the device as no longer reusable. func (d *Device) Taint() { d.isTainted = true } @@ -194,7 +194,7 @@ func (d *deviceManager) release(device *Device) error { } // getDeviceNamesInUse returns the device to volume ID mapping -// the mapping includes both already attached and being attached volumes +// the mapping includes both already attached and being attached volumes. func (d *deviceManager) getDeviceNamesInUse(instance *types.Instance) map[string]string { nodeID := aws.ToString(instance.InstanceId) inUse := map[string]string{} diff --git a/pkg/cloud/handlers.go b/pkg/cloud/handlers.go index 2b82c8a8af..2f725943d7 100644 --- a/pkg/cloud/handlers.go +++ b/pkg/cloud/handlers.go @@ -29,7 +29,7 @@ import ( "k8s.io/klog/v2" ) -// RecordRequestsHandler is added to the Complete chain; called after any request +// RecordRequestsHandler is added to the Complete chain; called after any request. func RecordRequestsMiddleware() func(*middleware.Stack) error { return func(stack *middleware.Stack) error { return stack.Finalize.Add(middleware.FinalizeMiddlewareFunc("RecordRequestsMiddleware", func(ctx context.Context, input middleware.FinalizeInput, next middleware.FinalizeHandler) (output middleware.FinalizeOutput, metadata middleware.Metadata, err error) { @@ -60,7 +60,7 @@ func RecordRequestsMiddleware() func(*middleware.Stack) error { // LogServerErrorsMiddleware is a middleware that logs server errors received when attempting to contact the AWS API // A specialized middleware is used instead of the SDK's built-in retry logging to allow for customizing the verbosity -// of throttle errors vs server/unknown errors, to prevent flooding the logs with throttle error +// of throttle errors vs server/unknown errors, to prevent flooding the logs with throttle error. func LogServerErrorsMiddleware() func(*middleware.Stack) error { return func(stack *middleware.Stack) error { return stack.Finalize.Add(middleware.FinalizeMiddlewareFunc("LogServerErrorsMiddleware", func(ctx context.Context, input middleware.FinalizeInput, next middleware.FinalizeHandler) (output middleware.FinalizeOutput, metadata middleware.Metadata, err error) { diff --git a/pkg/cloud/metadata/ec2.go b/pkg/cloud/metadata/ec2.go index c4e2ea60be..b0c39a6b48 100644 --- a/pkg/cloud/metadata/ec2.go +++ b/pkg/cloud/metadata/ec2.go @@ -29,13 +29,13 @@ import ( ) const ( - // OutpostArnEndpoint is the ec2 instance metadata endpoint to query to get the outpost arn + // OutpostArnEndpoint is the ec2 instance metadata endpoint to query to get the outpost arn. OutpostArnEndpoint string = "outpost-arn" - // enisEndpoint is the ec2 instance metadata endpoint to query the number of attached ENIs + // enisEndpoint is the ec2 instance metadata endpoint to query the number of attached ENIs. EnisEndpoint string = "network/interfaces/macs" - // blockDevicesEndpoint is the ec2 instance metadata endpoint to query the number of attached block devices + // blockDevicesEndpoint is the ec2 instance metadata endpoint to query the number of attached block devices. BlockDevicesEndpoint string = "block-device-mapping" ) diff --git a/pkg/cloud/metadata/metadata.go b/pkg/cloud/metadata/metadata.go index af68db2896..ee644d67c0 100644 --- a/pkg/cloud/metadata/metadata.go +++ b/pkg/cloud/metadata/metadata.go @@ -24,7 +24,7 @@ import ( "k8s.io/klog/v2" ) -// Metadata is info about the ec2 instance on which the driver is running +// Metadata is info about the ec2 instance on which the driver is running. type Metadata struct { InstanceID string InstanceType string @@ -83,7 +83,7 @@ func retrieveK8sMetadata(k8sAPIClient KubernetesAPIClient) (*Metadata, error) { return KubernetesAPIInstanceInfo(clientset) } -// Override the region on a Metadata object if it is non-empty +// Override the region on a Metadata object if it is non-empty. func (m *Metadata) overrideRegion(region string) *Metadata { if region != "" { m.Region = region diff --git a/pkg/cloud/volume_limits.go b/pkg/cloud/volume_limits.go index b1ee0174af..7b91db018d 100644 --- a/pkg/cloud/volume_limits.go +++ b/pkg/cloud/volume_limits.go @@ -160,7 +160,7 @@ func GetReservedSlotsForInstanceType(it string) int { // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-store-volumes.html // IMDS does not provide NVMe instance store data; we'll just list all instances here -// g5.48xlarge is not added to this table as it is in the maxVolumeLimits +// g5.48xlarge is not added to this table as it is in the maxVolumeLimits. var nvmeInstanceStoreVolumes = map[string]int{ "c1.medium": 1, "c1.xlarge": 4, @@ -513,7 +513,7 @@ var nvmeInstanceStoreVolumes = map[string]int{ // https://aws.amazon.com/ec2/instance-types // Despite the dl1.24xlarge having Gaudi Accelerators describe instance types considers them GPUs as such that instance type is in this table -// g5.48xlarge is not added to this table as it is in the maxVolumeLimits +// g5.48xlarge is not added to this table as it is in the maxVolumeLimits. var gpuInstanceGpus = map[string]int{ "dl1.24xlarge": 8, "g3.16xlarge": 4, diff --git a/pkg/coalescer/coalescer.go b/pkg/coalescer/coalescer.go index db4e23f5c3..9fbc85afca 100644 --- a/pkg/coalescer/coalescer.go +++ b/pkg/coalescer/coalescer.go @@ -30,7 +30,7 @@ import ( // // When the delay on the request expires (determined by the time the first request comes in), the merged // input is passed to the execution function, and the result to all waiting callers (those that were -// not rejected during the merge step) +// not rejected during the merge step). type Coalescer[InputType any, ResultType any] interface { // Coalesce is a function to coalesce a given input // key = only requests with this same key will be coalesced (such as volume ID) @@ -45,7 +45,7 @@ type Coalescer[InputType any, ResultType any] interface { // mergeFunction = a function to merge a new input with the existing inputs // (should return an error if the new input cannot be combined with the existing inputs, // otherwise return the new merged input) -// executeFunction = the function to call when the delay expires +// executeFunction = the function to call when the delay expires. func New[InputType any, ResultType any](delay time.Duration, mergeFunction func(input InputType, existing InputType) (InputType, error), executeFunction func(key string, input InputType) (ResultType, error), @@ -63,21 +63,21 @@ func New[InputType any, ResultType any](delay time.Duration, return &c } -// Type to store a result or error in channels +// Type to store a result or error in channels. type result[ResultType any] struct { result ResultType err error } // Type to send inputs from Coalesce() to coalescerThread() via channel -// Includes a return channel for the result +// Includes a return channel for the result. type newInput[InputType any, ResultType any] struct { key string input InputType resultChannel chan result[ResultType] } -// Type to store pending inputs in the input map +// Type to store pending inputs in the input map. type pendingInput[InputType any, ResultType any] struct { input InputType resultChannels []chan result[ResultType] diff --git a/pkg/coalescer/coalescer_test.go b/pkg/coalescer/coalescer_test.go index c39cdc0640..ca705fe906 100644 --- a/pkg/coalescer/coalescer_test.go +++ b/pkg/coalescer/coalescer_test.go @@ -29,7 +29,7 @@ var ( // Merge function used to test the coalescer // For testing purposes, positive numbers are added to the existing input, -// and negative numbers return an error ("fail to merge") +// and negative numbers return an error ("fail to merge"). func mockMerge(input int, existing int) (int, error) { if input < 0 { return 0, errFailedToMerge @@ -39,7 +39,7 @@ func mockMerge(input int, existing int) (int, error) { // Execute function used to test the coalescer // For testing purposes, small numbers (numbers less than 100) successfully execute, -// and large numbers (numbers 100 or greater) fail to execute +// and large numbers (numbers 100 or greater) fail to execute. func mockExecute(_ string, input int) (string, error) { if input < 100 { return "success", nil diff --git a/pkg/driver/constants.go b/pkg/driver/constants.go index 17d6ab69c8..4f5aa7d6f5 100644 --- a/pkg/driver/constants.go +++ b/pkg/driver/constants.go @@ -18,41 +18,41 @@ package driver import "time" -// constants of keys in PublishContext +// constants of keys in PublishContext. const ( // devicePathKey represents key for device path in PublishContext - // devicePath is the device path where the volume is attached to + // devicePath is the device path where the volume is attached to. DevicePathKey = "devicePath" ) -// constants of keys in VolumeContext +// constants of keys in VolumeContext. const ( // VolumeAttributePartition represents key for partition config in VolumeContext - // this represents the partition number on a device used to mount + // this represents the partition number on a device used to mount. VolumeAttributePartition = "partition" ) -// constants of keys in volume parameters +// constants of keys in volume parameters. const ( - // VolumeTypeKey represents key for volume type + // VolumeTypeKey represents key for volume type. VolumeTypeKey = "type" - // IopsPerGBKey represents key for IOPS per GB + // IopsPerGBKey represents key for IOPS per GB. IopsPerGBKey = "iopspergb" - // AllowAutoIOPSPerGBIncreaseKey represents key for allowing automatic increase of IOPS + // AllowAutoIOPSPerGBIncreaseKey represents key for allowing automatic increase of IOPS. AllowAutoIOPSPerGBIncreaseKey = "allowautoiopspergbincrease" - // Iops represents key for IOPS for volume + // Iops represents key for IOPS for volume. IopsKey = "iops" - // ThroughputKey represents key for throughput + // ThroughputKey represents key for throughput. ThroughputKey = "throughput" - // EncryptedKey represents key for whether filesystem is encrypted + // EncryptedKey represents key for whether filesystem is encrypted. EncryptedKey = "encrypted" - // KmsKeyId represents key for KMS encryption key + // KmsKeyId represents key for KMS encryption key. KmsKeyIDKey = "kmskeyid" // PVCNameKey contains name of the PVC for which is a volume provisioned. @@ -62,58 +62,58 @@ const ( PVCNamespaceKey = "csi.storage.k8s.io/pvc/namespace" // PVNameKey contains name of the final PV that will be used for the dynamically - // provisioned volume + // provisioned volume. PVNameKey = "csi.storage.k8s.io/pv/name" - // VolumeSnapshotNameKey contains name of the snapshot + // VolumeSnapshotNameKey contains name of the snapshot. VolumeSnapshotNameKey = "csi.storage.k8s.io/volumesnapshot/name" - // VolumeSnapshotNamespaceKey contains namespace of the snapshot + // VolumeSnapshotNamespaceKey contains namespace of the snapshot. VolumeSnapshotNamespaceKey = "csi.storage.k8s.io/volumesnapshot/namespace" // VolumeSnapshotCotentNameKey contains name of the VolumeSnapshotContent that is the source - // for the snapshot + // for the snapshot. VolumeSnapshotContentNameKey = "csi.storage.k8s.io/volumesnapshotcontent/name" - // BlockExpressKey increases the iops limit for io2 volumes to the block express limit + // BlockExpressKey increases the iops limit for io2 volumes to the block express limit. BlockExpressKey = "blockexpress" // FSTypeKey configures the file system type that will be formatted during volume creation. FSTypeKey = "csi.storage.k8s.io/fstype" - // BlockSizeKey configures the block size when formatting a volume + // BlockSizeKey configures the block size when formatting a volume. BlockSizeKey = "blocksize" - // InodeSizeKey configures the inode size when formatting a volume + // InodeSizeKey configures the inode size when formatting a volume. InodeSizeKey = "inodesize" - // BytesPerInodeKey configures the `bytes-per-inode` when formatting a volume + // BytesPerInodeKey configures the `bytes-per-inode` when formatting a volume. BytesPerInodeKey = "bytesperinode" - // NumberOfInodesKey configures the `number-of-inodes` when formatting a volume + // NumberOfInodesKey configures the `number-of-inodes` when formatting a volume. NumberOfInodesKey = "numberofinodes" - // Ext4ClusterSizeKey enables the bigalloc option when formatting an ext4 volume + // Ext4ClusterSizeKey enables the bigalloc option when formatting an ext4 volume. Ext4BigAllocKey = "ext4bigalloc" - // Ext4ClusterSizeKey configures the cluster size when formatting an ext4 volume with the bigalloc option enabled + // Ext4ClusterSizeKey configures the cluster size when formatting an ext4 volume with the bigalloc option enabled. Ext4ClusterSizeKey = "ext4clustersize" // TagKeyPrefix contains the prefix of a volume parameter that designates it as - // a tag to be attached to the resource + // a tag to be attached to the resource. TagKeyPrefix = "tagSpecification" - // OutpostArn represents key for outpost's arn + // OutpostArn represents key for outpost's arn. OutpostArnKey = "outpostarn" ) -// constants of keys in snapshot parameters +// constants of keys in snapshot parameters. const ( - // FastSnapShotRestoreAvailabilityZones represents key for fast snapshot restore availability zones + // FastSnapShotRestoreAvailabilityZones represents key for fast snapshot restore availability zones. FastSnapshotRestoreAvailabilityZones = "fastsnapshotrestoreavailabilityzones" ) -// constants for volume tags and their values +// constants for volume tags and their values. const ( // ResourceLifecycleTagPrefix is prefix of tag for provisioned EBS volume that // marks them as owned by the cluster. Used only when --cluster-id is set. @@ -153,29 +153,29 @@ const ( PVNameTag = "kubernetes.io/created-for/pv/name" ) -// constants for default command line flag values +// constants for default command line flag values. const ( DefaultCSIEndpoint = "unix://tmp/csi.sock" DefaultModifyVolumeRequestHandlerTimeout = 2 * time.Second ) -// constants for fstypes +// constants for fstypes. const ( - // FSTypeExt2 represents the ext2 filesystem type + // FSTypeExt2 represents the ext2 filesystem type. FSTypeExt2 = "ext2" - // FSTypeExt3 represents the ext3 filesystem type + // FSTypeExt3 represents the ext3 filesystem type. FSTypeExt3 = "ext3" - // FSTypeExt4 represents the ext4 filesystem type + // FSTypeExt4 represents the ext4 filesystem type. FSTypeExt4 = "ext4" - // FSTypeXfs represents the xfs filesystem type + // FSTypeXfs represents the xfs filesystem type. FSTypeXfs = "xfs" - // FSTypeNtfs represents the ntfs filesystem type + // FSTypeNtfs represents the ntfs filesystem type. FSTypeNtfs = "ntfs" ) -// constants for node k8s API use +// constants for node k8s API use. const ( - // AgentNotReadyNodeTaintKey contains the key of taints to be removed on driver startup + // AgentNotReadyNodeTaintKey contains the key of taints to be removed on driver startup. AgentNotReadyNodeTaintKey = "ebs.csi.aws.com/agent-not-ready" ) diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index b0683a3d2b..dc4e0ef081 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -37,14 +37,14 @@ import ( "k8s.io/klog/v2" ) -// Supported access modes +// Supported access modes. const ( SingleNodeWriter = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER MultiNodeMultiWriter = csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER ) var ( - // controllerCaps represents the capability of controller service + // controllerCaps represents the capability of controller service. controllerCaps = []csi.ControllerServiceCapability_RPC_Type{ csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, @@ -58,7 +58,7 @@ var ( const trueStr = "true" const isManagedByDriver = trueStr -// ControllerService represents the controller service of CSI driver +// ControllerService represents the controller service of CSI driver. type ControllerService struct { cloud cloud.Cloud inFlight *internal.InFlight @@ -68,7 +68,7 @@ type ControllerService struct { csi.UnimplementedControllerServer } -// NewControllerService creates a new controller service +// NewControllerService creates a new controller service. func NewControllerService(c cloud.Cloud, o *Options) *ControllerService { return &ControllerService{ cloud: c, @@ -1011,7 +1011,7 @@ func getVolSizeBytes(req *csi.CreateVolumeRequest) (int64, error) { return volSizeBytes, nil } -// BuildOutpostArn returns the string representation of the outpost ARN from the given csi.TopologyRequirement.segments +// BuildOutpostArn returns the string representation of the outpost ARN from the given csi.TopologyRequirement.segments. func BuildOutpostArn(segments map[string]string) string { if len(segments[AwsPartitionKey]) == 0 { return "" diff --git a/pkg/driver/controller_modify_volume.go b/pkg/driver/controller_modify_volume.go index 8e1f797251..10f40b8c7b 100644 --- a/pkg/driver/controller_modify_volume.go +++ b/pkg/driver/controller_modify_volume.go @@ -35,7 +35,7 @@ import ( const ( ModificationKeyVolumeType = "type" - // Retained for backwards compatibility, but not recommended + // Retained for backwards compatibility, but not recommended. DeprecatedModificationKeyVolumeType = "volumeType" ModificationKeyIOPS = "iops" diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index c8eeb17cd6..031da14d10 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -52,7 +52,7 @@ const ( AwsRegionKey = "topology." + DriverName + "/region" AwsOutpostIDKey = "topology." + DriverName + "/outpost-id" WellKnownZoneTopologyKey = "topology.kubernetes.io/zone" - // Deprecated: Use the WellKnownZoneTopologyKey instead + // Deprecated: Use the WellKnownZoneTopologyKey instead. ZoneTopologyKey = "topology." + DriverName + "/zone" OSTopologyKey = "kubernetes.io/os" ) diff --git a/pkg/driver/node.go b/pkg/driver/node.go index fd1a9478f2..0c4ab698e0 100644 --- a/pkg/driver/node.go +++ b/pkg/driver/node.go @@ -44,10 +44,10 @@ import ( ) const ( - // default file system type to be used when it is not provided + // default file system type to be used when it is not provided. defaultFsType = FSTypeExt4 - // VolumeOperationAlreadyExists is message fmt returned to CO when there is another in-flight call on the given volumeID + // VolumeOperationAlreadyExists is message fmt returned to CO when there is another in-flight call on the given volumeID. VolumeOperationAlreadyExists = "An operation with the given volume=%q is already in progress" // sbeDeviceVolumeAttachmentLimit refers to the maximum number of volumes that can be attached to an instance on snow. @@ -72,9 +72,9 @@ var ( csi.NodeServiceCapability_RPC_GET_VOLUME_STATS, } - // taintRemovalInitialDelay is the initial delay for node taint removal + // taintRemovalInitialDelay is the initial delay for node taint removal. taintRemovalInitialDelay = 1 * time.Second - // taintRemovalBackoff is the exponential backoff configuration for node taint removal + // taintRemovalBackoff is the exponential backoff configuration for node taint removal. taintRemovalBackoff = wait.Backoff{ Duration: 500 * time.Millisecond, Factor: 2, @@ -82,7 +82,7 @@ var ( } ) -// NodeService represents the node service of CSI driver +// NodeService represents the node service of CSI driver. type NodeService struct { metadata metadata.MetadataService mounter mounter.Mounter @@ -91,7 +91,7 @@ type NodeService struct { csi.UnimplementedNodeServer } -// NewNodeService creates a new node service +// NewNodeService creates a new node service. func NewNodeService(o *Options, md metadata.MetadataService, m mounter.Mounter, k kubernetes.Interface) *NodeService { if k != nil { // Remove taint from node to indicate driver startup success @@ -761,7 +761,7 @@ func (d *NodeService) nodePublishVolumeForFileSystem(req *csi.NodePublishVolumeR return nil } -// getVolumesLimit returns the limit of volumes that the node supports +// getVolumesLimit returns the limit of volumes that the node supports. func (d *NodeService) getVolumesLimit() int64 { if d.options.VolumeAttachLimit >= 0 { return d.options.VolumeAttachLimit @@ -839,14 +839,14 @@ func collectMountOptions(fsType string, mntFlags []string) []string { return options } -// Struct for JSON patch operations +// Struct for JSON patch operations. type JSONPatch struct { OP string `json:"op,omitempty"` Path string `json:"path,omitempty"` Value interface{} `json:"value"` } -// removeTaintInBackground is a goroutine that retries removeNotReadyTaint with exponential backoff +// removeTaintInBackground is a goroutine that retries removeNotReadyTaint with exponential backoff. func removeTaintInBackground(k8sClient kubernetes.Interface, backoff wait.Backoff, removalFunc func(kubernetes.Interface) error) { backoffErr := wait.ExponentialBackoff(backoff, func() (bool, error) { err := removalFunc(k8sClient) diff --git a/pkg/driver/request_coalescing_test.go b/pkg/driver/request_coalescing_test.go index dabb2d4706..2b7b2c2c64 100644 --- a/pkg/driver/request_coalescing_test.go +++ b/pkg/driver/request_coalescing_test.go @@ -426,7 +426,7 @@ func testDuplicateRequest(t *testing.T, executor modifyVolumeExecutor) { wg.Wait() } -// TestResponseReturnTiming tests the caller of request coalescing blocking until receiving response from cloud.ResizeOrModifyDisk +// TestResponseReturnTiming tests the caller of request coalescing blocking until receiving response from cloud.ResizeOrModifyDisk. func testResponseReturnTiming(t *testing.T, executor modifyVolumeExecutor) { t.Helper() const NewVolumeType = "gp3" diff --git a/pkg/driver/version.go b/pkg/driver/version.go index f168fa4e2d..7adb7b9bac 100644 --- a/pkg/driver/version.go +++ b/pkg/driver/version.go @@ -22,7 +22,7 @@ import ( "runtime" ) -// These are set during build time via -ldflags +// These are set during build time via -ldflags. var ( driverVersion string gitCommit string diff --git a/pkg/expiringcache/expiring_cache.go b/pkg/expiringcache/expiring_cache.go index 962301d12d..74cb5c7c1d 100644 --- a/pkg/expiringcache/expiring_cache.go +++ b/pkg/expiringcache/expiring_cache.go @@ -30,7 +30,7 @@ import ( // // From the consumer's perspective, it behaves similarly to a map // KeyType is the type of the object that is used as a key -// ValueType is the type of the object that is stored +// ValueType is the type of the object that is stored. type ExpiringCache[KeyType comparable, ValueType any] interface { // Get operates identically to retrieving from a map, returning // the value and/or boolean indicating if the value existed in the map @@ -55,7 +55,7 @@ type expiringCache[KeyType comparable, ValueType any] struct { } // New returns a new ExpiringCache -// for a given KeyType, ValueType, and expiration delay +// for a given KeyType, ValueType, and expiration delay. func New[KeyType comparable, ValueType any](expirationDelay time.Duration) ExpiringCache[KeyType, ValueType] { return &expiringCache[KeyType, ValueType]{ expirationDelay: expirationDelay, diff --git a/pkg/mounter/mount.go b/pkg/mounter/mount.go index c75bfb4c00..344224522e 100644 --- a/pkg/mounter/mount.go +++ b/pkg/mounter/mount.go @@ -27,7 +27,7 @@ import ( // A mix & match of functions defined in upstream libraries. (FormatAndMount // from struct SafeFormatAndMount, PathExists from an old edition of // mount.Interface). Define it explicitly so that it can be mocked and to -// insulate from oft-changing upstream interfaces/structs +// insulate from oft-changing upstream interfaces/structs. type Mounter interface { mountutils.Interface diff --git a/pkg/util/template/funcs.go b/pkg/util/template/funcs.go index 7880b80912..3195138455 100644 --- a/pkg/util/template/funcs.go +++ b/pkg/util/template/funcs.go @@ -21,7 +21,7 @@ import ( "strings" ) -// Disable functions +// Disable functions. func html(...interface{}) (string, error) { return "", errors.New("cannot call 'html' function") } diff --git a/pkg/util/util.go b/pkg/util/util.go index 1d34932cf7..346dde5d5a 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -41,13 +41,13 @@ var ( isMACAddressRegex = regexp.MustCompile(`([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})`) ) -// RoundUpBytes rounds up the volume size in bytes up to multiplications of GiB +// RoundUpBytes rounds up the volume size in bytes up to multiplications of GiB. func RoundUpBytes(volumeSizeBytes int64) int64 { return roundUpSize(volumeSizeBytes, GiB) * GiB } // RoundUpGiB rounds up the volume size in bytes upto multiplications of GiB -// in the unit of GiB +// in the unit of GiB. func RoundUpGiB(volumeSizeBytes int64) (int32, error) { result := roundUpSize(volumeSizeBytes, GiB) if result > int64(math.MaxInt32) { @@ -57,7 +57,7 @@ func RoundUpGiB(volumeSizeBytes int64) (int32, error) { return int32(result), nil } -// BytesToGiB converts Bytes to GiB +// BytesToGiB converts Bytes to GiB. func BytesToGiB(volumeSizeBytes int64) int32 { result := volumeSizeBytes / GiB if result > int64(math.MaxInt32) { @@ -68,7 +68,7 @@ func BytesToGiB(volumeSizeBytes int64) int32 { return int32(result) } -// GiBToBytes converts GiB to Bytes +// GiBToBytes converts GiB to Bytes. func GiBToBytes(volumeSizeGiB int32) int64 { return int64(volumeSizeGiB) * GiB } @@ -136,18 +136,18 @@ func IsSBE(region string) bool { return region == "snow" } -// StringIsAlphanumeric returns true if a given string contains only English letters or numbers +// StringIsAlphanumeric returns true if a given string contains only English letters or numbers. func StringIsAlphanumeric(s string) bool { return isAlphanumericRegex(s) } -// CountMACAddresses returns the amount of MAC addresses within a string +// CountMACAddresses returns the amount of MAC addresses within a string. func CountMACAddresses(s string) int { matches := isMACAddressRegex.FindAllStringIndex(s, -1) return len(matches) } -// NormalizeWindowsPath normalizes a Windows path +// NormalizeWindowsPath normalizes a Windows path. func NormalizeWindowsPath(path string) string { normalizedPath := strings.ReplaceAll(path, "/", "\\") if strings.HasPrefix(normalizedPath, "\\") { diff --git a/tests/e2e/driver/driver.go b/tests/e2e/driver/driver.go index b3faa749c4..0fff49879c 100644 --- a/tests/e2e/driver/driver.go +++ b/tests/e2e/driver/driver.go @@ -32,13 +32,13 @@ type PVTestDriver interface { VolumeSnapshotTestDriver } -// DynamicPVTestDriver represents an interface for a CSI driver that supports DynamicPV +// DynamicPVTestDriver represents an interface for a CSI driver that supports DynamicPV. type DynamicPVTestDriver interface { // GetDynamicProvisionStorageClass returns a StorageClass dynamic provision Persistent Volume GetDynamicProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, volumeExpansion *bool, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass } -// PreProvisionedVolumeTestDriver represents an interface for a CSI driver that supports pre-provisioned volume +// PreProvisionedVolumeTestDriver represents an interface for a CSI driver that supports pre-provisioned volume. type PreProvisionedVolumeTestDriver interface { // GetPersistentVolume returns a PersistentVolume with pre-provisioned volumeHandle GetPersistentVolume(volumeID string, fsType string, size string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, namespace string, accessMode v1.PersistentVolumeAccessMode, volumeMode v1.PersistentVolumeMode) *v1.PersistentVolume diff --git a/tests/e2e/driver/ebs_csi_driver.go b/tests/e2e/driver/ebs_csi_driver.go index 52bfb9fabb..efab4571e3 100644 --- a/tests/e2e/driver/ebs_csi_driver.go +++ b/tests/e2e/driver/ebs_csi_driver.go @@ -29,12 +29,12 @@ const ( True = "true" ) -// Implement DynamicPVTestDriver interface +// Implement DynamicPVTestDriver interface. type ebsCSIDriver struct { driverName string } -// InitEbsCSIDriver returns ebsCSIDriver that implements DynamicPVTestDriver interface +// InitEbsCSIDriver returns ebsCSIDriver that implements DynamicPVTestDriver interface. func InitEbsCSIDriver() PVTestDriver { return &ebsCSIDriver{ driverName: ebscsidriver.DriverName, @@ -107,7 +107,7 @@ func (d *ebsCSIDriver) GetPersistentVolume(volumeID string, fsType string, size } } -// MinimumSizeForVolumeType returns the minimum disk size for each volumeType +// MinimumSizeForVolumeType returns the minimum disk size for each volumeType. func MinimumSizeForVolumeType(volumeType string) string { switch volumeType { case "st1", "sc1": diff --git a/tests/e2e/pre_provsioning.go b/tests/e2e/pre_provsioning.go index 6a3c82dfbd..a95e974561 100644 --- a/tests/e2e/pre_provsioning.go +++ b/tests/e2e/pre_provsioning.go @@ -48,7 +48,7 @@ var ( defaultDiskSizeBytes int64 = defaultDiskSize * 1024 * 1024 * 1024 ) -// Requires env AWS_AVAILABILITY_ZONES a comma separated list of AZs to be set +// Requires env AWS_AVAILABILITY_ZONES a comma separated list of AZs to be set. var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned", func() { f := framework.NewDefaultFramework("ebs") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged diff --git a/tests/e2e/requires_aws_api.go b/tests/e2e/requires_aws_api.go index 682593e292..c5a5696514 100644 --- a/tests/e2e/requires_aws_api.go +++ b/tests/e2e/requires_aws_api.go @@ -39,7 +39,7 @@ import ( const testTagNamePrefix = "testTag" const testTagValue = "3.1415926" -// generateTagName appends a random uuid to tag name to prevent clashes on parallel e2e test runs on shared cluster +// generateTagName appends a random uuid to tag name to prevent clashes on parallel e2e test runs on shared cluster. func generateTagName() string { return testTagNamePrefix + uuid.NewString()[:8] } diff --git a/tests/e2e/testsuites/dynamically_provisioned_cmd_volume_tester.go b/tests/e2e/testsuites/dynamically_provisioned_cmd_volume_tester.go index d28f2a60a8..f776e2f289 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_cmd_volume_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_cmd_volume_tester.go @@ -23,7 +23,7 @@ import ( // DynamicallyProvisionedCmdVolumeTest will provision required StorageClass(es), PVC(s) and Pod(s) // Waiting for the PV provisioner to create a new PV -// Testing if the Pod(s) Cmd is run with a 0 exit code +// Testing if the Pod(s) Cmd is run with a 0 exit code. type DynamicallyProvisionedCmdVolumeTest struct { CSIDriver driver.DynamicPVTestDriver Pods []PodDetails diff --git a/tests/e2e/testsuites/dynamically_provisioned_collocated_pod_tester.go b/tests/e2e/testsuites/dynamically_provisioned_collocated_pod_tester.go index 487ef47c3a..d4bd17ea17 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_collocated_pod_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_collocated_pod_tester.go @@ -23,7 +23,7 @@ import ( // DynamicallyProvisionedCollocatedPodTest will provision required StorageClass(es), PVC(s) and Pod(s) // Waiting for the PV provisioner to create a new PV -// Testing if multiple Pod(s) can write simultaneously +// Testing if multiple Pod(s) can write simultaneously. type DynamicallyProvisionedCollocatedPodTest struct { CSIDriver driver.DynamicPVTestDriver Pods []PodDetails diff --git a/tests/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go b/tests/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go index 20502c43b7..88ce4355f8 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go @@ -23,7 +23,7 @@ import ( // DynamicallyProvisionedDeletePodTest will provision required StorageClass and Deployment // Testing if the Pod can write and read to mounted volumes -// Deleting a pod, and again testing if the Pod can write and read to mounted volumes +// Deleting a pod, and again testing if the Pod can write and read to mounted volumes. type DynamicallyProvisionedDeletePodTest struct { CSIDriver driver.DynamicPVTestDriver Pod PodDetails diff --git a/tests/e2e/testsuites/dynamically_provisioned_read_only_volume_tester.go b/tests/e2e/testsuites/dynamically_provisioned_read_only_volume_tester.go index 92de0c68f9..0ada41e7ef 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_read_only_volume_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_read_only_volume_tester.go @@ -29,7 +29,7 @@ const expectedReadOnlyLog = "Read-only file system" // DynamicallyProvisionedReadOnlyVolumeTest will provision required StorageClass(es), PVC(s) and Pod(s) // Waiting for the PV provisioner to create a new PV -// Testing that the Pod(s) cannot write to the volume when mounted +// Testing that the Pod(s) cannot write to the volume when mounted. type DynamicallyProvisionedReadOnlyVolumeTest struct { CSIDriver driver.DynamicPVTestDriver Pods []PodDetails diff --git a/tests/e2e/testsuites/dynamically_provisioned_reclaim_policy_tester.go b/tests/e2e/testsuites/dynamically_provisioned_reclaim_policy_tester.go index 3211c18031..fb94bbe7d2 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_reclaim_policy_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_reclaim_policy_tester.go @@ -22,7 +22,7 @@ import ( ) // DynamicallyProvisionedReclaimPolicyTest will provision required PV(s) and PVC(s) -// Testing the correct behavior for different reclaimPolicies +// Testing the correct behavior for different reclaimPolicies. type DynamicallyProvisionedReclaimPolicyTest struct { CSIDriver driver.DynamicPVTestDriver Volumes []VolumeDetails diff --git a/tests/e2e/testsuites/dynamically_provisioned_topology_aware_volume_tester.go b/tests/e2e/testsuites/dynamically_provisioned_topology_aware_volume_tester.go index 1d64f77c2b..e4d24ee8e6 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_topology_aware_volume_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_topology_aware_volume_tester.go @@ -26,7 +26,7 @@ import ( // DynamicallyProvisionedTopologyAwareVolumeTest will provision required StorageClass(es), PVC(s) and Pod(s) // Waiting for the PV provisioner to create a new PV // Testing if the Pod(s) can write and read to mounted volumes -// Validate PVs have expected PV nodeAffinity +// Validate PVs have expected PV nodeAffinity. type DynamicallyProvisionedTopologyAwareVolumeTest struct { CSIDriver driver.DynamicPVTestDriver Pods []PodDetails diff --git a/tests/e2e/testsuites/dynamically_provisioned_volume_snapshot_tester.go b/tests/e2e/testsuites/dynamically_provisioned_volume_snapshot_tester.go index 23880778bf..e28405f875 100644 --- a/tests/e2e/testsuites/dynamically_provisioned_volume_snapshot_tester.go +++ b/tests/e2e/testsuites/dynamically_provisioned_volume_snapshot_tester.go @@ -28,7 +28,7 @@ import ( // Testing if the Pod(s) can write and read to mounted volumes // Create a snapshot, validate the data is still on the disk, and then write and read to it again // And finally delete the snapshot -// This test only supports a single volume +// This test only supports a single volume. type DynamicallyProvisionedVolumeSnapshotTest struct { CSIDriver driver.PVTestDriver Pod PodDetails diff --git a/tests/e2e/testsuites/e2e_utils.go b/tests/e2e/testsuites/e2e_utils.go index bb733acc6f..0c5a03d8c4 100644 --- a/tests/e2e/testsuites/e2e_utils.go +++ b/tests/e2e/testsuites/e2e_utils.go @@ -51,22 +51,22 @@ var DefaultGeneratedVolumeMount = VolumeMountDetails{ MountPathGenerate: "/mnt/test-", } -// PodCmdWriteToVolume returns pod command that would write to mounted volume +// PodCmdWriteToVolume returns pod command that would write to mounted volume. func PodCmdWriteToVolume(volumeMountPath string) string { return fmt.Sprintf("echo 'hello world' >> %s/data && grep 'hello world' %s/data && sync", volumeMountPath, volumeMountPath) } -// PodCmdContinuousWrite returns pod command that would continuously write to mounted volume +// PodCmdContinuousWrite returns pod command that would continuously write to mounted volume. func PodCmdContinuousWrite(volumeMountPath string) string { return fmt.Sprintf("while true; do echo \"$(date -u)\" >> /%s/out.txt; sleep 5; done", volumeMountPath) } -// PodCmdGrepVolumeData returns pod command that would check that a volume was written to by PodCmdWriteToVolume +// PodCmdGrepVolumeData returns pod command that would check that a volume was written to by PodCmdWriteToVolume. func PodCmdGrepVolumeData(volumeMountPath string) string { return fmt.Sprintf("grep 'hello world' %s/data", volumeMountPath) } -// IncreasePvcObjectStorage increases `storage` of a K8s PVC object by specified Gigabytes +// IncreasePvcObjectStorage increases `storage` of a K8s PVC object by specified Gigabytes. func IncreasePvcObjectStorage(pvc *v1.PersistentVolumeClaim, sizeIncreaseGi int32) resource.Quantity { pvcSize := pvc.Spec.Resources.Requests["storage"] delta := resource.Quantity{} @@ -76,7 +76,7 @@ func IncreasePvcObjectStorage(pvc *v1.PersistentVolumeClaim, sizeIncreaseGi int3 return pvcSize } -// WaitForPvToResize waiting for pvc size to be resized to desired size +// WaitForPvToResize waiting for pvc size to be resized to desired size. func WaitForPvToResize(c clientset.Interface, ns *v1.Namespace, pvName string, desiredSize resource.Quantity, timeout time.Duration, interval time.Duration) error { framework.Logf("waiting up to %v for pv resize in namespace %q to be complete", timeout, ns.Name) for start := time.Now(); time.Since(start) < timeout; time.Sleep(interval) { @@ -90,7 +90,7 @@ func WaitForPvToResize(c clientset.Interface, ns *v1.Namespace, pvName string, d return fmt.Errorf("gave up after waiting %v for pv %q to complete resizing", timeout, pvName) } -// ResizeTestPvc increases size of given `TestPersistentVolumeClaim` by specified Gigabytes +// ResizeTestPvc increases size of given `TestPersistentVolumeClaim` by specified Gigabytes. func ResizeTestPvc(client clientset.Interface, namespace *v1.Namespace, testPvc *TestPersistentVolumeClaim, sizeIncreaseGi int32) (updatedSize resource.Quantity) { framework.Logf("getting pvc name: %v", testPvc.persistentVolumeClaim.Name) pvc, _ := client.CoreV1().PersistentVolumeClaims(namespace.Name).Get(context.TODO(), testPvc.persistentVolumeClaim.Name, metav1.GetOptions{}) @@ -110,14 +110,14 @@ func ResizeTestPvc(client clientset.Interface, namespace *v1.Namespace, testPvc return updatedSize } -// AnnotatePvc annotates supplied k8s pvc object with supplied annotations +// AnnotatePvc annotates supplied k8s pvc object with supplied annotations. func AnnotatePvc(pvc *v1.PersistentVolumeClaim, annotations map[string]string) { for annotation, value := range annotations { pvc.Annotations[annotation] = value } } -// CheckPvAnnotations checks whether supplied k8s pv object contains supplied annotations +// CheckPvAnnotations checks whether supplied k8s pv object contains supplied annotations. func CheckPvAnnotations(pv *v1.PersistentVolume, annotations map[string]string) bool { for annotation, value := range annotations { if pv.Annotations[annotation] != value { @@ -127,7 +127,7 @@ func CheckPvAnnotations(pv *v1.PersistentVolume, annotations map[string]string) return true } -// WaitForPvToModify waiting for PV to be modified +// WaitForPvToModify waiting for PV to be modified. func WaitForPvToModify(c clientset.Interface, ns *v1.Namespace, pvName string, expectedAnnotations map[string]string, timeout time.Duration, interval time.Duration) error { framework.Logf("waiting up to %v for pv in namespace %q to be modified", timeout, ns.Name) @@ -142,7 +142,7 @@ func WaitForPvToModify(c clientset.Interface, ns *v1.Namespace, pvName string, e return fmt.Errorf("gave up after waiting %v for pv %q to complete modifying", timeout, pvName) } -// WaitForVacToApplyToPv waits for a PV's VAC to match the PVC's VAC +// WaitForVacToApplyToPv waits for a PV's VAC to match the PVC's VAC. func WaitForVacToApplyToPv(c clientset.Interface, ns *v1.Namespace, pvName string, expectedVac string, timeout time.Duration, interval time.Duration) error { framework.Logf("waiting up to %v for pv in namespace %q to be modified via VAC", timeout, ns.Name) diff --git a/tests/e2e/testsuites/pre_provisioned_read_only_volume_tester.go b/tests/e2e/testsuites/pre_provisioned_read_only_volume_tester.go index 04156914dd..2db452a027 100644 --- a/tests/e2e/testsuites/pre_provisioned_read_only_volume_tester.go +++ b/tests/e2e/testsuites/pre_provisioned_read_only_volume_tester.go @@ -26,7 +26,7 @@ import ( ) // PreProvisionedReadOnlyVolumeTest will provision required PV(s), PVC(s) and Pod(s) -// Testing that the Pod(s) cannot write to the volume when mounted +// Testing that the Pod(s) cannot write to the volume when mounted. type PreProvisionedReadOnlyVolumeTest struct { CSIDriver driver.PreProvisionedVolumeTestDriver Pods []PodDetails diff --git a/tests/e2e/testsuites/pre_provisioned_reclaim_policy_tester.go b/tests/e2e/testsuites/pre_provisioned_reclaim_policy_tester.go index 9a9538a713..c3e0b7b5ac 100644 --- a/tests/e2e/testsuites/pre_provisioned_reclaim_policy_tester.go +++ b/tests/e2e/testsuites/pre_provisioned_reclaim_policy_tester.go @@ -21,7 +21,7 @@ import ( ) // PreProvisionedReclaimPolicyTest will provision required PV(s) and PVC(s) -// Testing the correct behavior for different reclaimPolicies +// Testing the correct behavior for different reclaimPolicies. type PreProvisionedReclaimPolicyTest struct { CSIDriver driver.PreProvisionedVolumeTestDriver Volumes []VolumeDetails diff --git a/tests/e2e/testsuites/pre_provisioned_volume_tester.go b/tests/e2e/testsuites/pre_provisioned_volume_tester.go index 30143fd38f..56ec2cd119 100644 --- a/tests/e2e/testsuites/pre_provisioned_volume_tester.go +++ b/tests/e2e/testsuites/pre_provisioned_volume_tester.go @@ -22,7 +22,7 @@ import ( ) // PreProvisionedVolumeTest will provision required PV(s), PVC(s) and Pod(s) -// Testing if the Pod(s) can write and read to mounted volumes +// Testing if the Pod(s) can write and read to mounted volumes. type PreProvisionedVolumeTest struct { CSIDriver driver.PreProvisionedVolumeTestDriver Pods []PodDetails diff --git a/tests/e2e/testsuites/testsuites.go b/tests/e2e/testsuites/testsuites.go index f67c7e61e1..32ffe0f43b 100644 --- a/tests/e2e/testsuites/testsuites.go +++ b/tests/e2e/testsuites/testsuites.go @@ -47,7 +47,7 @@ const ( execTimeout = 10 * time.Second // Some pods can take much longer to get ready due to volume attach/detach latency. slowPodStartTimeout = 15 * time.Minute - // Description that will printed during tests + // Description that will printed during tests. failedConditionDescription = "Error status code" volumeSnapshotNameStatic = "volume-snapshot-tester" @@ -665,7 +665,7 @@ func (t *TestPod) WaitForRunning() { } // Ideally this would be in "k8s.io/kubernetes/test/e2e/framework" -// Similar to framework.WaitForPodSuccessInNamespace +// Similar to framework.WaitForPodSuccessInNamespace. var podFailedCondition = func(pod *v1.Pod) (bool, error) { switch pod.Status.Phase { case v1.PodFailed: