Skip to content

Commit

Permalink
K8s dependency update (#48)
Browse files Browse the repository at this point in the history
* Upgrade k8s package

* Test

* Update packages + fixed sanity
  • Loading branch information
prankulmahajan committed Dec 7, 2021
1 parent 6749861 commit 12c5e07
Show file tree
Hide file tree
Showing 1,878 changed files with 282,944 additions and 69,659 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Expand Up @@ -99,8 +99,8 @@ func handle(logger *zap.Logger) {
// Setup CSI Driver
ibmCSIDriver := driver.GetIBMCSIDriver()

// Get and instance for the Mount Manager
mounter := mountManager.NewSafeMounter()
// Get new instance for the Mount Manager
mounter := mountManager.NewNodeMounter()

statUtil := &(driver.VolumeStatUtils{})

Expand Down
7 changes: 7 additions & 0 deletions dependency-check/suppression-file.xml
Expand Up @@ -100,6 +100,13 @@
<packageUrl regex="true">^pkg:golang/github\.com/coreos/go-etcd@.*$</packageUrl>
<cve>CVE-2020-15106</cve>
</suppress>
<suppress>
<notes><![CDATA[
file name: "k8s.io/kubernetes:1.21.0"
]]></notes>
<packageUrl regex="true">pkg:golang/k8s.io/kubernetes@1.21.0</packageUrl>
<cve>CVE-2021-25737</cve>
</suppress>
<suppress>
<notes><![CDATA[
file name: github.com/IBM-Cloud/go-etcd-rules:1.3.0
Expand Down
52 changes: 36 additions & 16 deletions go.mod
Expand Up @@ -3,29 +3,49 @@ module github.com/kubernetes-sigs/ibm-vpc-block-csi-driver
go 1.16

require (
github.com/IBM/ibm-csi-common v1.0.0-beta9
github.com/IBM/ibmcloud-volume-interface v1.0.0-beta8
github.com/IBM/ibmcloud-volume-vpc v1.0.0-beta12
github.com/container-storage-interface/spec v1.3.0
github.com/IBM/ibm-csi-common v1.0.0-beta12
github.com/IBM/ibmcloud-volume-interface v1.0.0-beta9
github.com/IBM/ibmcloud-volume-vpc v1.0.0-beta13
github.com/container-storage-interface/spec v1.5.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/google/uuid v1.1.2
github.com/kubernetes-csi/csi-test/v4 v4.2.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/kubernetes-csi/csi-test/v4 v4.3.0
github.com/prometheus/client_golang v1.7.1
github.com/stretchr/testify v1.6.1
github.com/stretchr/testify v1.7.0
go.uber.org/zap v1.15.0
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d
golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6 // indirect
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073
google.golang.org/grpc v1.34.0
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
k8s.io/kubernetes v1.14.2
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10 // indirect
k8s.io/kubernetes v1.21.0
k8s.io/mount-utils v0.21.0
)

replace (
k8s.io/api => k8s.io/api v0.0.0-20190516230258-a675ac48af67
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190313205120-8b27c41bdbb1
k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20190516232619-2bf8e45c8454
k8s.io/api => k8s.io/api v0.21.0
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.21.0
k8s.io/apimachinery => k8s.io/apimachinery v0.21.0
k8s.io/apiserver => k8s.io/apiserver v0.21.0
k8s.io/cli-runtime => k8s.io/cli-runtime v0.21.0
k8s.io/client-go => k8s.io/client-go v0.21.0
k8s.io/cloud-provider => k8s.io/cloud-provider v0.21.0
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.21.0
k8s.io/code-generator => k8s.io/code-generator v0.21.0
k8s.io/component-base => k8s.io/component-base v0.21.0
k8s.io/component-helpers => k8s.io/component-helpers v0.21.0
k8s.io/controller-manager => k8s.io/controller-manager v0.21.0
k8s.io/cri-api => k8s.io/cri-api v0.17.4-beta.0
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.21.0
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.21.0
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.21.0
k8s.io/kube-proxy => k8s.io/kube-proxy v0.21.0
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.21.0
k8s.io/kubectl => k8s.io/kubectl v0.21.0
k8s.io/kubelet => k8s.io/kubelet v0.21.0
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.21.0
k8s.io/metrics => k8s.io/metrics v0.21.0
k8s.io/mount-utils => k8s.io/mount-utils v0.21.0-beta.0
k8s.io/node-api => k8s.io/node-api v0.21.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.21.0
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.21.0
)
824 changes: 719 additions & 105 deletions go.sum

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg/ibmcsidriver/ibm_csi_driver.go
Expand Up @@ -23,10 +23,10 @@ import (
cloudProvider "github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider"
commonError "github.com/IBM/ibm-csi-common/pkg/messages"
nodeMetadata "github.com/IBM/ibm-csi-common/pkg/metadata"
mountManager "github.com/IBM/ibm-csi-common/pkg/mountmanager"
"github.com/IBM/ibm-csi-common/pkg/utils"
csi "github.com/container-storage-interface/spec/lib/go/csi"
"go.uber.org/zap"
"k8s.io/kubernetes/pkg/util/mount"
)

// IBMCSIDriver ...
Expand All @@ -50,7 +50,7 @@ func GetIBMCSIDriver() *IBMCSIDriver {
}

// SetupIBMCSIDriver ...
func (icDriver *IBMCSIDriver) SetupIBMCSIDriver(provider cloudProvider.CloudProviderInterface, mounter *mount.SafeFormatAndMount, statsUtil StatsUtils, metadata nodeMetadata.NodeMetadata, lgr *zap.Logger, name, vendorVersion string) error {
func (icDriver *IBMCSIDriver) SetupIBMCSIDriver(provider cloudProvider.CloudProviderInterface, mounter mountManager.Mounter, statsUtil StatsUtils, metadata nodeMetadata.NodeMetadata, lgr *zap.Logger, name, vendorVersion string) error {
icDriver.logger = lgr
icDriver.logger.Info("IBMCSIDriver-SetupIBMCSIDriver setting up IBM CSI Driver...")

Expand Down Expand Up @@ -171,7 +171,7 @@ func NewIdentityServer(icDriver *IBMCSIDriver) *CSIIdentityServer {
}

// NewNodeServer ...
func NewNodeServer(icDriver *IBMCSIDriver, mounter *mount.SafeFormatAndMount, statsUtil StatsUtils, nodeMetadata nodeMetadata.NodeMetadata) *CSINodeServer {
func NewNodeServer(icDriver *IBMCSIDriver, mounter mountManager.Mounter, statsUtil StatsUtils, nodeMetadata nodeMetadata.NodeMetadata) *CSINodeServer {
return &CSINodeServer{
Driver: icDriver,
Mounter: mounter,
Expand Down
4 changes: 2 additions & 2 deletions pkg/ibmcsidriver/ibm_csi_driver_test.go
Expand Up @@ -37,7 +37,7 @@ func initIBMCSIDriver(t *testing.T) *IBMCSIDriver {

// Create fake provider and mounter
provider, _ := cloudProvider.NewFakeIBMCloudStorageProvider("", logger)
mounter := mountManager.NewFakeSafeMounter()
mounter := mountManager.NewFakeNodeMounter()
statsUtil := &MockStatUtils{}

fakeNodeData := nodeMetadata.FakeNodeMetadata{}
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestSetupIBMCSIDriver(t *testing.T) {

// Create fake provider and mounter
provider, _ := cloudProvider.NewFakeIBMCloudStorageProvider("", logger)
mounter := mountManager.NewFakeSafeMounter()
mounter := mountManager.NewFakeNodeMounter()
statsUtil := &MockStatUtils{}

fakeNodeData := nodeMetadata.FakeNodeMetadata{}
Expand Down
23 changes: 11 additions & 12 deletions pkg/ibmcsidriver/node.go
Expand Up @@ -31,20 +31,20 @@ import (
commonError "github.com/IBM/ibm-csi-common/pkg/messages"
nodeMetadata "github.com/IBM/ibm-csi-common/pkg/metadata"
"github.com/IBM/ibm-csi-common/pkg/metrics"
"github.com/IBM/ibm-csi-common/pkg/mountmanager"
"github.com/IBM/ibm-csi-common/pkg/utils"
csi "github.com/container-storage-interface/spec/lib/go/csi"
"go.uber.org/zap"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/resizefs"
"k8s.io/kubernetes/pkg/volume/util/fs"
mount "k8s.io/mount-utils"
)

// CSINodeServer ...
type CSINodeServer struct {
Driver *IBMCSIDriver
Mounter *mount.SafeFormatAndMount
Mounter mountmanager.Mounter
Metadata nodeMetadata.NodeMetadata
Stats StatsUtils
// TODO: Only lock mutually exclusive calls and make locking more fine grained
Expand All @@ -61,7 +61,7 @@ type StatsUtils interface {

// MountUtils ...
type MountUtils interface {
Resize(mounter *mount.SafeFormatAndMount, devicePath string, deviceMountPath string) (bool, error)
Resize(mounter mountmanager.Mounter, devicePath string, deviceMountPath string) (bool, error)
}

// VolumeStatUtils ...
Expand All @@ -74,7 +74,7 @@ type VolumeMountUtils struct {

//FSInfo ...
func (su *VolumeStatUtils) FSInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
return fs.FsInfo(path)
return fs.Info(path)
}

const (
Expand Down Expand Up @@ -117,7 +117,6 @@ func (csiNS *CSINodeServer) NodePublishVolume(ctx context.Context, req *csi.Node
ctxLogger, requestID := utils.GetContextLoggerWithRequestID(ctx, false, &controlleRequestID)
ctxLogger.Info("CSINodeServer-NodePublishVolume...", zap.Reflect("Request", *req))
metrics.UpdateDurationFromStart(ctxLogger, "NodePublishVolume", time.Now())

csiNS.mux.Lock()
defer csiNS.mux.Unlock()

Expand Down Expand Up @@ -205,7 +204,7 @@ func (csiNS *CSINodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.No
}

ctxLogger.Info("Unmounting target path", zap.String("targetPath", targetPath))
err := mount.CleanupMountPoint(targetPath, csiNS.Mounter.Interface, false /* bind mount */)
err := mount.CleanupMountPoint(targetPath, csiNS.Mounter, false /* bind mount */)
if err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.UnmountFailed, requestID, err, targetPath)
}
Expand Down Expand Up @@ -264,7 +263,7 @@ func (csiNS *CSINodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeSt
ctxLogger.Info("Found device path ", zap.String("devicePath", devicePath), zap.String("source", source))

// Check target path
exists, err := csiNS.Mounter.ExistsPath(stagingTargetPath)
exists, err := csiNS.Mounter.PathExists(stagingTargetPath)
if err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.TargetPathCheckFailed, requestID, err, stagingTargetPath)
}
Expand Down Expand Up @@ -301,7 +300,7 @@ func (csiNS *CSINodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeSt

// FormatAndMount will format only if needed
ctxLogger.Info("Formating and mounting ", zap.String("source", source), zap.String("stagingTargetPath", stagingTargetPath), zap.String("fsType", fsType), zap.Reflect("options", options))
err = csiNS.Mounter.FormatAndMount(source, stagingTargetPath, fsType, options)
err = csiNS.Mounter.NewSafeFormatAndMount().FormatAndMount(source, stagingTargetPath, fsType, options)
if err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.FormatAndMountFailed, requestID, err, source, stagingTargetPath)
}
Expand Down Expand Up @@ -329,7 +328,7 @@ func (csiNS *CSINodeServer) NodeUnstageVolume(ctx context.Context, req *csi.Node
}

ctxLogger.Info("Unmounting staging target path", zap.String("stagingTargetPath", stagingTargetPath))
err := mount.CleanupMountPoint(stagingTargetPath, csiNS.Mounter.Interface, false /* bind mount */)
err := mount.CleanupMountPoint(stagingTargetPath, csiNS.Mounter, false /* bind mount */)
if err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.UnmountFailed, requestID, err, stagingTargetPath)
}
Expand Down Expand Up @@ -537,8 +536,8 @@ func (su *VolumeStatUtils) IsDevicePathNotExist(devicePath string) bool {
}

// Resize expands the fs
func (volMountUtils *VolumeMountUtils) Resize(mounter *mount.SafeFormatAndMount, devicePath string, deviceMountPath string) (bool, error) {
r := resizefs.NewResizeFs(mounter)
func (volMountUtils *VolumeMountUtils) Resize(mounter mountmanager.Mounter, devicePath string, deviceMountPath string) (bool, error) {
r := mount.NewResizeFs(mounter.NewSafeFormatAndMount().Exec)
if _, err := r.Resize(devicePath, deviceMountPath); err != nil {
return false, err
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/ibmcsidriver/node_helper.go
Expand Up @@ -32,14 +32,14 @@ import (
// findDevicePath finds path of device and verifies its existence
func (csiNS *CSINodeServer) findDevicePathSource(ctxLogger *zap.Logger, devicePath string, volumeID string /*TODO may be required in future*/) (string, error) {
ctxLogger.Info("CSINodeServer-findDevicePathSource...")
exists, err := csiNS.Mounter.ExistsPath(devicePath)
exists, err := csiNS.Mounter.PathExists(devicePath)
if err != nil || !exists {
ctxLogger.Warn("Device path not found, trying to fix by udevadm trigger", zap.String("DevicePath", devicePath))
if err = csiNS.udevadmTrigger(ctxLogger); err != nil {
ctxLogger.Error("Failed to execute udevadm trigger, will try to check device path again", zap.Error(err))
}
// Re-verifying device path and returning error accordingly
exists, err = csiNS.Mounter.ExistsPath(devicePath)
exists, err = csiNS.Mounter.PathExists(devicePath)
if err != nil {
return "", err
}
Expand All @@ -60,20 +60,20 @@ func (csiNS *CSINodeServer) processMount(ctxLogger *zap.Logger, requestID, stagi
fsTypeField := zap.String("fsType", fsType)
optionsField := zap.Reflect("options", options)
ctxLogger.Info("CSINodeServer-processMount...", stagingTargetPathField, targetPathField, fsTypeField, optionsField)
if err := csiNS.Mounter.Interface.MakeDir(targetPath); err != nil {
if err := csiNS.Mounter.MakeDir(targetPath); err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.TargetPathCreateFailed, requestID, err, targetPath)
}
err := csiNS.Mounter.Interface.Mount(stagingTargetPath, targetPath, fsType, options)
err := csiNS.Mounter.Mount(stagingTargetPath, targetPath, fsType, options)
if err != nil {
notMnt, mntErr := csiNS.Mounter.Interface.IsLikelyNotMountPoint(targetPath)
notMnt, mntErr := csiNS.Mounter.IsLikelyNotMountPoint(targetPath)
if mntErr != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.MountPointValidateError, requestID, mntErr, targetPath)
}
if !notMnt {
if mntErr = csiNS.Mounter.Interface.Unmount(targetPath); mntErr != nil {
if mntErr = csiNS.Mounter.Unmount(targetPath); mntErr != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.UnmountFailed, requestID, mntErr, targetPath)
}
notMnt, mntErr = csiNS.Mounter.Interface.IsLikelyNotMountPoint(targetPath)
notMnt, mntErr = csiNS.Mounter.IsLikelyNotMountPoint(targetPath)
if mntErr != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.MountPointValidateError, requestID, mntErr, targetPath)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (csiNS *CSINodeServer) processMountForBlock(ctxLogger *zap.Logger, requestI
ctxLogger.Info("Found device path ", zap.String("devicePath", devicePath), zap.String("source", source))

targetDir := filepath.Dir(target)
exists, err := csiNS.Mounter.ExistsPath(targetDir)
exists, err := csiNS.Mounter.PathExists(targetDir)
if err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.TargetPathCheckFailed, requestID, err, targetDir)
}
Expand All @@ -132,7 +132,7 @@ func (csiNS *CSINodeServer) processMountForBlock(ctxLogger *zap.Logger, requestI
}

ctxLogger.Info("Mounting source to target", zap.String("source", source), zap.String("target", target))
if err := csiNS.Mounter.Interface.Mount(source, target, "", options); err != nil {
if err := csiNS.Mounter.Mount(source, target, "", options); err != nil {
if removeErr := os.Remove(target); removeErr != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.RemoveMountTargetFailed, requestID, removeErr, target)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ibmcsidriver/node_test.go
Expand Up @@ -26,13 +26,13 @@ import (
"strings"
"testing"

"github.com/IBM/ibm-csi-common/pkg/mountmanager"
"github.com/IBM/ibm-csi-common/pkg/utils"
csi "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/kubernetes/pkg/util/mount"
)

const defaultVolumeID = "csiprovidervolumeid"
Expand All @@ -51,7 +51,7 @@ type MockMountUtils struct {
}

// Resize expands the fs
func (mu *MockMountUtils) Resize(mounter *mount.SafeFormatAndMount, devicePath string, deviceMountPath string) (bool, error) {
func (mu *MockMountUtils) Resize(mounter mountmanager.Mounter, devicePath string, deviceMountPath string) (bool, error) {
if strings.Contains(deviceMountPath, "fake-") {
return false, fmt.Errorf("failed to resize fs")
} else if strings.Contains(deviceMountPath, "valid-") {
Expand Down

0 comments on commit 12c5e07

Please sign in to comment.