diff --git a/go.mod b/go.mod index bea850b41..6f9791595 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/protobuf v1.3.3-0.20190920234318-1680a479a2cf github.com/google/uuid v1.3.0 github.com/longhorn/backupstore v0.0.0-20230306022849-8d5e216c3b33 - github.com/longhorn/longhorn-engine v1.3.3-0.20230216042703-718990dc8a35 + github.com/longhorn/longhorn-engine v1.3.3 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 github.com/tinylib/msgp v1.1.1-0.20190612170807-0573788bc2a8 // indirect diff --git a/go.sum b/go.sum index 597880990..9d3608031 100644 --- a/go.sum +++ b/go.sum @@ -46,13 +46,12 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/longhorn/backupstore v0.0.0-20220913112826-5f5c95274f2a/go.mod h1:hvIVsrpjPey7KupirAh0WoPMg0ArWnE6fA5bI30X7AI= github.com/longhorn/backupstore v0.0.0-20230306022849-8d5e216c3b33 h1:zfRoewEi64drdl4PzGcdw88jobkiAbQpxBT6IbT+zmY= github.com/longhorn/backupstore v0.0.0-20230306022849-8d5e216c3b33/go.mod h1:NFJYOfVUk22TZPSVbKHFgL0JgbJP0suXdixr1042sM8= github.com/longhorn/go-iscsi-helper v0.0.0-20230215045129-588aa7586e4c h1:M4UR1cVrVHHKqwc4aL3MUlp1d/Z2i7T7VS1y0SSUwa8= github.com/longhorn/go-iscsi-helper v0.0.0-20230215045129-588aa7586e4c/go.mod h1:9z/y9glKmWEdV50tjlUPxFwi1goQfIrrsoZbnMyIZbY= -github.com/longhorn/longhorn-engine v1.3.3-0.20230216042703-718990dc8a35 h1:3RgCpW+8XGrUq3U5pSH1cDszVu6gIWhGs2akEEdtAZc= -github.com/longhorn/longhorn-engine v1.3.3-0.20230216042703-718990dc8a35/go.mod h1:rFBcnmpcs6un/I1InIzb18kPni64pH2iclEyoGrdXO0= +github.com/longhorn/longhorn-engine v1.3.3 h1:syzFlOV5aTRX6rfs82TYJUVexm9e5B/we5vXW97RlIo= +github.com/longhorn/longhorn-engine v1.3.3/go.mod h1:q1dS4TBER+9KdHHBnl9T7CGNRE6L2Zo72xWWHDzWCuY= github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003/go.mod h1:0CLeXlf59Lg6C0kjLSDf47ft73Dh37CwymYRKWwAn04= github.com/longhorn/sparse-tools v0.0.0-20220323120706-0bd9b4129826 h1:8IeuJT9y0xFGSfSl9dOG/L6dJOGtIrS3nYqgo3eYzao= github.com/longhorn/sparse-tools v0.0.0-20220323120706-0bd9b4129826/go.mod h1:BWM7yTPb1DulG18EE/Jy20LVIySzIYoZpiOYFtAGwZo= diff --git a/vendor/github.com/longhorn/longhorn-engine/pkg/replica/server.go b/vendor/github.com/longhorn/longhorn-engine/pkg/replica/server.go index 113c59077..982c9d5ec 100644 --- a/vendor/github.com/longhorn/longhorn-engine/pkg/replica/server.go +++ b/vendor/github.com/longhorn/longhorn-engine/pkg/replica/server.go @@ -8,19 +8,9 @@ import ( "github.com/sirupsen/logrus" "github.com/longhorn/longhorn-engine/pkg/backingfile" + "github.com/longhorn/longhorn-engine/pkg/types" ) -const ( - Initial = State("initial") - Open = State("open") - Closed = State("closed") - Dirty = State("dirty") - Rebuilding = State("rebuilding") - Error = State("error") -) - -type State string - type Server struct { sync.RWMutex r *Replica @@ -51,7 +41,7 @@ func (s *Server) Create(size int64) error { defer s.Unlock() state, _ := s.Status() - if state != Initial { + if state != types.ReplicaStateInitial { return nil } @@ -94,7 +84,7 @@ func (s *Server) Reload() error { return nil } - logrus.Infof("Reloading volume") + logrus.Info("Reloading volume") newReplica, err := s.r.Reload() if err != nil { return err @@ -106,39 +96,39 @@ func (s *Server) Reload() error { return nil } -func (s *Server) Status() (State, Info) { +func (s *Server) Status() (types.ReplicaState, Info) { if s.r == nil { info, err := ReadInfo(s.dir) if os.IsNotExist(err) { - return Initial, Info{} + return types.ReplicaStateInitial, Info{} } replica := Replica{dir: s.dir} - volumeMetaFileValid, vaildErr := replica.checkValidVolumeMetaData() - if vaildErr != nil { - logrus.Errorf("Failed to check if volume metedata is valid in replica directory %s: %v", s.dir, err) - return Error, Info{} + volumeMetaFileValid, validErr := replica.checkValidVolumeMetaData() + if validErr != nil { + logrus.WithError(validErr).Errorf("Failed to check if volume metadata is valid in replica directory %s", s.dir) + return types.ReplicaStateError, Info{} } if !volumeMetaFileValid { - return Initial, Info{} + return types.ReplicaStateInitial, Info{} } if err != nil { - logrus.Errorf("Failed to read info in replica directory %s: %v", s.dir, err) - return Error, Info{} + logrus.WithError(err).Errorf("Failed to read info in replica directory %s", s.dir) + return types.ReplicaStateError, Info{} } - return Closed, info + return types.ReplicaStateClosed, info } info := s.r.Info() switch { case info.Error != "": - return Error, info + return types.ReplicaStateError, info case info.Rebuilding: - return Rebuilding, info + return types.ReplicaStateRebuilding, info case info.Dirty: - return Dirty, info + return types.ReplicaStateDirty, info default: - return Open, info + return types.ReplicaStateOpen, info } } @@ -148,8 +138,8 @@ func (s *Server) SetRebuilding(rebuilding bool) error { state, _ := s.Status() // Must be Open/Dirty to set true or must be Rebuilding to set false - if (rebuilding && state != Open && state != Dirty) || - (!rebuilding && state != Rebuilding) { + if (rebuilding && state != types.ReplicaStateOpen && state != types.ReplicaStateDirty) || + (!rebuilding && state != types.ReplicaStateRebuilding) { return fmt.Errorf("cannot set rebuilding=%v from state %s", rebuilding, state) } @@ -321,10 +311,10 @@ func (s *Server) SetRevisionCounter(counter int64) error { func (s *Server) PingResponse() error { state, info := s.Status() - if state == Error { + if state == types.ReplicaStateError { return fmt.Errorf("ping failure due to %v", info.Error) } - if state != Open && state != Dirty && state != Rebuilding { + if state != types.ReplicaStateOpen && state != types.ReplicaStateDirty && state != types.ReplicaStateRebuilding { return fmt.Errorf("ping failure: replica state %v", state) } return nil diff --git a/vendor/github.com/longhorn/longhorn-engine/pkg/sync/backup.go b/vendor/github.com/longhorn/longhorn-engine/pkg/sync/backup.go index 81ce6bbf5..d5dad7934 100644 --- a/vendor/github.com/longhorn/longhorn-engine/pkg/sync/backup.go +++ b/vendor/github.com/longhorn/longhorn-engine/pkg/sync/backup.go @@ -244,11 +244,16 @@ func (t *Task) RestoreBackup(backup string, credential map[string]string) error backupInfo, err := backupstore.InspectBackup(backup) if err != nil { - return errors.Wrapf(err, "failed to get the current restoring backup info") + for _, r := range replicas { + taskErr.Append(NewReplicaError(r.Address, errors.Wrapf(err, "failed to get the current restoring backup info"))) + } + return taskErr } + if backupInfo.VolumeSize < volume.Size { return fmt.Errorf("BUG: The backup volume %v size %v cannot be smaller than the DR volume %v size %v", backupInfo.VolumeName, backupInfo.VolumeSize, volume.Name, volume.Size) - } else if backupInfo.VolumeSize > volume.Size { + } + if backupInfo.VolumeSize > volume.Size { if !isIncremental { return fmt.Errorf("BUG: The backup volume %v size %v cannot be larger than normal restore volume %v size %v", backupInfo.VolumeName, backupInfo.VolumeSize, volume.Name, volume.Size) } diff --git a/vendor/github.com/longhorn/longhorn-engine/pkg/sync/sync.go b/vendor/github.com/longhorn/longhorn-engine/pkg/sync/sync.go index e053af99b..1c927e2b5 100644 --- a/vendor/github.com/longhorn/longhorn-engine/pkg/sync/sync.go +++ b/vendor/github.com/longhorn/longhorn-engine/pkg/sync/sync.go @@ -464,7 +464,7 @@ func (t *Task) checkAndResetFailedRebuild(address string) error { return err } - if replica.State == "closed" && replica.Rebuilding { + if replica.State == string(types.ReplicaStateClosed) && replica.Rebuilding { if err := client.OpenReplica(); err != nil { return err } diff --git a/vendor/github.com/longhorn/longhorn-engine/pkg/types/types.go b/vendor/github.com/longhorn/longhorn-engine/pkg/types/types.go index 83be0a9a5..3e88f7df7 100644 --- a/vendor/github.com/longhorn/longhorn-engine/pkg/types/types.go +++ b/vendor/github.com/longhorn/longhorn-engine/pkg/types/types.go @@ -38,6 +38,17 @@ const ( VolumeHeadName = "volume-head" ) +type ReplicaState string + +const ( + ReplicaStateInitial = ReplicaState("initial") + ReplicaStateOpen = ReplicaState("open") + ReplicaStateClosed = ReplicaState("closed") + ReplicaStateDirty = ReplicaState("dirty") + ReplicaStateRebuilding = ReplicaState("rebuilding") + ReplicaStateError = ReplicaState("error") +) + type ReaderWriterAt interface { io.ReaderAt io.WriterAt diff --git a/vendor/modules.txt b/vendor/modules.txt index dc61d51f2..8443fead5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -79,7 +79,7 @@ github.com/longhorn/backupstore/util github.com/longhorn/backupstore/vfs # github.com/longhorn/go-iscsi-helper v0.0.0-20230215045129-588aa7586e4c github.com/longhorn/go-iscsi-helper/util -# github.com/longhorn/longhorn-engine v1.3.3-0.20230216042703-718990dc8a35 +# github.com/longhorn/longhorn-engine v1.3.3 github.com/longhorn/longhorn-engine/pkg/backingfile github.com/longhorn/longhorn-engine/pkg/controller/client github.com/longhorn/longhorn-engine/pkg/meta