Skip to content

Commit

Permalink
meta: check metadata version after setting reloaded (#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandyXSD authored Jul 29, 2022
1 parent 9eac488 commit c789371
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func format(c *cli.Context) error {
BlockSize: fixObjectSize(c.Int("block-size")),
Compression: c.String("compress"),
TrashDays: c.Int("trash-days"),
MetaVersion: 1,
MetaVersion: meta.MaxVersion,
}
if format.AccessKey == "" && os.Getenv("ACCESS_KEY") != "" {
format.AccessKey = os.Getenv("ACCESS_KEY")
Expand Down
2 changes: 2 additions & 0 deletions pkg/meta/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ func (m *baseMeta) refreshSession() {
old := m.fmt.UUID
if _, err := m.Load(false); err != nil {
logger.Warnf("reload setting: %s", err)
} else if m.fmt.MetaVersion > MaxVersion {
logger.Fatalf("incompatible metadata version %d > max version %d", m.fmt.MetaVersion, MaxVersion)
} else if m.fmt.UUID != old {
logger.Fatalf("UUID changed from %s to %s", old, m.fmt.UUID)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (f *Format) String() string {
}

func (f *Format) CheckVersion() error {
if f.MetaVersion > 1 {
if f.MetaVersion > MaxVersion {
return fmt.Errorf("incompatible metadata version: %d; please upgrade the client", f.MetaVersion)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/meta/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
)

const (
// MaxVersion is the max of supported versions.
MaxVersion = 1
// ChunkSize is size of a chunk
ChunkSize = 1 << 26 // 64M
// DeleteSlice is a message to delete a slice from object store.
Expand Down

0 comments on commit c789371

Please sign in to comment.