Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update offline installer to ignore comments in the manifests. #227

Merged
merged 12 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ jobs:
with:
version: latest
skip-cache: true
args: --out-format=colored-line-number
3 changes: 2 additions & 1 deletion dell-csi-helm-installer/csi-offline-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ run_command() {
# build_image_manifest
# builds a manifest of all the images referred to by the helm chart
build_image_manifest() {
local REGEX_COMMENTS="(#.*)"
local REGEX="([-_./:A-Za-z0-9]{3,}):([-_.A-Za-z0-9]{1,})"

status "Building image manifest file"
Expand All @@ -82,7 +83,7 @@ build_image_manifest() {
# - search all files in a diectory looking for strings that make $REGEX
# - exclude anything with double '//'' as that is a URL and not an image name
# - make sure at least one '/' is found
find "${D}" -type f -exec egrep -oh "${REGEX}" {} \; | egrep -v '//' | egrep '/' >> "${IMAGEMANIFEST}.tmp"
find "${D}" -type f -exec egrep -v "${REGEX_COMMENTS}" {} \; | egrep -oh "${REGEX}"| egrep -v '//' | egrep '/' >> "${IMAGEMANIFEST}.tmp"
fi
done

Expand Down
24 changes: 12 additions & 12 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (s *service) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest

nasServer, ok := params[keyNasServer]
if !ok {
return nil, status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "`%s` is a required parameter", keyNasServer))
return nil, status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "`%s` is a required parameter", keyNasServer))
}

