Merge pull request #19350 from aladesawe/server-wal-version-unexported-return
Migrate WALVersion to fix unexported-return of walVersion
This commit is contained in:
@ -97,7 +97,7 @@ func (o *migrateOptions) Config() (*migrateConfig, error) {
|
|||||||
type migrateConfig struct {
|
type migrateConfig struct {
|
||||||
lg *zap.Logger
|
lg *zap.Logger
|
||||||
targetVersion *semver.Version
|
targetVersion *semver.Version
|
||||||
walVersion schema.WALVersion
|
walVersion wal.Version
|
||||||
dataDir string
|
dataDir string
|
||||||
force bool
|
force bool
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
|
|
||||||
"go.etcd.io/etcd/api/v3/version"
|
"go.etcd.io/etcd/api/v3/version"
|
||||||
"go.etcd.io/etcd/server/v3/storage/backend"
|
"go.etcd.io/etcd/server/v3/storage/backend"
|
||||||
|
"go.etcd.io/etcd/server/v3/storage/wal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Validate checks provided backend to confirm that schema used is supported.
|
// Validate checks provided backend to confirm that schema used is supported.
|
||||||
@ -47,21 +48,16 @@ func localBinaryVersion() semver.Version {
|
|||||||
return semver.Version{Major: v.Major, Minor: v.Minor}
|
return semver.Version{Major: v.Major, Minor: v.Minor}
|
||||||
}
|
}
|
||||||
|
|
||||||
type WALVersion interface {
|
|
||||||
// MinimalEtcdVersion returns minimal etcd version able to interpret WAL log.
|
|
||||||
MinimalEtcdVersion() *semver.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate updates storage schema to provided target version.
|
// Migrate updates storage schema to provided target version.
|
||||||
// Downgrading requires that provided WAL doesn't contain unsupported entries.
|
// Downgrading requires that provided WAL doesn't contain unsupported entries.
|
||||||
func Migrate(lg *zap.Logger, tx backend.BatchTx, w WALVersion, target semver.Version) error {
|
func Migrate(lg *zap.Logger, tx backend.BatchTx, w wal.Version, target semver.Version) error {
|
||||||
tx.LockOutsideApply()
|
tx.LockOutsideApply()
|
||||||
defer tx.Unlock()
|
defer tx.Unlock()
|
||||||
return UnsafeMigrate(lg, tx, w, target)
|
return UnsafeMigrate(lg, tx, w, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnsafeMigrate is non thread-safe version of Migrate.
|
// UnsafeMigrate is non thread-safe version of Migrate.
|
||||||
func UnsafeMigrate(lg *zap.Logger, tx backend.UnsafeReadWriter, w WALVersion, target semver.Version) error {
|
func UnsafeMigrate(lg *zap.Logger, tx backend.UnsafeReadWriter, w wal.Version, target semver.Version) error {
|
||||||
current, err := UnsafeDetectSchemaVersion(lg, tx)
|
current, err := UnsafeDetectSchemaVersion(lg, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot detect storage schema version: %w", err)
|
return fmt.Errorf("cannot detect storage schema version: %w", err)
|
||||||
|
@ -29,9 +29,15 @@ import (
|
|||||||
"go.etcd.io/raft/v3/raftpb"
|
"go.etcd.io/raft/v3/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Version defines the wal version interface.
|
||||||
|
type Version interface {
|
||||||
|
// MinimalEtcdVersion returns minimal etcd version able to interpret WAL log.
|
||||||
|
MinimalEtcdVersion() *semver.Version
|
||||||
|
}
|
||||||
|
|
||||||
// ReadWALVersion reads remaining entries from opened WAL and returns struct
|
// ReadWALVersion reads remaining entries from opened WAL and returns struct
|
||||||
// that implements schema.WAL interface.
|
// that implements schema.WAL interface.
|
||||||
func ReadWALVersion(w *WAL) (*walVersion, error) {
|
func ReadWALVersion(w *WAL) (Version, error) {
|
||||||
_, _, ents, err := w.ReadAll()
|
_, _, ents, err := w.ReadAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user