Skip to content

Commit

Permalink
eosfs: also removed user quota logic, externalized to the create_home…
Browse files Browse the repository at this point in the history
…_hook script
  • Loading branch information
glpatcern committed Dec 3, 2024
1 parent e6c0836 commit a813e76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
9 changes: 0 additions & 9 deletions pkg/storage/utils/eosfs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ type Config struct {
// QuotaNode for storing quota information
QuotaNode string `mapstructure:"quota_node"`

// DefaultQuotaBytes sets the default maximum bytes available for a user
DefaultQuotaBytes uint64 `mapstructure:"default_quota_bytes"`

// DefaultSecondaryQuotaBytes sets the default maximum bytes available for a secondary user
DefaultSecondaryQuotaBytes uint64 `mapstructure:"default_secondary_quota_bytes"`

// DefaultQuotaFiles sets the default maximum files available for a user
DefaultQuotaFiles uint64 `mapstructure:"default_quota_files"`

// UploadsNamespace for storing upload data
UploadsNamespace string `mapstructure:"uploads_namespace"`

Expand Down
27 changes: 7 additions & 20 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ func (c *Config) ApplyDefaults() {
c.QuotaNode = c.Namespace
}

if c.DefaultQuotaBytes == 0 {
c.DefaultQuotaBytes = 2000000000000 // 1 TB logical
}
if c.DefaultSecondaryQuotaBytes == 0 {
c.DefaultSecondaryQuotaBytes = c.DefaultQuotaBytes
}
if c.DefaultQuotaFiles == 0 {
c.DefaultQuotaFiles = 1000000 // 1 Million
}

if c.EosBinary == "" {
c.EosBinary = "/usr/bin/eos"
}
Expand Down Expand Up @@ -1270,24 +1260,21 @@ func (fs *eosfs) createNominalHome(ctx context.Context) error {
return errors.Wrap(err, "eosfs: error verifying if user home directory exists")
}

// set quota for user, depending on its type
quotaBytes := fs.conf.DefaultQuotaBytes
if u.Id.Type != userpb.UserType_USER_TYPE_PRIMARY {
quotaBytes = fs.conf.DefaultSecondaryQuotaBytes
}
log := appctx.GetLogger(ctx)
log.Info().Interface("user", u.Id).Msg("creating user home")

if fs.conf.CreateHomeHook != "" {
err = exec.Command(fs.conf.CreateHomeHook, u.Username, strconv.FormatUint(quotaBytes, 10), strconv.FormatUint(fs.conf.DefaultQuotaFiles, 10)).Run()
hook := exec.Command(fs.conf.CreateHomeHook, u.Username, utils.UserTypeToString(u.Id.Type))
err = hook.Run()
log.Info().Interface("output", hook.Stdout).Err(err).Msg("create_home_hook output")
if err != nil {
return errors.Wrap(err, "eosfs: error running post create home hook")
return errors.Wrap(err, "eosfs: error running create home hook")
}
} else {
log.Fatal().Msg("create_home_hook not configured")
return errtypes.NotFound("eosfs: create home hook not configured")
}

log := appctx.GetLogger(ctx)
log.Info().Uint64("quotaBytes", quotaBytes).Interface("user", u.Id).Msg("created nominal home")

return nil
}

Expand Down

0 comments on commit a813e76

Please sign in to comment.