// Add AdditionalFilesystemSize in size as Unity XT use this much size for metadata in filesystem
Expand All @@ -193,7 +193,7 @@ func (s *service) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest
filesystem, _ := fileAPI.FindFilesystemByName(ctx, volName)
if filesystem != nil {
content := filesystem.FileContent
if int64(content.SizeTotal) == size && content.NASServer.ID == nasServer && content.Pool.ID == storagePool {
if int64(content.SizeTotal) /* #nosec G115 -- This is a false positive */ == size && content.NASServer.ID == nasServer && content.Pool.ID == storagePool {
log.Info("Filesystem exists in the requested state with same size, NAS server and storage pool")
filesystem.FileContent.SizeTotal -= AdditionalFilesystemSize
return utils.GetVolumeResponseFromFilesystem(filesystem, arrayID, protocol, preferredAccessibility), nil
Expand Down Expand Up @@ -252,7 +252,7 @@ func (s *service) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest
vol, _ := volumeAPI.FindVolumeByName(ctx, volName)
if vol != nil {
content := vol.VolumeContent
if int64(content.SizeTotal) == size {
if int64(content.SizeTotal) /* #nosec G115 -- This is a false positive */ == size {
log.Info("Volume exists in the requested state with same size")
return utils.GetVolumeResponseFromVolume(vol, arrayID, protocol, preferredAccessibility), nil
}
Expand Down Expand Up @@ -666,7 +666,7 @@ func (s *service) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsReque
// Process the source snapshots and make CSI Snapshot
entries, err := s.getCSISnapshots(snaps, req.SourceVolumeId, protocol, arrayID)
if err != nil {
return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, err.Error()))
return nil, status.Error(codes.Unknown, utils.GetMessageWithRunID(rid, "%s", err.Error()))
}
log.Debugf("ListSnapshot successful for snapid: [%s]", req.SnapshotId)
return &csi.ListSnapshotsResponse{
Expand Down Expand Up @@ -846,7 +846,7 @@ func (s *service) ControllerExpandVolume(ctx context.Context, req *csi.Controlle
if err != nil {
return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find filesystem failed with error: %v", err))
}
expandVolumeResp.CapacityBytes = int64(filesystem.FileContent.SizeTotal) - AdditionalFilesystemSize
expandVolumeResp.CapacityBytes = int64(filesystem.FileContent.SizeTotal) /* #nosec G115 -- This is a false positive */ - AdditionalFilesystemSize
expandVolumeResp.NodeExpansionRequired = false
return expandVolumeResp, err
}
Expand Down Expand Up @@ -878,7 +878,7 @@ func (s *service) ControllerExpandVolume(ctx context.Context, req *csi.Controlle
if err != nil {
return nil, status.Error(codes.NotFound, utils.GetMessageWithRunID(rid, "Find volume failed with error: %v", err))
}
expandVolumeResp.CapacityBytes = int64(volume.VolumeContent.SizeTotal)
expandVolumeResp.CapacityBytes = int64(volume.VolumeContent.SizeTotal) /* #nosec G115 -- This is a false positive */
expandVolumeResp.NodeExpansionRequired = nodeExpansionRequired
return expandVolumeResp, err
}
Expand All @@ -896,7 +896,7 @@ func (s *service) getCSIVolumes(volumes []types.Volume) ([]*csi.ListVolumesRespo
// Create CSI volume
vi := &csi.Volume{
VolumeId: vol.VolumeContent.ResourceID,
CapacityBytes: int64(vol.VolumeContent.SizeTotal),
CapacityBytes: int64(vol.VolumeContent.SizeTotal), /* #nosec G115 -- This is a false positive */
VolumeContext: attributes,
}

Expand Down Expand Up @@ -1152,7 +1152,7 @@ func (s *service) createVolumeClone(ctx context.Context, crParams *CRParams, sou
// Validate the size parameter
snapSize := int64(snapResp.SnapshotContent.Size - AdditionalFilesystemSize)
if snapSize != size {
return nil, status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Requested size %d should be same as source filesystem size %d", size, snapSize))
return nil, status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Requested size %d should be same as source filesystem size %d", size, snapSize))
}
// Idempotency check
snapResp, err := snapAPI.FindSnapshotByName(ctx, volName)
Expand All @@ -1170,9 +1170,9 @@ func (s *service) createVolumeClone(ctx context.Context, crParams *CRParams, sou
csiVolResp.Volume.ContentSource = contentSource
return csiVolResp, nil
}
fsSize := int64(filesystem.FileContent.SizeTotal - AdditionalFilesystemSize)
fsSize := int64(filesystem.FileContent.SizeTotal - AdditionalFilesystemSize) /* #nosec G115 -- This is a false positive */
if size != fsSize {
return nil, status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Requested size %d should be same as source volume size %d",
return nil, status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Requested size %d should be same as source volume size %d",
size, fsSize))
}

Expand Down Expand Up @@ -1274,7 +1274,7 @@ func (s *service) createVolumeFromSnap(ctx context.Context, crParams *CRParams,
// Validate the size parameter
snapSize := int64(snapResp.SnapshotContent.Size - AdditionalFilesystemSize)
if snapSize != size {
return nil, status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Requested size %d should be same as source snapshot size %d", size, snapSize))
return nil, status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Requested size %d should be same as source snapshot size %d", size, snapSize))
}

snapResp, err := snapAPI.FindSnapshotByName(ctx, volName)
Expand Down Expand Up @@ -1320,7 +1320,7 @@ func (s *service) createVolumeFromSnap(ctx context.Context, crParams *CRParams,

// Validate the size parameter
if snapResp.SnapshotContent.Size != size {
return nil, status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Requested size %d should be same as source snapshot size %d", size, snapResp.SnapshotContent.Size))
return nil, status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Requested size %d should be same as source snapshot size %d", size, snapResp.SnapshotContent.Size))
}

volResp, _ := volumeAPI.FindVolumeByName(ctx, volName)
Expand Down
6 changes: 3 additions & 3 deletions service/csi_extension_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (s *service) checkIfNodeIsConnected(ctx context.Context, arrayID string, no
} else {
message = fmt.Sprintf("Host lookup failed. Error: %v", err)
}
log.Infof(message)
log.Infof("%s", message)
rep.Messages = append(rep.Messages, message)
rep.Connected = false
return nil
Expand All @@ -307,7 +307,7 @@ func (s *service) checkIfNodeIsConnected(ctx context.Context, arrayID string, no
healthContent := hostInitiator.HostInitiatorContent.Health
if healthContent.DescriptionIDs[0] == componentOkMessage {
message = fmt.Sprintf("FC Health is good for array:%s, Health:%s", arrayID, healthContent.DescriptionIDs[0])
log.Infof(message)
log.Infof("%s", message)
rep.Messages = append(rep.Messages, message)
rep.Connected = true
fcConnectivity = true
Expand All @@ -332,7 +332,7 @@ func (s *service) checkIfNodeIsConnected(ctx context.Context, arrayID string, no
healthContent := hostInitiator.HostInitiatorContent.Health
if healthContent.DescriptionIDs[0] == componentOkMessage {
message = fmt.Sprintf("iSCSI Health is good for array:%s, Health:%s", arrayID, healthContent.DescriptionIDs[0])
log.Infof(message)
log.Infof("%s", message)
rep.Messages = append(rep.Messages, message)
rep.Connected = true
break
Expand Down
9 changes: 4 additions & 5 deletions service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package service
import (
"context"
"errors"
"fmt"
"io"
"os"
"path"
Expand Down Expand Up @@ -322,12 +321,12 @@ func (s *service) NodeUnstageVolume(
// Get the device mounts
dev, err := GetDevice(ctx, devicePath)
if err != nil {
return nil, status.Error(codes.Internal, utils.GetMessageWithRunID(rid, err.Error()))
return nil, status.Error(codes.Internal, utils.GetMessageWithRunID(rid, "%s", err.Error()))
}
log.Debug("Rechecking dev mounts")
mnts, err := getDevMounts(ctx, dev)
if err != nil {
return nil, status.Error(codes.Internal, utils.GetMessageWithRunID(rid, err.Error()))
return nil, status.Error(codes.Internal, utils.GetMessageWithRunID(rid, "%s", err.Error()))
}
if len(mnts) > 0 {
return nil, status.Error(codes.Internal, utils.GetMessageWithRunID(rid, "Device mounts still present after unmounting target and staging mounts %#v", mnts))
Expand Down Expand Up @@ -1205,7 +1204,7 @@ func (s *service) checkVolumeMapping(ctx context.Context, volume *types.Volume,
hostcontent := hostaccess.HostContent
hostAccessID := hostcontent.ID
if hostAccessID == hostID {
log.Debugf(fmt.Sprintf("Volume %s has been published to the current node %s.", volName, host.HostContent.Name))
log.Debugf("Volume %s has been published to the current node %s.", volName, host.HostContent.Name)
return hostaccess.HLU, nil
}
}
Expand Down Expand Up @@ -1482,7 +1481,7 @@ func (s *service) disconnectVolume(ctx context.Context, volumeWWN, protocol stri
log.Debugf("Disconnect succesful for colume wwn %s", volumeWWN)
return nil
}
return status.Errorf(codes.Internal, utils.GetMessageWithRunID(rid, "disconnectVolume exceeded retry limit WWN %s devPath %s", volumeWWN, devPath))
return status.Errorf(codes.Internal, "%s", utils.GetMessageWithRunID(rid, "disconnectVolume exceeded retry limit WWN %s devPath %s", volumeWWN, devPath))
}

type publishContextData struct {
Expand Down
2 changes: 1 addition & 1 deletion service/utils/emcutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func getVolumeResponse(name, protocol, arrayID, resourceID string, size uint64,

volumeReq := &csi.Volume{
VolumeId: volID,
CapacityBytes: int64(size),
CapacityBytes: int64(size), /* #nosec G115 -- This is a false positive */
VolumeContext: VolumeContext,
AccessibleTopology: preferredAccessibility,
}
Expand Down
30 changes: 15 additions & 15 deletions service/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,31 @@ func validateCreateFsFromSnapshot(ctx context.Context, sourceFilesystemResp *typ

// Validate the storagePool parameter
if sourceFilesystemResp.FileContent.Pool.ID != storagePool {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source filesystem storage pool %s is different than the requested storage pool %s",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source filesystem storage pool %s is different than the requested storage pool %s",
sourceFilesystemResp.FileContent.Pool.ID, storagePool))
}

// Validate the thinProvisioned parameter
if sourceFilesystemResp.FileContent.IsThinEnabled != thin {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source filesystem thin provision %v is different than the requested thin provision %v",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source filesystem thin provision %v is different than the requested thin provision %v",
sourceFilesystemResp.FileContent.IsThinEnabled, thin))
}

// Validate the dataReduction parameter
if sourceFilesystemResp.FileContent.IsDataReductionEnabled != dataReduction {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source filesystem data reduction %v is different than the requested data reduction %v",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source filesystem data reduction %v is different than the requested data reduction %v",
sourceFilesystemResp.FileContent.IsDataReductionEnabled, dataReduction))
}

// Validate the tieringPolicy parameter
if int64(sourceFilesystemResp.FileContent.TieringPolicy) != tieringPolicy {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source filesystem tiering policy %v is different than the requested tiering policy %v",
if int64(sourceFilesystemResp.FileContent.TieringPolicy) /* #nosec G115 -- This is a false positive */ != tieringPolicy {
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source filesystem tiering policy %v is different than the requested tiering policy %v",
sourceFilesystemResp.FileContent.TieringPolicy, tieringPolicy))
}

// Validate the hostIOSize parameter
if sourceFilesystemResp.FileContent.HostIOSize != hostIoSize {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source filesystem host IO size %v is different than the requested host IO size %v",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source filesystem host IO size %v is different than the requested host IO size %v",
sourceFilesystemResp.FileContent.HostIOSize, hostIoSize))
}

Expand All @@ -176,22 +176,22 @@ func validateCreateVolumeFromSource(ctx context.Context, sourceVolResp *types.Vo

// Validate the storagePool parameter
if sourceVolResp.VolumeContent.Pool.ID != storagePool {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source volume storage pool %s is different than the requested storage pool %s",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source volume storage pool %s is different than the requested storage pool %s",
sourceVolResp.VolumeContent.Pool.ID, storagePool))
}
// Validate the tieringPolicy parameter
if int64(sourceVolResp.VolumeContent.TieringPolicy) != tieringPolicy {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source volume tiering policy %v is different than the requested tiering policy %v",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source volume tiering policy %v is different than the requested tiering policy %v",
sourceVolResp.VolumeContent.TieringPolicy, tieringPolicy))
}
// Validate the thinProvisioned parameter
if sourceVolResp.VolumeContent.IsThinEnabled != thin {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source volume thin provision %v is different than the requested thin provision %v",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source volume thin provision %v is different than the requested thin provision %v",
sourceVolResp.VolumeContent.IsThinEnabled, thin))
}
// Validate the dataReduction parameter
if sourceVolResp.VolumeContent.IsDataReductionEnabled != dataReduction {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Source volume data reduction %v is different than the requested data reduction %v",
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Source volume data reduction %v is different than the requested data reduction %v",
sourceVolResp.VolumeContent.IsDataReductionEnabled, dataReduction))
}

