Deprecate and remove configurable disk usage check (#6016)

master
Harshavardhana 7 years ago committed by kannappanr
parent eafc15cd47
commit 3143454982
  1. 9
      cmd/common-main.go
  2. 22
      cmd/config-current.go
  3. 4
      cmd/config-migrate.go
  4. 7
      cmd/config-versions.go
  5. 48
      cmd/disk-usage.go
  6. 4
      cmd/globals.go
  7. 9
      cmd/ui-errors.go
  8. 12
      docs/config/README.md

@ -153,15 +153,6 @@ func handleCommonEnvVars() {
globalCacheExpiry = expiry
}
if intervalStr := os.Getenv("MINIO_USAGE_CHECK_INTERVAL"); intervalStr != "" {
interval, err := parseDuration(intervalStr)
if err != nil {
logger.Fatal(uiErrInvalidUsageCheckIntervalValue(err), "Invalid MINIO_USAGE_CHECK_INTERVAL value (`%s`)", intervalStr)
}
globalUsageCheckInterval = interval
globalIsEnvUsageCheck = true
}
// In place update is true by default if the MINIO_UPDATE is not set
// or is not set to 'off', if MINIO_UPDATE is set to 'off' then
// in-place update is off.

@ -21,7 +21,6 @@ import (
"fmt"
"reflect"
"sync"
"time"
"github.com/minio/minio/cmd/logger"
@ -105,17 +104,6 @@ func (s *serverConfig) GetBrowser() bool {
return bool(s.Browser)
}
// Set new usage configuration, currently only supports configuring
// usage check interval.
func (s *serverConfig) SetUsageConfig(checkUsageInterval time.Duration) {
s.Usage = usageConfig{checkUsageInterval}
}
// Get current usage configuration.
func (s *serverConfig) GetUsageConfig() usageConfig {
return s.Usage
}
// SetCacheConfig sets the current cache config
func (s *serverConfig) SetCacheConfig(drives, exclude []string, expiry int) {
s.Cache.Drives = drives
@ -153,8 +141,6 @@ func (s *serverConfig) ConfigDiff(t *serverConfig) string {
return "StorageClass configuration differs"
case !reflect.DeepEqual(s.Cache, t.Cache):
return "Cache configuration differs"
case !reflect.DeepEqual(s.Usage, t.Usage):
return "Usage configuration differs"
case !reflect.DeepEqual(s.Notify.AMQP, t.Notify.AMQP):
return "AMQP Notification configuration differs"
case !reflect.DeepEqual(s.Notify.NATS, t.Notify.NATS):
@ -200,7 +186,6 @@ func newServerConfig() *serverConfig {
Exclude: []string{},
Expiry: globalCacheExpiry,
},
Usage: usageConfig{globalDefaultUsageCheckInterval},
Notify: notifier{},
}
@ -261,10 +246,6 @@ func newConfig() error {
srvCfg.SetCacheConfig(globalCacheDrives, globalCacheExcludes, globalCacheExpiry)
}
if globalIsEnvUsageCheck {
srvCfg.SetUsageConfig(globalUsageCheckInterval)
}
// hold the mutex lock before a new config is assigned.
// Save the new config globally.
// unlock the mutex.
@ -358,9 +339,6 @@ func loadConfig() error {
globalCacheExcludes = cacheConf.Exclude
globalCacheExpiry = cacheConf.Expiry
}
if !globalIsEnvUsageCheck {
globalUsageCheckInterval = globalServerConfig.GetUsageConfig().UsageCheckInterval
}
globalServerConfigMu.Unlock()
return nil

@ -2062,10 +2062,6 @@ func migrateV23ToV24() error {
srvConfig.Cache.Exclude = cv23.Cache.Exclude
srvConfig.Cache.Expiry = cv23.Cache.Expiry
// Init usage config. For future migration, usage config needs
// to be copied over from previous version.
srvConfig.Usage = usageConfig{globalDefaultUsageCheckInterval}
if err = quick.Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv23.Version, srvConfig.Version, err)
}

@ -603,8 +603,8 @@ type serverConfigV23 struct {
Notify notifier `json:"notify"`
}
// serverConfigV24 is just like version '23' with addition of usage interval
// field.
// serverConfigV24 is just like version '23', we had to revert
// the changes which were made in 6fb06045028b7a57c37c60a612c8e50735279ab4
//
// IMPORTANT NOTE: When updating this struct make sure that
// serverConfig.ConfigDiff() is updated as necessary.
@ -623,9 +623,6 @@ type serverConfigV24 struct {
// Cache configuration
Cache CacheConfig `json:"cache"`
// Usage configuration
Usage usageConfig `json:"usage"`
// Notification queue configuration.
Notify notifier `json:"notify"`
}

@ -18,56 +18,8 @@ package cmd
import (
"context"
"encoding/json"
"fmt"
"time"
)
// Captures configurable parameters of usage check.
type usageConfig struct {
UsageCheckInterval time.Duration
}
// MarshalJSON - encodes to JSON data.
func (u usageConfig) MarshalJSON() ([]byte, error) {
type _usageConfig struct {
UsageCheckInterval string `json:"interval"`
}
return json.Marshal(_usageConfig{u.UsageCheckInterval.String()})
}
// parseDuration - parse duration string
func parseDuration(dStr string) (time.Duration, error) {
d, err := time.ParseDuration(dStr)
if err != nil {
return d, err
}
if d < globalMinimumUsageCheckInterval {
return d, fmt.Errorf("interval %s is not allowed, minimum required value is %s",
d, globalMinimumUsageCheckInterval)
}
return d, nil
}
// UnmarshalJSON - decodes JSON data.
func (u *usageConfig) UnmarshalJSON(data []byte) error {
type _usageConfig struct {
UsageCheckInterval string `json:"interval"`
}
var u1 = _usageConfig{}
if err := json.Unmarshal(data, &u1); err != nil {
return err
}
if !globalIsEnvUsageCheck {
d, err := parseDuration(u1.UsageCheckInterval)
if err != nil {
return err
}
u.UsageCheckInterval = d
}
return nil
}
// getDiskUsage walks the file tree rooted at root, calling usageFn
// for each file or directory in the tree, including root.
func getDiskUsage(ctx context.Context, root string, usageFn usageFunc) error {

@ -188,14 +188,10 @@ var (
globalCacheExpiry = 90
// Add new variable global values here.
// Minimum required usage check interval value.
globalMinimumUsageCheckInterval = 2 * time.Hour // 2 hours
// Default usage check interval value.
globalDefaultUsageCheckInterval = 12 * time.Hour // 12 hours
// Usage check interval value.
globalUsageCheckInterval = globalDefaultUsageCheckInterval
// Is env usage check interval set.
globalIsEnvUsageCheck bool
)
// global colors.

@ -47,15 +47,6 @@ var (
"MINIO_CACHE_EXPIRY: Valid cache expiry duration is in days.",
)
uiErrInvalidUsageCheckIntervalValue = newUIErrFn(
"Invalid usage check interval value",
"Please check the passed value",
`MINIO_USAGE_CHECK_INTERVAL: Valid usage check interval duration string is a signed sequence of decimal numbers,
each with optional fraction and a unit suffix, such as "2h45m". Valid time units are "ns", "us", "ms", "s", "m", "h".
Minimum supported value is '2h'.
`,
)
uiErrInvalidCredentials = newUIErrFn(
"Invalid credentials",
"Please provide correct credentials",

@ -99,18 +99,6 @@ By default, parity for objects with standard storage class is set to `N/2`, and
|``exclude`` | _[]string_ | List of wildcard patterns for prefixes to exclude from cache |
|``expiry`` | _int_ | Days to cache expiry |
### Usage
|Field|Type|Description|
|:---|:---|:---|
|``interval``| _string_ | Valid usage check interval duration string is a signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "2h45m". Valid time units are "ns", "us", "ms", "s", "m", "h". Minimum supported value is '2h'.|
Example: Run usage check every 4 hours 3 minutes 10 seconds.
```sh
export MINIO_USAGE_CHECK_INTERVAL="4h3m10s"
minio server /data
```
#### Notify
|Field|Type|Description|
|:---|:---|:---|

Loading…
Cancel
Save