Skip to content

Commit

Permalink
batch dead code removal
Browse files Browse the repository at this point in the history
remove some of the codes that is not used anywhere.
  • Loading branch information
huww98 committed Dec 2, 2023
1 parent 8aefe93 commit 46291d4
Show file tree
Hide file tree
Showing 30 changed files with 3 additions and 319 deletions.
2 changes: 0 additions & 2 deletions build/lib/csiplugin-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const (
OSSSocketPath = "/etc/csi-tool/connector.sock"
// DiskSocketPath socket path
DiskSocketPath = "/etc/csi-tool/diskconnector.sock"
// ShellPath is the fsfreeze shell path
ShellPath = "/etc/csi-tool/fsfreeze.sh"
// GetPathDevice get the device of specific path
GetPathDevice = "df --output=source %s"
)
Expand Down
4 changes: 0 additions & 4 deletions build/multi-private/csiplugin-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
)

const (
// MBSIZE metrics
MBSIZE = 1024 * 1024
// LogFilename name of log file
LogFilename = "/var/run/csiplugin/csi_connector.log"
// PIDFilename name of pid file
Expand All @@ -28,8 +26,6 @@ const (
OSSSocketPath = "/etc/csi-tool/connector.sock"
// DiskSocketPath socket path
DiskSocketPath = "/etc/csi-tool/diskconnector.sock"
// ShellPath is the fsfreeze shell path
ShellPath = "/etc/csi-tool/fsfreeze.sh"
// GetPathDevice get the device of specific path
GetPathDevice = "df --output=source %s"
)
Expand Down
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ func setPrometheusVersion() {
}

const (
// MBSIZE MB size
MBSIZE = 1024 * 1024
// TypePluginSuffix is the suffix of all storage plugins.
TypePluginSuffix = "plugin.csi.alibabacloud.com"
// TypePluginVar is the yaml variable that needs to be replaced.
Expand Down
3 changes: 0 additions & 3 deletions pkg/cpfs/cpfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ type CPFS struct {
idServer *csicommon.DefaultIdentityServer
nodeServer *nodeServer
controllerServer csi.ControllerServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

// NewDriver create a cpfs driver object
Expand Down
14 changes: 0 additions & 14 deletions pkg/dbfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ import (
)

const (
// DRIVER tag
DRIVER = "driver"
// SERVER tag
SERVER = "server"
// MODE tag
MODE = "mode"
// ModeType tag
ModeType = "modeType"
// PATH tag
PATH = "path"
// ProtocolType tag
ProtocolType = "protocolType"
// FileSystemType tag
FileSystemType = "fileSystemType"
// ZoneID tag
ZoneID = "zoneId"
// ZoneIDTag tag
Expand Down
3 changes: 0 additions & 3 deletions pkg/dbfs/dbfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ type DBFS struct {
idServer *csicommon.DefaultIdentityServer
nodeServer *nodeServer
controllerServer csi.ControllerServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

// NewDriver create the identity/node/controller server and dbfs driver
Expand Down
4 changes: 1 addition & 3 deletions pkg/dbfs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"strings"
"time"

"github.com/aliyun/alibaba-cloud-sdk-go/services/dbfs"
"github.com/container-storage-interface/spec/lib/go/csi"
csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/log"
Expand All @@ -41,8 +40,7 @@ import (
)

type nodeServer struct {
dbfsClient dbfs.Client
clientSet *kubernetes.Clientset
clientSet *kubernetes.Clientset
*csicommon.DefaultNodeServer
nodeID string
maxVolumesPerNode int64
Expand Down
24 changes: 0 additions & 24 deletions pkg/dbfs/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import (
)

const (
// MetadataURL is metadata url
MetadataURL = "http://100.100.100.200/latest/meta-data/"
// RegionTag is region id
RegionTag = "region-id"
// NsenterCmd is the nsenter command
Expand All @@ -46,15 +44,6 @@ const (
GetDBFSMountCmd = "/usr/sbin/get_dbfs_mount_path"
)

var (
// VERSION should be updated by hand at each release
VERSION = "v1.14.8"
// GITCOMMIT will be overwritten automatically by the build system
GITCOMMIT = "HEAD"
// KubernetesAlicloudIdentity is the system identity for ecs client request
KubernetesAlicloudIdentity = fmt.Sprintf("Kubernetes.Alicloud/CsiProvision.Nas-%s", VERSION)
)

func (ns *nodeServer) DoDBFSMount(req *csi.NodeStageVolumeRequest, mountPoint string, volumeID string) error {
log.Log.Infof("DoDBFSMount: mount volume %s to target %s", volumeID, mountPoint)
dbfsPath, isAttached, err := checkDbfsAttached(volumeID)
Expand Down Expand Up @@ -308,19 +297,6 @@ func isPodMounted(pvName string) (bool, error) {
return true, nil
}

// GetPvNameFormMntPoint get pv name
func GetPvNameFormMntPoint(mntPath string) string {
if mntPath == "" {
return ""
}
if strings.HasSuffix(mntPath, "/mount") {
tmpPath := mntPath[0 : len(mntPath)-6]
pvName := filepath.Base(tmpPath)
return pvName
}
return ""
}

// getDbfsVersion get dbfs config version from config file
func getDbfsVersion(dbfsID string) string {
cmd := fmt.Sprintf("%s cat /opt/dbfs/config/version.conf", NsenterCmd)
Expand Down
7 changes: 0 additions & 7 deletions pkg/disk/bdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ const (
VfhpReconcilePeriod = 600
)

// PatchStringValue type
type PatchStringValue struct {
Op string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value"`
}

// BdfAttachInfo type
type BdfAttachInfo struct {
Depend bool `json:"depend"`
Expand Down
29 changes: 0 additions & 29 deletions pkg/disk/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,35 +627,6 @@ func waitForDiskInStatus(retryCount int, interval time.Duration, diskID string,
return status.Errorf(codes.Aborted, "WaitForDiskInStatus: after %d times of check, disk %s is still not in expected status %v", retryCount, diskID, expectedStatus)
}

// return disk with the define name
func findDiskByName(ecsClient *ecs.Client, name string, resourceGroupID string, sharedDisk bool) ([]ecs.Disk, error) {
resDisks := []ecs.Disk{}
describeDisksRequest := ecs.CreateDescribeDisksRequest()
describeDisksRequest.RegionId = GlobalConfigVar.Region
describeDisksRequest.DiskName = name
diskResponse, err := ecsClient.DescribeDisks(describeDisksRequest)

if err != nil {
return resDisks, err
}
if sharedDisk && len(diskResponse.Disks.Disk) == 0 {
describeDisksRequest.EnableShared = requests.NewBoolean(true)
diskResponse, err = ecsClient.DescribeDisks(describeDisksRequest)
if err != nil {
return resDisks, err
}
if diskResponse == nil {
return nil, status.Errorf(codes.Aborted, "Empty response when get disk %s", name)
}
}
for _, disk := range diskResponse.Disks.Disk {
if disk.DiskName == name {
resDisks = append(resDisks, disk)
}
}
return resDisks, err
}

func findDiskByID(diskID string, ecsClient *ecs.Client) (*ecs.Disk, error) {
describeDisksRequest := ecs.CreateDescribeDisksRequest()
describeDisksRequest.RegionId = GlobalConfigVar.Region
Expand Down
21 changes: 0 additions & 21 deletions pkg/disk/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const (
IAVolumeSnapshotKey = "csi.alibabacloud.com/snapshot-ia"
// SnapshotRequestTag interval limit
SnapshotRequestTag = "SNAPSHOT_REQUEST_INTERVAL"
// VolumeSnapshotContentName ...
VolumeSnapshotContentName = "csi.storage.k8s.io/volumesnapshotcontent/name"
// DefaultVolumeSnapshotClass ...
DefaultVolumeSnapshotClass = "alibabacloud-disk-snapshot"
// annDiskID tag
Expand Down Expand Up @@ -72,18 +70,8 @@ const (
//snapshotDeletedSuccessfully means that the delete snapshot success
snapshotDeletedSuccessfully string = "SnapshotDeletedSuccessfully"

// KubernetesAlicloudDiskDriver driver name
KubernetesAlicloudDiskDriver = "alicloud/disk"
// MetadataURL metadata URL
MetadataURL = "http://100.100.100.200/latest/meta-data/"
// DocumentURL document URL
DocumentURL = "http://100.100.100.200/latest/dynamic/instance-identity/document"
// RegionIDTag region ID
RegionIDTag = "region-id"
// InstanceID instance ID
InstanceID = "instance-id"
// DiskConflict invalid operation type
DiskConflict = "InvalidOperation.Conflict"
// IncorrectDiskStatus incorrect disk status
IncorrectDiskStatus = "IncorrectDiskStatus"
// NeverAttached status belongs to IncorrectDiskStatus
Expand All @@ -92,18 +80,13 @@ const (
DiskCreatingSnapshot = "DiskCreatingSnapshot"
// UserNotInTheWhiteList tag
UserNotInTheWhiteList = "UserNotInTheWhiteList"
// TagK8sPV tag
TagK8sPV = "k8s-pv"
// ZoneIDTag tag
ZoneIDTag = "zone-id"
// LogfilePrefix tag
LogfilePrefix = "/var/log/alicloud/provisioner"

// These are error codes of ECS OpenAPI

DiskNotAvailable = "InvalidDataDiskCategory" // InvalidDataDiskCategory.ValueNotSupported/NotSupported
DiskNotAvailableVer2 = "'DataDisk.n.Category' is not valid in this region."
DiskSizeNotAvailable = "InvalidDiskSize.NotSupported"
DiskPerformanceLevelNotMatch = "OperationDenied.PerformanceLevelNotMatch"
DiskIopsLimitExceeded = "InvalidProvisionedIops.LimitExceed"
DiskLimitExceeded = "InstanceDiskLimitExceeded"
Expand Down Expand Up @@ -138,10 +121,6 @@ const (
MBSIZE = 1024 * 1024
// GBSIZE tag
GBSIZE = 1024 * MBSIZE
// DefaultRegion is the default region id
DefaultRegion = "cn-hangzhou"
// DiskUUIDPath tag
DiskUUIDPath = "/host/etc/kubernetes/volumes/disk/uuid"
// ZoneID ...
ZoneID = "zoneId"
// instanceTypeLabel ...
Expand Down
27 changes: 0 additions & 27 deletions pkg/disk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,33 +684,6 @@ func snapshotBeforeDelete(volumeID string, ecsClient *ecs.Client) error {
return createStaticSnap(volumeID, resp.SnapshotId, GlobalConfigVar.SnapClient)
}

func updateSnapshotIAStatus(req *csi.CreateSnapshotRequest, status string) error {
volumeSnapshotName := req.Parameters[VolumeSnapshotName]
volumeSnapshotNameSpace := req.Parameters[VolumeSnapshotNamespace]
if volumeSnapshotName == "" || volumeSnapshotNameSpace == "" {
log.Log.Infof("CreateSnapshot: cannot get volumesnapshot name and namespace: %s, %s, %s", volumeSnapshotName, volumeSnapshotNameSpace, req.Name)
return nil
}

volumeSnapshot, err := GlobalConfigVar.SnapClient.SnapshotV1().VolumeSnapshots(volumeSnapshotNameSpace).Get(context.Background(), volumeSnapshotName, metav1.GetOptions{})
if err != nil {
log.Log.Warnf("CreateSnapshot: get volumeSnapshot(%s/%s) labels error: %s", volumeSnapshotNameSpace, volumeSnapshotName, err.Error())
return err
}
if volumeSnapshot.Labels == nil {
volumeSnapshot.Labels = map[string]string{}
}
volumeSnapshot.Labels[IAVolumeSnapshotKey] = status

_, err = GlobalConfigVar.SnapClient.SnapshotV1().VolumeSnapshots(volumeSnapshotNameSpace).Update(context.Background(), volumeSnapshot, metav1.UpdateOptions{})
if err != nil {
log.Log.Warnf("CreateSnapshot: Update VolumeSnapshot(%s/%s) IA Status error: %s", volumeSnapshotNameSpace, volumeSnapshotName, err.Error())
return err
}
log.Log.Infof("CreateSnapshot: updateSnapshot(%s/%s) IA Status successful %s", volumeSnapshotNameSpace, volumeSnapshotName, req.Name)
return nil
}

// DeleteSnapshot ...
func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {

Expand Down
3 changes: 0 additions & 3 deletions pkg/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ type DISK struct {
idServer csi.IdentityServer
nodeServer csi.NodeServer
controllerServer csi.ControllerServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

// GlobalConfig save global values for plugin
Expand Down
2 changes: 0 additions & 2 deletions pkg/disk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ const (
TenantUserUID = "alibabacloud.com/user-uid"
// CreateDiskARN ARN parameter of the CreateDisk interface
CreateDiskARN = "alibabacloud.com/createdisk-arn"
// SocketPath is path of connector sock
SocketPath = "/host/etc/csi-tool/diskconnector.sock"
// MaxVolumesPerNode define max ebs one node
MaxVolumesPerNode = 15
// NOUUID is xfs fs mount opts
Expand Down
2 changes: 0 additions & 2 deletions pkg/disk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ import (
var (
// VERSION should be updated by hand at each release
VERSION = "v1.14.6"
// GITCOMMIT will be overwritten automatically by the build system
GITCOMMIT = "HEAD"
// KubernetesAlicloudIdentity is the system identity for ecs client request
KubernetesAlicloudIdentity = fmt.Sprintf("Kubernetes.Alicloud/CsiProvision.Disk-%s", VERSION)

Expand Down
3 changes: 0 additions & 3 deletions pkg/ens/ens.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ type ENS struct {
idServer csi.IdentityServer
nodeServer csi.NodeServer
controllerServer csi.ControllerServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

func initDriver() {}
Expand Down
4 changes: 0 additions & 4 deletions pkg/ens/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ const (
MKFS_OPTIONS = "mkfsOptions"
// NOUUID is xfs fs mount opts
NOUUID = "nouuid"
// fsckErrorsCorrected tag
FSCK_ERRORS_CORRECTED = 1
// fsckErrorsUncorrected tag
FSCK_ERRORS_UNCORRECTED = 4
// SysConfigTag tag
SYS_CONFIG_TAG = "sysConfig"
// INPUT_OUTPUT_ERR tag
Expand Down
3 changes: 0 additions & 3 deletions pkg/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ type Local struct {
idServer *identityServer
nodeServer csi.NodeServer
controllerServer *controllerServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

const (
Expand Down
26 changes: 0 additions & 26 deletions pkg/local/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"os/exec"
"path/filepath"
"strconv"
"strings"
Expand All @@ -38,8 +37,6 @@ import (
)

const (
// MetadataURL is metadata server url
MetadataURL = "http://100.100.100.200/latest/meta-data/"
// InstanceID is the instance id tag
InstanceID = "instance-id"
// RegionIDTag is the region id tag
Expand All @@ -48,29 +45,6 @@ const (
MkfsOptions = "mkfsOptions"
)

// ErrParse is an error that is returned when parse operation fails
var ErrParse = errors.New("Cannot parse output of blkid")

func formatDevice(devicePath, fstype string) error {
output, err := exec.Command("mkfs", "-t", fstype, devicePath).CombinedOutput()
if err != nil {
return errors.New("FormatDevice error: " + string(output))
}
return nil
}

func isVgExist(vgName string) (bool, error) {
vgCmd := fmt.Sprintf("%s vgdisplay %s 2>&1 | grep 'VG Name' | grep %s | grep -v grep | wc -l", NsenterCmd, vgName, vgName)
vgline, err := utils.Run(vgCmd)
if err != nil {
return false, err
}
if strings.TrimSpace(vgline) == "1" {
return true, nil
}
return false, nil
}

// Get Local Disk Number from ecs API
// Requirements: The instance must have role which contains ecs::DescribeInstances, ecs::DescribeInstancesType.
func getLocalDeviceNum() (int, error) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/lvm/lvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ type LVM struct {
idServer *identityServer
nodeServer csi.NodeServer
controllerServer *controllerServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

const (
Expand Down
Loading

0 comments on commit 46291d4

Please sign in to comment.