Expand All @@ -200,9 +200,9 @@ func validateCreateVolumeFromSource(ctx context.Context, sourceVolResp *types.Vo
}

// Validate the size parameter
if int64(sourceVolResp.VolumeContent.SizeTotal) != size {
return status.Errorf(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Requested size %d should be same as source volume size %d",
size, int64(sourceVolResp.VolumeContent.SizeTotal)))
if int64(sourceVolResp.VolumeContent.SizeTotal) /* #nosec G115 -- This is a false positive */ != size {
return status.Errorf(codes.InvalidArgument, "%s", utils.GetMessageWithRunID(rid, "Requested size %d should be same as source volume size %d",
size, int64(sourceVolResp.VolumeContent.SizeTotal))) /* #nosec G115 -- This is a false positive */
}

return nil
Expand Down Expand Up @@ -281,12 +281,12 @@ func ValidateCreateVolumeRequest(ctx context.Context, req *csi.CreateVolumeReque
// Validate volume capabilities
vcs := req.GetVolumeCapabilities()
if len(vcs) == 0 {
return "", "", 0, 0, 0, false, false, status.Error(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Controller Volume Capability are not provided"))
return "", "", 0, 0, 0, false, false, status.Error(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "%s", "Controller Volume Capability are not provided"))
}

supported, reason := valVolumeCaps(vcs, protocol)
if !supported {
return "", "", 0, 0, 0, false, false, status.Error(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "Volume Capabilities are not supported. Reason=["+reason+"]"))
return "", "", 0, 0, 0, false, false, status.Error(codes.InvalidArgument, utils.GetMessageWithRunID(rid, "%s", "Volume Capabilities are not supported. Reason=["+reason+"]"))
}

return
Expand Down