Skip to content

Commit

Permalink
Added QAT configs with experimental flag.
Browse files Browse the repository at this point in the history
Signed-off-by: Utkarsh Bhatt <[email protected]>
  • Loading branch information
UtkarshBhatthere committed Oct 16, 2024
1 parent c76c1f5 commit 5e741a1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
30 changes: 25 additions & 5 deletions microceph/ceph/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
type ClusterConfigPermission string

const (
ClusterConfigRO ClusterConfigPermission = "read_only"
ClusterConfigRW ClusterConfigPermission = "read_write"
ClusterConfigRO ClusterConfigPermission = "read_only" // Read Only
ClusterConfigRW ClusterConfigPermission = "read_write" // Read/ Write
ClusterConfigEXPRW ClusterConfigPermission = "exp_read_write" // Read/ Write but experimental features
)

type ClusterConfigDefinition struct {
Expand Down Expand Up @@ -84,6 +85,10 @@ func GetConstConfigTable() ConfigTable {
"rgw_swift_versioning_enabled": {"global", ClusterConfigRW, []string{"rgw"}},
"rgw_swift_enforce_content_length": {"global", ClusterConfigRW, []string{"rgw"}},
"rgw_swift_custom_header": {"global", ClusterConfigRW, []string{"rgw"}},
// RGW QAT config keys
"qat_compressor_enabled": {"client.radosgw.gateway", ClusterConfigEXPRW, []string{"rgw"}},
"openssl_engine_opts": {"client.radosgw.gateway", ClusterConfigEXPRW, []string{"rgw"}},
"plugin_crypto_accelerator": {"client.radosgw.gateway", ClusterConfigEXPRW, []string{"rgw"}},
}
}

Expand Down Expand Up @@ -160,10 +165,11 @@ func RemoveConfigItem(c types.Config) error {
return err
}

config := GetConstConfigTable()[c.Key]
args := []string{
"config",
"rm",
GetConstConfigTable()[c.Key].Who,
config.Who,
c.Key,
}

Expand All @@ -172,6 +178,12 @@ func RemoveConfigItem(c types.Config) error {
return err
}

if config.Permission == ClusterConfigEXPRW {
err := fmt.Errorf(constants.ExperimentalConfigErrTemplate, "reset", c.Key)
logger.Warn(err.Error())
return err
}

return nil
}

Expand Down Expand Up @@ -207,10 +219,11 @@ func ListConfigs() (types.Configs, error) {

// ****** Helper Functions ******//
func setConfigItem(c types.Config) error {
config := GetConstConfigTable()[c.Key]
args := []string{
"config",
"set",
GetConstConfigTable()[c.Key].Who,
config.Who,
c.Key,
c.Value,
"-f",
Expand All @@ -222,6 +235,12 @@ func setConfigItem(c types.Config) error {
return err
}

if config.Permission == ClusterConfigEXPRW {
err := fmt.Errorf(constants.ExperimentalConfigErrTemplate, "set", c.Key)
logger.Warn(err.Error())
return err
}

return nil
}

Expand All @@ -233,7 +252,8 @@ func canSetConfig(key string) (bool, error) {
return false, err
}

if config.Permission != ClusterConfigRW {
// check if write operation is permitted.
if !strings.Contains(string(config.Permission), "write") {
err := fmt.Errorf("requested key %s does not support write operation", key)
logger.Warnf(err.Error())
return false, err
Expand Down
5 changes: 5 additions & 0 deletions microceph/cmd/microceph/cluster_config_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"strings"

"github.com/canonical/microcluster/v2/microcluster"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -55,6 +56,10 @@ func (c *cmdClusterConfigReset) Run(cmd *cobra.Command, args []string) error {

err = client.ClearConfig(context.Background(), cli, req)
if err != nil {
if strings.Contains(err.Error(), "performed on experimental config") {
fmt.Println(err.Error())
return nil
}
return err
}

Expand Down
5 changes: 5 additions & 0 deletions microceph/cmd/microceph/cluster_config_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"strings"

"github.com/canonical/microcluster/v2/microcluster"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -56,6 +57,10 @@ func (c *cmdClusterConfigSet) Run(cmd *cobra.Command, args []string) error {

err = client.SetConfig(context.Background(), cli, req)
if err != nil {
if strings.Contains(err.Error(), "performed on experimental config") {
fmt.Println(err.Error())
return nil
}
return err
}

Expand Down
1 change: 1 addition & 0 deletions microceph/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const LoopSpecId = "loop,"
const DevicePathPrefix = "/dev/disk/by-id/"
const RgwSockPattern = "client.radosgw.gateway"
const CliForcePrompt = "If you understand the *RISK* and you're *ABSOLUTELY CERTAIN* that is what you want, pass --yes-i-really-mean-it."
const ExperimentalConfigErrTemplate = "WARNING: An operation (%s) was performed on experimental config (%s)"

// Path and filename constants

Expand Down

0 comments on commit 5e741a1

Please sign in to comment.