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

build: update Go 1.23 #5036

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ceph/ceph-csi/api

go 1.22.5
go 1.23.4

require (
github.com/ghodss/yaml v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions build.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ BASE_IMAGE=quay.io/ceph/ceph:v19
CEPH_VERSION=squid

# standard Golang options
GOLANG_VERSION=1.22.5
GOLANG_VERSION=1.23.4
GO111MODULE=on

# commitlint version
COMMITLINT_VERSION=latest

# static checks and linters
GOLANGCI_VERSION=v1.57.2
GOLANGCI_VERSION=v1.62.2

# external snapshotter version
# Refer: https://github.com/kubernetes-csi/external-snapshotter/releases
Expand Down
12 changes: 6 additions & 6 deletions e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ var _ = Describe(cephfsType, func() {
for i := range deplPods {
err = ensureStatSucceeds(deplPods[i].Name)
if err != nil {
framework.Failf(err.Error())
framework.Failf("%v", err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit more context in the errors would help here.

framework.Failf("ensureStatSucceeds failed for pod %q: %v", deplPods[i].Name, err.Error())

Something like that really helps the person receiving the error a lot. These things can/should be done everywhere.

}
}
// Kill ceph-fuse in cephfs-csi node plugin Pods.
Expand Down Expand Up @@ -797,12 +797,12 @@ var _ = Describe(cephfsType, func() {
// the pod with hopefully mounts working again.
err = deletePod(pod2Name, depl.Namespace, c, deployTimeout)
if err != nil {
framework.Failf(err.Error())
framework.Failf("%v", err.Error())
}
// Wait for the second Pod to be recreated.
err = waitForDeploymentComplete(c, depl.Name, depl.Namespace, deployTimeout)
if err != nil {
framework.Failf(err.Error())
framework.Failf("%v", err.Error())
}
// List Deployment's pods again to get name of the new pod.
deplPods, err = listPods(f, depl.Namespace, &metav1.ListOptions{
Expand All @@ -828,7 +828,7 @@ var _ = Describe(cephfsType, func() {
// Verify Pod pod2Name has its ceph-fuse mount working again.
err = ensureStatSucceeds(pod2Name)
if err != nil {
framework.Failf(err.Error())
framework.Failf("%v", err.Error())
}

// Delete created resources.
Expand Down Expand Up @@ -1083,7 +1083,7 @@ var _ = Describe(cephfsType, func() {
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}

// delete PVC and app
Expand Down Expand Up @@ -2413,7 +2413,7 @@ var _ = Describe(cephfsType, func() {
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}

// delete cloned ROX pvc and app
Expand Down
2 changes: 1 addition & 1 deletion e2e/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ var _ = Describe("nfs", func() {
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}

// delete PVC and app
Expand Down
10 changes: 5 additions & 5 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ var _ = Describe("RBD", func() {
}
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}
}

Expand Down Expand Up @@ -1798,7 +1798,7 @@ var _ = Describe("RBD", func() {
}
readOnlyErr := fmt.Sprintf("'%s': Operation not permitted", devPath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}
}
err = deletePVCAndDeploymentApp(f, pvcClone, appClone)
Expand Down Expand Up @@ -3357,7 +3357,7 @@ var _ = Describe("RBD", func() {
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}
}

Expand Down Expand Up @@ -3471,7 +3471,7 @@ var _ = Describe("RBD", func() {
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}
}

Expand Down Expand Up @@ -4133,7 +4133,7 @@ var _ = Describe("RBD", func() {
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) {
framework.Failf(stdErr)
framework.Failf("%v", stdErr)
}

// delete PVC and app
Expand Down
10 changes: 5 additions & 5 deletions e2e/rbd_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
)

//nolint:gomnd // numbers specify Kernel versions.
//nolint:mnd // numbers specify Kernel versions.
var nbdResizeSupport = []util.KernelVersion{
{
Version: 5,
Expand All @@ -48,7 +48,7 @@ var nbdResizeSupport = []util.KernelVersion{
}, // standard 5.3+ versions
}

//nolint:gomnd // numbers specify Kernel versions.
//nolint:mnd // numbers specify Kernel versions.
var fastDiffSupport = []util.KernelVersion{
{
Version: 5,
Expand All @@ -60,7 +60,7 @@ var fastDiffSupport = []util.KernelVersion{
}, // standard 5.3+ versions
}

//nolint:gomnd // numbers specify Kernel versions.
//nolint:mnd // numbers specify Kernel versions.
var deepFlattenSupport = []util.KernelVersion{
{
Version: 5,
Expand All @@ -75,7 +75,7 @@ var deepFlattenSupport = []util.KernelVersion{
// To use `io-timeout=0` we need
// www.mail-archive.com/[email protected]/msg38060.html
//
//nolint:gomnd // numbers specify Kernel versions.
//nolint:mnd // numbers specify Kernel versions.
var nbdZeroIOtimeoutSupport = []util.KernelVersion{
{
Version: 5,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ func waitToRemoveImagesFromTrash(f *framework.Framework, poolName string, t int)
return true, nil
}
errReason = fmt.Errorf("found %d images found in trash. Image details %v", len(imagesInTrash), imagesInTrash)
framework.Logf(errReason.Error())
framework.Logf("%v", errReason.Error())

return false, nil
})
Expand Down
6 changes: 3 additions & 3 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1580,10 +1580,10 @@ func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool {
// return value.
}

maj := strconv.Itoa(major)
min := strconv.Itoa(minor)
_maj := strconv.Itoa(major)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather ugly, not only because of the added _, also because comparing versions as a string.

Maybe it makes more sense to convert v.Major and v.Minor to integers?

_min := strconv.Itoa(minor)

return (v.Major > maj) || (v.Major == maj && v.Minor >= min)
return (v.Major > _maj) || (v.Major == _maj && v.Minor >= _min)
}

// waitForJobCompletion polls the status of the given job and waits until the
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ceph/ceph-csi

go 1.22.7
go 1.23.4

require (
github.com/IBM/keyprotect-go-client v0.15.1
Expand Down
8 changes: 4 additions & 4 deletions internal/cephfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (fs *Driver) Run(conf *util.Config) {
if conf.IsNodeServer && k8s.RunsOnKubernetes() {
nodeLabels, err = k8s.GetNodeLabels(conf.NodeID)
if err != nil {
log.FatalLogMsg(err.Error())
log.FatalLogMsg("%v", err.Error())
}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ func (fs *Driver) Run(conf *util.Config) {
if conf.IsNodeServer {
topology, err = util.GetTopologyFromDomainLabels(conf.DomainLabels, conf.NodeID, conf.DriverName)
if err != nil {
log.FatalLogMsg(err.Error())
log.FatalLogMsg("%v", err.Error())
}
fs.ns = NewNodeServer(
fs.cd, conf.Vtype,
Expand All @@ -176,7 +176,7 @@ func (fs *Driver) Run(conf *util.Config) {
if !conf.IsControllerServer && !conf.IsNodeServer {
topology, err = util.GetTopologyFromDomainLabels(conf.DomainLabels, conf.NodeID, conf.DriverName)
if err != nil {
log.FatalLogMsg(err.Error())
log.FatalLogMsg("%v", err.Error())
}
fs.ns = NewNodeServer(
fs.cd, conf.Vtype,
Expand All @@ -189,7 +189,7 @@ func (fs *Driver) Run(conf *util.Config) {
// configure CSI-Addons server and components
err = fs.setupCSIAddonsServer(conf)
if err != nil {
log.FatalLogMsg(err.Error())
log.FatalLogMsg("%v", err.Error())
}

server := csicommon.NewNonBlockingGRPCServer()
Expand Down
2 changes: 1 addition & 1 deletion internal/cephfs/mounter/volumemounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
var (
availableMounters []string

//nolint:gomnd // numbers specify Kernel versions.
//nolint:mnd // numbers specify Kernel versions.
quotaSupport = []util.KernelVersion{
{
Version: 4,
Expand Down
4 changes: 2 additions & 2 deletions internal/cephfs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func getBackingSnapshotRoot(
if err != nil {
log.ErrorLog(ctx, "failed to open %s when searching for snapshot root: %v", snapshotsBase, err)

return "", status.Errorf(codes.Internal, err.Error())
return "", status.Error(codes.Internal, err.Error())
}
defer dir.Close()

Expand All @@ -446,7 +446,7 @@ func getBackingSnapshotRoot(
if err != nil {
log.ErrorLog(ctx, "failed to read %s when searching for snapshot root: %v", snapshotsBase, err)

return "", status.Errorf(codes.Internal, err.Error())
return "", status.Error(codes.Internal, err.Error())
}

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/persistentvolume/persistentvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r *ReconcilePersistentVolume) getCredentials(

if name == "" || namespace == "" {
errStr := "secret name or secret namespace is empty"
log.ErrorLogMsg(errStr)
log.ErrorLogMsg("%v", errStr)

return nil, errors.New(errStr)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/csi-addons/rbd/encryptionkeyrotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func (ekrs *EncryptionKeyRotationServer) EncryptionKeyRotate(
err = status.Errorf(codes.NotFound, "volume ID %s not found", volID)
case errors.Is(err, util.ErrPoolNotFound):
log.ErrorLog(ctx, "failed to get backend volume for %s: %v", volID, err)
err = status.Errorf(codes.NotFound, err.Error())
err = status.Error(codes.NotFound, err.Error())
default:
err = status.Errorf(codes.Internal, err.Error())
err = status.Error(codes.Internal, err.Error())
}

return nil, err
Expand Down
10 changes: 5 additions & 5 deletions internal/csi-addons/rbd/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func getForceOption(ctx context.Context, parameters map[string]string) (bool, er
}
force, err := strconv.ParseBool(val)
if err != nil {
return false, status.Errorf(codes.Internal, err.Error())
return false, status.Error(codes.Internal, err.Error())
}

return force, nil
Expand Down Expand Up @@ -636,7 +636,7 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
// it takes time for this operation.
log.ErrorLog(ctx, err.Error())

return nil, status.Errorf(codes.Aborted, err.Error())
return nil, status.Error(codes.Aborted, err.Error())
}

if info.GetState() != librbd.MirrorImageEnabled.String() {
Expand Down Expand Up @@ -832,11 +832,11 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context,
if err != nil {
switch {
case errors.Is(err, corerbd.ErrImageNotFound):
err = status.Errorf(codes.NotFound, err.Error())
err = status.Error(codes.NotFound, err.Error())
case errors.Is(err, util.ErrPoolNotFound):
err = status.Errorf(codes.NotFound, err.Error())
err = status.Error(codes.NotFound, err.Error())
default:
err = status.Errorf(codes.Internal, err.Error())
err = status.Error(codes.Internal, err.Error())
}

return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/kms/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (vc *vaultConnection) Destroy() {
tmpFile, ok := vc.vaultConfig[api.EnvVaultCACert]
if ok {
// ignore error on failure to remove tmpfile (gosec complains)
//nolint:forcetypeassert // ignore error on failure to remove tmpfile
//nolint:forcetypeassert,errcheck // ignore error on failure to remove tmpfile
_ = os.Remove(tmpFile.(string))
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/kms/vault_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestInitVaultTokensKMS(t *testing.T) {
// add tenant "bob"
bob := make(map[string]interface{})
bob["vaultAddress"] = "https://vault.bob.example.org"
//nolint:forcetypeassert // as its a test we dont need to check assertion here.
//nolint:forcetypeassert,errcheck // as its a test we dont need to check assertion here.
args.Config["tenants"].(map[string]interface{})["bob"] = bob

_, err = initVaultTokensKMS(args)
Expand Down
2 changes: 1 addition & 1 deletion internal/liveness/liveness.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func recordLiveness(endpoint, drivername string, pollTime, timeout time.Duration
// register prometheus metrics
err := prometheus.Register(liveness)
if err != nil {
log.FatalLogMsg(err.Error())
log.FatalLogMsg("%v", err.Error())
}

csiConn, err := connlib.Connect(context.Background(), endpoint, liveMetricsManager)
Expand Down
16 changes: 8 additions & 8 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,9 +1122,9 @@ func (cs *ControllerServer) CreateSnapshot(
err = status.Errorf(codes.NotFound, "source Volume ID %s not found", req.GetSourceVolumeId())
case errors.Is(err, util.ErrPoolNotFound):
log.ErrorLog(ctx, "failed to get backend volume for %s: %v", req.GetSourceVolumeId(), err)
err = status.Errorf(codes.NotFound, err.Error())
err = status.Error(codes.NotFound, err.Error())
default:
err = status.Errorf(codes.Internal, err.Error())
err = status.Error(codes.Internal, err.Error())
}

return nil, err
Expand Down Expand Up @@ -1171,7 +1171,7 @@ func (cs *ControllerServer) CreateSnapshot(
return nil, status.Error(codes.AlreadyExists, err.Error())
}

return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}
if found {
return cloneFromSnapshot(ctx, rbdVol, rbdSnap, cr, req.GetParameters())
Expand Down Expand Up @@ -1253,7 +1253,7 @@ func cloneFromSnapshot(
log.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr)
}

return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}
defer vol.Destroy(ctx)

Expand All @@ -1265,14 +1265,14 @@ func cloneFromSnapshot(
err = vol.flattenRbdImage(ctx, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
if errors.Is(err, ErrFlattenInProgress) {
// if flattening is in progress, return error and do not cleanup
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
} else if err != nil {
uErr := undoSnapshotCloning(ctx, rbdVol, rbdSnap, vol, cr)
if uErr != nil {
log.WarningLog(ctx, "failed undoing reservation of snapshot: %s %v", rbdSnap.RequestName, uErr)
}

return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

// Update snapshot-name/snapshot-namespace/snapshotcontent-name details on
Expand Down Expand Up @@ -1566,9 +1566,9 @@ func (cs *ControllerServer) ControllerExpandVolume(
err = status.Errorf(codes.NotFound, "volume ID %s not found", volID)
case errors.Is(err, util.ErrPoolNotFound):
log.ErrorLog(ctx, "failed to get backend volume for %s: %v", volID, err)
err = status.Errorf(codes.NotFound, err.Error())
err = status.Error(codes.NotFound, err.Error())
default:
err = status.Errorf(codes.Internal, err.Error())
err = status.Error(codes.Internal, err.Error())
}

return nil, err
Expand Down
Loading
Loading