Skip to content

Commit

Permalink
FSHC v2: upgrade rc2 config to rc3
Browse files Browse the repository at this point in the history
* temp patch only to carry out interim upgrade within v3.24
  - (ref v324)
  - (v3.23 => new fshc) and (3.24.rc2 => new fshc)

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Aug 21, 2024
1 parent f5deb20 commit 49df738
Showing 1 changed file with 47 additions and 11 deletions.
58 changes: 47 additions & 11 deletions cmn/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ type (
IOErrTime *cos.Duration `json:"io_err_time,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
// [backward compatibility] TODO: remove (ref v324)
FSHCConfRC3 FSHCConf

AuthConf struct {
Secret string `json:"secret"`
Expand Down Expand Up @@ -685,6 +687,9 @@ var (
_ json.Unmarshaler = (*BackendConf)(nil)
_ json.Marshaler = (*FSPConf)(nil)
_ json.Unmarshaler = (*FSPConf)(nil)

// [backward compatibility] TODO: remove (ref v324)
_ json.Unmarshaler = (*FSHCConf)(nil)
)

/////////////////////////////////////////////
Expand Down Expand Up @@ -1248,15 +1253,35 @@ func (c *HTTPConf) ToTLS() TLSArgs {
}
}

/////////////
//////////////
// FSHCConf //
/////////////
//////////////

const (
IOErrTimeDflt = 10 * time.Second
IOErrsLimit = 100
IOErrsLimit = 10
)

// [backward compatibility] TODO: remove (ref v324)
func (c *FSHCConf) UnmarshalJSON(data []byte) (err error) {
rc3 := &FSHCConfRC3{}
if err = jsoniter.Unmarshal(data, rc3); err == nil {
*c = *(*FSHCConf)(rc3)
return nil
}

c.TestFileCount = 4
c.HardErrs = 2
c.IOErrs = IOErrsLimit
c.IOErrTime = cos.Duration(IOErrTimeDflt)
c.Enabled = true

// cannot nlog yet; may not show up when redirected
fmt.Fprintln(os.Stderr, "Warning: setting fshc to all defaults")

return nil
}

func (c *FSHCConf) Validate() error {
if c.TestFileCount < 4 {
return fmt.Errorf("invalid fshc.test_files %d (expecting >= %d)", c.TestFileCount, 4)
Expand All @@ -1271,6 +1296,14 @@ func (c *FSHCConf) Validate() error {
c.IOErrTime = cos.Duration(IOErrTimeDflt)
}

// [backward compatibility] TODO: remove (ref v324)
if c.IOErrs == 0 {
c.IOErrs = IOErrsLimit
}
if c.IOErrTime == 0 {
c.IOErrTime = cos.Duration(IOErrTimeDflt)
}

if c.IOErrs < 10 {
return fmt.Errorf("invalid fshc.io_err_limit %d (expecting >= %d)", c.IOErrs, 10)
}
Expand Down Expand Up @@ -1399,15 +1432,18 @@ func (c *FSPConf) UnmarshalJSON(data []byte) error {
// [backward compatibility] try loading from the prev. meta-version
var v322 FSPConfV322
v322.Paths = make(cos.StrSet, 10)
if err = jsoniter.Unmarshal(data, &v322.Paths); err == nil {
for fspath := range v322.Paths {
m[fspath] = ""
}
c.Paths = m
// cannot nlog yet - in the process of loading config (w/ log dirs not yet assigned)
fmt.Fprintln(os.Stderr, "Warning: load fspaths from V3 (older) config:", c.Paths)
if err = jsoniter.Unmarshal(data, &v322.Paths); err != nil {
return err
}
return err

for fspath := range v322.Paths {
m[fspath] = ""
}
c.Paths = m

// cannot nlog yet; may not show up when redirected
fmt.Fprintln(os.Stderr, "Warning: load fspaths from V3 (older) config:", c.Paths)
return nil
}

func (c *FSPConf) MarshalJSON() ([]byte, error) {
Expand Down

0 comments on commit 49df738

Please sign in to comment.