diff --git a/go.mod b/go.mod index aef2d9c01..58c9c022a 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( github.com/RoaringBitmap/roaring v1.9.3 github.com/google/uuid v1.6.0 github.com/longhorn/backupstore v0.0.0-20240417071544-3bd377eeefeb - github.com/longhorn/go-common-libs v0.0.0-20240411093823-b8862efb8e03 - github.com/longhorn/go-spdk-helper v0.0.0-20240415074119-eb1e91922189 + github.com/longhorn/go-common-libs v0.0.0-20240422073843-1578e42a50bd + github.com/longhorn/go-spdk-helper v0.0.0-20240422131908-185e91a748ad github.com/longhorn/longhorn-engine v1.6.0-dev-20231217.0.20240418025706-519598108463 - github.com/longhorn/longhorn-spdk-engine v0.0.0-20240417162837-d96ef4ed8c28 + github.com/longhorn/longhorn-spdk-engine v0.0.0-20240423045523-73fd7e6f9745 github.com/longhorn/types v0.0.0-20240417112740-a0d8514936b8 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 @@ -68,7 +68,7 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect - k8s.io/apimachinery v0.29.4 // indirect + k8s.io/apimachinery v0.30.0 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect ) diff --git a/go.sum b/go.sum index c8fd07f19..1af519ced 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,6 @@ github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0 github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/gammazero/workerpool v1.1.3 h1:WixN4xzukFoN0XSeXF6puqEqFTl2mECI9S6W44HWy9Q= github.com/gammazero/workerpool v1.1.3/go.mod h1:wPjyBLDbyKnUn2XwwyD3EEwo9dHutia9/fwNmSHWACc= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -69,14 +67,14 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/longhorn/backupstore v0.0.0-20240417071544-3bd377eeefeb h1:GkAG0P7QI32PYgjLBV6VvaEAM/Z9dKyPohccU1js+Uk= github.com/longhorn/backupstore v0.0.0-20240417071544-3bd377eeefeb/go.mod h1:4cbJWtlrD2cGTQxQLtdlPTYopiJiusXH7CpOBrn/s3k= -github.com/longhorn/go-common-libs v0.0.0-20240411093823-b8862efb8e03 h1:RN7mq4FrbHcAeemI5tDha9u4X+RSRrPugD1cY1FHdvo= -github.com/longhorn/go-common-libs v0.0.0-20240411093823-b8862efb8e03/go.mod h1:7onp+E4hSg2DnB40dJU0Y7adrvykGg6jHxOb48imPGg= -github.com/longhorn/go-spdk-helper v0.0.0-20240415074119-eb1e91922189 h1:g4CoDfmj1rrJPNUJWPAp4LKa+9IGr+nQbQLOfOnxg4s= -github.com/longhorn/go-spdk-helper v0.0.0-20240415074119-eb1e91922189/go.mod h1:99yD4ZjORUMmuxZRTDd9+AzTwc0mpKCWQJoTkKwEZJU= +github.com/longhorn/go-common-libs v0.0.0-20240422073843-1578e42a50bd h1:Jjg8nogQ04/DaofTXsHWCRrBEf4g2ufwfzrsAP4SgrQ= +github.com/longhorn/go-common-libs v0.0.0-20240422073843-1578e42a50bd/go.mod h1:qppGSy9WsxH1C9T6yhSMvG53ynpasyKOH/n9e1jr8mw= +github.com/longhorn/go-spdk-helper v0.0.0-20240422131908-185e91a748ad h1:DhZYpqJp5t5RYyNctTBlz2pgfRxV3tJ/qLshXD4HY3Q= +github.com/longhorn/go-spdk-helper v0.0.0-20240422131908-185e91a748ad/go.mod h1:CiKgQ6CKWCE4CrAUgQx7inzRT7Xzbo6JuDhdRTpaVkY= github.com/longhorn/longhorn-engine v1.6.0-dev-20231217.0.20240418025706-519598108463 h1:KxddgUYC9InOhe8MxfbxzOL5v9q7f5DyThxQGGKvqVw= github.com/longhorn/longhorn-engine v1.6.0-dev-20231217.0.20240418025706-519598108463/go.mod h1:WNiZl2l51I36/c8dewxkyWd0yBA5Anznzki0knKO88U= -github.com/longhorn/longhorn-spdk-engine v0.0.0-20240417162837-d96ef4ed8c28 h1:roV0nZayPLV5/zAfbeNpeJPpA2kDm9TRwSjN+cCT3mw= -github.com/longhorn/longhorn-spdk-engine v0.0.0-20240417162837-d96ef4ed8c28/go.mod h1:4BPAoCUpl+WqsEV7SswdsA8t7oehXKDPKScXP+PEWbc= +github.com/longhorn/longhorn-spdk-engine v0.0.0-20240423045523-73fd7e6f9745 h1:pAFMPOPdeU0rqSyMbrrKnwcXUri7dLNFGnEO9ghSqUQ= +github.com/longhorn/longhorn-spdk-engine v0.0.0-20240423045523-73fd7e6f9745/go.mod h1:21mmiI8dBDXzBiEUbCDoTXimCSbdFDn0MneZzINIqXA= github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003 h1:Jw9uANsGcHTxp6HcC++/vN17LfeuDmozHI2j6DoZf5E= github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003/go.mod h1:0CLeXlf59Lg6C0kjLSDf47ft73Dh37CwymYRKWwAn04= github.com/longhorn/sparse-tools v0.0.0-20240228120902-ce8c4c2e71ca h1:dECamLpXIlL7GRmiruGseb5xO6hGAWyu2xYm9D46mb8= @@ -227,14 +225,10 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/apimachinery v0.29.4 h1:RaFdJiDmuKs/8cm1M6Dh1Kvyh59YQFDcFuFTSmXes6Q= -k8s.io/apimachinery v0.29.4/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= -k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= -k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= +k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= +k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/mount-utils v0.29.4 h1:tW/URea4gtXlaVW7VObr52NQhS+z3SXTg1GUaFZjRL4= -k8s.io/mount-utils v0.29.4/go.mod h1:SHUMR9n3b6tLgEmlyT36cL6fV6Sjwa5CJhc0guCXvb0= k8s.io/mount-utils v0.30.0 h1:EceYTNYVabfpdtIAHC4KgMzoZkm1B8ovZ1J666mYZQI= k8s.io/mount-utils v0.30.0/go.mod h1:9sCVmwGLcV1MPvbZ+rToMDnl1QcGozy+jBPd0MsQLIo= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go index 6b4ee9623..7da93428a 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go @@ -576,7 +576,10 @@ func (c *Client) BdevRaidRemoveBaseBdev(name string) (removed bool, err error) { // "reconnectDelaySec": Controller reconnect delay in seconds // // "fastIOFailTimeoutSec": Fast I/O failure timeout in seconds -func (c *Client) BdevNvmeAttachController(name, subnqn, traddr, trsvcid string, trtype spdktypes.NvmeTransportType, adrfam spdktypes.NvmeAddressFamily, ctrlrLossTimeoutSec, reconnectDelaySec, fastIOFailTimeoutSec int32) (bdevNameList []string, err error) { +// +// "multipath": Multipathing behavior: disable, failover, multipath. Default is failover +func (c *Client) BdevNvmeAttachController(name, subnqn, traddr, trsvcid string, trtype spdktypes.NvmeTransportType, adrfam spdktypes.NvmeAddressFamily, + ctrlrLossTimeoutSec, reconnectDelaySec, fastIOFailTimeoutSec int32, multipath string) (bdevNameList []string, err error) { req := spdktypes.BdevNvmeAttachControllerRequest{ Name: name, NvmeTransportID: spdktypes.NvmeTransportID{ @@ -589,6 +592,7 @@ func (c *Client) BdevNvmeAttachController(name, subnqn, traddr, trsvcid string, CtrlrLossTimeoutSec: ctrlrLossTimeoutSec, ReconnectDelaySec: reconnectDelaySec, FastIOFailTimeoutSec: fastIOFailTimeoutSec, + Multipath: multipath, } cmdOutput, err := c.jsonCli.SendCommand("bdev_nvme_attach_controller", req) diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/types/nvme.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/types/nvme.go index b7fe46911..cdc80d5e4 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/types/nvme.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/types/nvme.go @@ -18,6 +18,14 @@ const ( NvmeAddressFamilyIntraHost = NvmeAddressFamily("intra_host") ) +type NvmeMultipathBehavior string + +const ( + NvmeMultipathBehaviorDisable = "disable" + NvmeMultipathBehaviorFailover = "failover" + NvmeMultipathBehaviorMultipath = "multipath" +) + type BdevDriverSpecificNvme []NvmeNamespaceInfo type NvmeNamespaceInfo struct { @@ -99,6 +107,8 @@ type BdevNvmeAttachControllerRequest struct { CtrlrLossTimeoutSec int32 `json:"ctrlr_loss_timeout_sec"` ReconnectDelaySec int32 `json:"reconnect_delay_sec"` FastIOFailTimeoutSec int32 `json:"fast_io_fail_timeout_sec"` + + Multipath string `json:"multipath,omitempty"` } type BdevNvmeDetachControllerRequest struct { diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/types/types.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/types/types.go index 1175d6342..f717cd9c7 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/types/types.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/types/types.go @@ -30,6 +30,7 @@ const ( DefaultTransportAckTimeout = 14 DefaultKeepAliveTimeoutMs = 10000 + DefaultMultipath = "disable" ExecuteTimeout = 60 * time.Second ) diff --git a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/disk/nvme/nvme.go b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/disk/nvme/nvme.go index 3e24f9201..74c04d486 100644 --- a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/disk/nvme/nvme.go +++ b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/disk/nvme/nvme.go @@ -36,7 +36,8 @@ func (d *DiskDriverNvme) DiskCreate(spdkClient *spdkclient.Client, diskName, dis } bdevs, err := spdkClient.BdevNvmeAttachController(diskName, "", diskPath, "", "PCIe", "", - helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec) + helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec, + helpertypes.DefaultMultipath) if err != nil { return "", errors.Wrapf(err, "failed to attach NVMe disk %v", diskPath) } diff --git a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go index 3aa303c66..81c7b9cc0 100644 --- a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go +++ b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go @@ -93,6 +93,8 @@ func NewEngine(engineName, volumeName, frontend string, specSize uint64, engineU } func (e *Engine) Create(spdkClient *spdkclient.Client, replicaAddressMap, localReplicaLvsNameMap map[string]string, portCount int32, superiorPortAllocator *util.Bitmap) (ret *spdkrpc.Engine, err error) { + e.log.Infof("Creating engine with replicas %+v", replicaAddressMap) + requireUpdate := true e.Lock() @@ -195,8 +197,10 @@ func (e *Engine) connectReplica(spdkClient *spdkclient.Client, replicaName, repl return "", nil } - nvmeBdevNameList, err := spdkClient.BdevNvmeAttachController(replicaName, helpertypes.GetNQN(replicaName), replicaIP, replicaPort, spdktypes.NvmeTransportTypeTCP, spdktypes.NvmeAddressFamilyIPv4, - helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec) + nvmeBdevNameList, err := spdkClient.BdevNvmeAttachController(replicaName, helpertypes.GetNQN(replicaName), + replicaIP, replicaPort, spdktypes.NvmeTransportTypeTCP, spdktypes.NvmeAddressFamilyIPv4, + helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec, + helpertypes.DefaultMultipath) if err != nil { return "", err } @@ -256,6 +260,8 @@ func (e *Engine) handleFrontend(spdkClient *spdkclient.Client, portCount int32, } func (e *Engine) Delete(spdkClient *spdkclient.Client, superiorPortAllocator *util.Bitmap) (err error) { + e.log.Info("Deleting engine") + requireUpdate := false e.Lock() @@ -1026,6 +1032,8 @@ func getRebuildingSnapshotList(rpcSrcReplica *api.Replica, currentSnapshotName s } func (e *Engine) ReplicaDelete(spdkClient *spdkclient.Client, replicaName, replicaAddress string) (err error) { + e.log.Infof("Deleting replica %s with address %s from engine", replicaName, replicaAddress) + e.Lock() defer e.Unlock() @@ -1047,8 +1055,22 @@ func (e *Engine) ReplicaDelete(spdkClient *spdkclient.Client, replicaName, repli return fmt.Errorf("replica %s recorded address %s does not match the input address %s for engine %s replica delete", replicaName, e.ReplicaAddressMap[replicaName], replicaAddress, e.Name) } + e.log.Infof("Removing base bdev %v from engine", e.ReplicaBdevNameMap[replicaName]) if _, err := spdkClient.BdevRaidRemoveBaseBdev(e.ReplicaBdevNameMap[replicaName]); err != nil && !jsonrpc.IsJSONRPCRespErrorNoSuchDevice(err) { - return err + return errors.Wrapf(err, "failed to remove base bdev %s for deleting replica %s", e.ReplicaBdevNameMap[replicaName], replicaName) + } + + // Detaching the corresponding NVMf controller to remote replica + replicaHost, _, err := net.SplitHostPort(replicaAddress) + if err != nil { + return errors.Wrapf(err, "failed to split replica address %s for deleting replica %s", replicaAddress, replicaName) + } + if replicaHost != e.IP { + controllerName := helperutil.GetNvmeControllerNameFromNamespaceName(replicaName) + e.log.Infof("Detaching the corresponding NVMf controller %v during remote replica %s delete", controllerName, replicaName) + if _, err := spdkClient.BdevNvmeDetachController(controllerName); err != nil && !jsonrpc.IsJSONRPCRespErrorNoSuchDevice(err) { + return errors.Wrapf(err, "failed to detach controller %s for deleting replica %s", controllerName, replicaName) + } } delete(e.ReplicaAddressMap, replicaName) @@ -1068,15 +1090,21 @@ const ( ) func (e *Engine) SnapshotCreate(spdkClient *spdkclient.Client, inputSnapshotName string, opts *api.SnapshotOptions) (snapshotName string, err error) { + e.log.Infof("Creating snapshot %s", inputSnapshotName) + return e.snapshotOperation(spdkClient, inputSnapshotName, SnapshotOperationCreate, opts) } func (e *Engine) SnapshotDelete(spdkClient *spdkclient.Client, snapshotName string) (err error) { + e.log.Infof("Deleting snapshot %s", snapshotName) + _, err = e.snapshotOperation(spdkClient, snapshotName, SnapshotOperationDelete, nil) return err } func (e *Engine) SnapshotRevert(spdkClient *spdkclient.Client, snapshotName string) (err error) { + e.log.Infof("Reverting snapshot %s", snapshotName) + _, err = e.snapshotOperation(spdkClient, snapshotName, SnapshotOperationRevert, nil) return err } @@ -1328,6 +1356,7 @@ func (e *Engine) SetErrorState() { func (e *Engine) BackupCreate(backupName, volumeName, engineName, snapshotName, backingImageName, backingImageChecksum string, labels []string, backupTarget string, credential map[string]string, concurrentLimit int32, compressionMethod, storageClassName string, size uint64) (*BackupCreateInfo, error) { + e.log.Infof("Creating backup %s", backupName) e.Lock() defer e.Unlock() @@ -1402,6 +1431,8 @@ func (e *Engine) BackupStatus(backupName, replicaAddress string) (*spdkrpc.Backu } func (e *Engine) BackupRestore(spdkClient *spdkclient.Client, backupUrl, engineName, snapshotName string, credential map[string]string, concurrentLimit int32) (*spdkrpc.EngineBackupRestoreResponse, error) { + e.log.Infof("Restoring backup %s", backupUrl) + e.Lock() defer e.Unlock() @@ -1476,7 +1507,7 @@ func (e *Engine) BackupRestoreFinish(spdkClient *spdkclient.Client) error { } e.log.Infof("Attaching replica %s with address %s before finishing restoration", replicaName, replicaAddress) _, err = spdkClient.BdevNvmeAttachController(replicaName, helpertypes.GetNQN(replicaName), replicaIP, replicaPort, spdktypes.NvmeTransportTypeTCP, spdktypes.NvmeAddressFamilyIPv4, - helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec) + helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec, helpertypes.DefaultMultipath) if err != nil { return err } diff --git a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/replica.go b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/replica.go index 6cffee131..d280c5904 100644 --- a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/replica.go +++ b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/replica.go @@ -1182,7 +1182,8 @@ func (r *Replica) RebuildingSrcAttach(spdkClient *spdkclient.Client, dstReplicaN nvmeBdevNameList, err := spdkClient.BdevNvmeAttachController(dstRebuildingLvolName, helpertypes.GetNQN(dstRebuildingLvolName), dstRebuildingLvolIP, dstRebuildingLvolPort, spdktypes.NvmeTransportTypeTCP, spdktypes.NvmeAddressFamilyIPv4, - helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec) + helpertypes.DefaultCtrlrLossTimeoutSec, helpertypes.DefaultReconnectDelaySec, helpertypes.DefaultFastIOFailTimeoutSec, + helpertypes.DefaultMultipath) if err != nil { return err } diff --git a/vendor/k8s.io/apimachinery/pkg/util/sets/doc.go b/vendor/k8s.io/apimachinery/pkg/util/sets/doc.go index 194883390..fd281bdb8 100644 --- a/vendor/k8s.io/apimachinery/pkg/util/sets/doc.go +++ b/vendor/k8s.io/apimachinery/pkg/util/sets/doc.go @@ -16,4 +16,4 @@ limitations under the License. // Package sets has generic set and specified sets. Generic set will // replace specified ones over time. And specific ones are deprecated. -package sets +package sets // import "k8s.io/apimachinery/pkg/util/sets" diff --git a/vendor/k8s.io/apimachinery/pkg/util/sets/ordered.go b/vendor/k8s.io/apimachinery/pkg/util/sets/ordered.go deleted file mode 100644 index 443dac62e..000000000 --- a/vendor/k8s.io/apimachinery/pkg/util/sets/ordered.go +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright 2022 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sets - -// ordered is a constraint that permits any ordered type: any type -// that supports the operators < <= >= >. -// If future releases of Go add new ordered types, -// this constraint will be modified to include them. -type ordered interface { - integer | float | ~string -} - -// integer is a constraint that permits any integer type. -// If future releases of Go add new predeclared integer types, -// this constraint will be modified to include them. -type integer interface { - signed | unsigned -} - -// float is a constraint that permits any floating-point type. -// If future releases of Go add new predeclared floating-point types, -// this constraint will be modified to include them. -type float interface { - ~float32 | ~float64 -} - -// signed is a constraint that permits any signed integer type. -// If future releases of Go add new predeclared signed integer types, -// this constraint will be modified to include them. -type signed interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 -} - -// unsigned is a constraint that permits any unsigned integer type. -// If future releases of Go add new predeclared unsigned integer types, -// this constraint will be modified to include them. -type unsigned interface { - ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr -} diff --git a/vendor/k8s.io/apimachinery/pkg/util/sets/set.go b/vendor/k8s.io/apimachinery/pkg/util/sets/set.go index d50526f42..b76129a1c 100644 --- a/vendor/k8s.io/apimachinery/pkg/util/sets/set.go +++ b/vendor/k8s.io/apimachinery/pkg/util/sets/set.go @@ -17,6 +17,7 @@ limitations under the License. package sets import ( + "cmp" "sort" ) @@ -37,7 +38,7 @@ func New[T comparable](items ...T) Set[T] { // KeySet creates a Set from a keys of a map[comparable](? extends interface{}). // If the value passed in is not actually a map, this will panic. func KeySet[T comparable, V any](theMap map[T]V) Set[T] { - ret := Set[T]{} + ret := make(Set[T], len(theMap)) for keyValue := range theMap { ret.Insert(keyValue) } @@ -193,7 +194,7 @@ func (s1 Set[T]) Equal(s2 Set[T]) bool { return len(s1) == len(s2) && s1.IsSuperset(s2) } -type sortableSliceOfGeneric[T ordered] []T +type sortableSliceOfGeneric[T cmp.Ordered] []T func (g sortableSliceOfGeneric[T]) Len() int { return len(g) } func (g sortableSliceOfGeneric[T]) Less(i, j int) bool { return less[T](g[i], g[j]) } @@ -203,7 +204,7 @@ func (g sortableSliceOfGeneric[T]) Swap(i, j int) { g[i], g[j] = g[j], g[i] // // This is a separate function and not a method because not all types supported // by Generic are ordered and only those can be sorted. -func List[T ordered](s Set[T]) []T { +func List[T cmp.Ordered](s Set[T]) []T { res := make(sortableSliceOfGeneric[T], 0, len(s)) for key := range s { res = append(res, key) @@ -236,6 +237,6 @@ func (s Set[T]) Len() int { return len(s) } -func less[T ordered](lhs, rhs T) bool { +func less[T cmp.Ordered](lhs, rhs T) bool { return lhs < rhs } diff --git a/vendor/k8s.io/apimachinery/pkg/util/validation/OWNERS b/vendor/k8s.io/apimachinery/pkg/util/validation/OWNERS new file mode 100644 index 000000000..402373247 --- /dev/null +++ b/vendor/k8s.io/apimachinery/pkg/util/validation/OWNERS @@ -0,0 +1,11 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +# Disable inheritance as this is an api owners file +options: + no_parent_owners: true +approvers: + - api-approvers +reviewers: + - api-reviewers +labels: + - kind/api-change diff --git a/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go b/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go index 0b8a6cb35..b32644902 100644 --- a/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go +++ b/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go @@ -19,10 +19,9 @@ package validation import ( "fmt" "math" - "net" "regexp" - "strconv" "strings" + "unicode" "k8s.io/apimachinery/pkg/util/validation/field" netutils "k8s.io/utils/net" @@ -352,11 +351,12 @@ func IsValidPortName(port string) []string { } // IsValidIP tests that the argument is a valid IP address. -func IsValidIP(value string) []string { +func IsValidIP(fldPath *field.Path, value string) field.ErrorList { + var allErrors field.ErrorList if netutils.ParseIPSloppy(value) == nil { - return []string{"must be a valid IP address, (e.g. 10.9.8.7 or 2001:db8::ffff)"} + allErrors = append(allErrors, field.Invalid(fldPath, value, "must be a valid IP address, (e.g. 10.9.8.7 or 2001:db8::ffff)")) } - return nil + return allErrors } // IsValidIPv4Address tests that the argument is a valid IPv4 address. @@ -379,6 +379,16 @@ func IsValidIPv6Address(fldPath *field.Path, value string) field.ErrorList { return allErrors } +// IsValidCIDR tests that the argument is a valid CIDR value. +func IsValidCIDR(fldPath *field.Path, value string) field.ErrorList { + var allErrors field.ErrorList + _, _, err := netutils.ParseCIDRSloppy(value) + if err != nil { + allErrors = append(allErrors, field.Invalid(fldPath, value, "must be a valid CIDR value, (e.g. 10.9.8.0/24 or 2001:db8::/64)")) + } + return allErrors +} + const percentFmt string = "[0-9]+%" const percentErrMsg string = "a valid percent string must be a numeric string followed by an ending '%'" @@ -409,6 +419,9 @@ func IsHTTPHeaderName(value string) []string { const envVarNameFmt = "[-._a-zA-Z][-._a-zA-Z0-9]*" const envVarNameFmtErrMsg string = "a valid environment variable name must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit" +// TODO(hirazawaui): Rename this when the RelaxedEnvironmentVariableValidation gate is removed. +const relaxedEnvVarNameFmtErrMsg string = "a valid environment variable name must consist only of printable ASCII characters other than '='" + var envVarNameRegexp = regexp.MustCompile("^" + envVarNameFmt + "$") // IsEnvVarName tests if a string is a valid environment variable name. @@ -422,6 +435,24 @@ func IsEnvVarName(value string) []string { return errs } +// IsRelaxedEnvVarName tests if a string is a valid environment variable name. +func IsRelaxedEnvVarName(value string) []string { + var errs []string + + if len(value) == 0 { + errs = append(errs, "environment variable name "+EmptyError()) + } + + for _, r := range value { + if r > unicode.MaxASCII || !unicode.IsPrint(r) || r == '=' { + errs = append(errs, relaxedEnvVarNameFmtErrMsg) + break + } + } + + return errs +} + const configMapKeyFmt = `[-._a-zA-Z0-9]+` const configMapKeyErrMsg string = "a valid config key must consist of alphanumeric characters, '-', '_' or '.'" @@ -493,18 +524,3 @@ func hasChDirPrefix(value string) []string { } return errs } - -// IsValidSocketAddr checks that string represents a valid socket address -// as defined in RFC 789. (e.g 0.0.0.0:10254 or [::]:10254)) -func IsValidSocketAddr(value string) []string { - var errs []string - ip, port, err := net.SplitHostPort(value) - if err != nil { - errs = append(errs, "must be a valid socket address format, (e.g. 0.0.0.0:10254 or [::]:10254)") - return errs - } - portInt, _ := strconv.Atoi(port) - errs = append(errs, IsValidPortNum(portInt)...) - errs = append(errs, IsValidIP(ip)...) - return errs -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 19b5c2c1d..3993eca1a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -145,8 +145,8 @@ github.com/longhorn/backupstore/s3 github.com/longhorn/backupstore/types github.com/longhorn/backupstore/util github.com/longhorn/backupstore/vfs -# github.com/longhorn/go-common-libs v0.0.0-20240411093823-b8862efb8e03 -## explicit; go 1.21 +# github.com/longhorn/go-common-libs v0.0.0-20240422073843-1578e42a50bd +## explicit; go 1.22 github.com/longhorn/go-common-libs/exec github.com/longhorn/go-common-libs/io github.com/longhorn/go-common-libs/net @@ -156,8 +156,8 @@ github.com/longhorn/go-common-libs/sync github.com/longhorn/go-common-libs/sys github.com/longhorn/go-common-libs/types github.com/longhorn/go-common-libs/utils -# github.com/longhorn/go-spdk-helper v0.0.0-20240415074119-eb1e91922189 -## explicit; go 1.21 +# github.com/longhorn/go-spdk-helper v0.0.0-20240422131908-185e91a748ad +## explicit; go 1.22 github.com/longhorn/go-spdk-helper/pkg/jsonrpc github.com/longhorn/go-spdk-helper/pkg/nvme github.com/longhorn/go-spdk-helper/pkg/spdk/client @@ -178,8 +178,8 @@ github.com/longhorn/longhorn-engine/pkg/sync github.com/longhorn/longhorn-engine/pkg/types github.com/longhorn/longhorn-engine/pkg/util github.com/longhorn/longhorn-engine/pkg/util/disk -# github.com/longhorn/longhorn-spdk-engine v0.0.0-20240417162837-d96ef4ed8c28 -## explicit; go 1.21 +# github.com/longhorn/longhorn-spdk-engine v0.0.0-20240423045523-73fd7e6f9745 +## explicit; go 1.22 github.com/longhorn/longhorn-spdk-engine/pkg/api github.com/longhorn/longhorn-spdk-engine/pkg/client github.com/longhorn/longhorn-spdk-engine/pkg/spdk @@ -403,8 +403,8 @@ google.golang.org/protobuf/types/known/timestamppb # gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c ## explicit; go 1.11 gopkg.in/check.v1 -# k8s.io/apimachinery v0.29.4 -## explicit; go 1.21 +# k8s.io/apimachinery v0.30.0 +## explicit; go 1.22.0 k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/runtime k8s.io/apimachinery/pkg/util/sets