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 15, 2024
1 parent c76c1f5 commit 1a6baec
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
26 changes: 21 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,10 @@ func RemoveConfigItem(c types.Config) error {
return err
}

if config.Permission == ClusterConfigEXPRW {
return fmt.Errorf("WARNING: reset operation on experimental config (%s)", c.Key)
}

return nil
}

Expand Down Expand Up @@ -207,10 +217,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 +233,10 @@ func setConfigItem(c types.Config) error {
return err
}

if config.Permission == ClusterConfigEXPRW {
return fmt.Errorf("WARNING: set operation on experimental config (%s)", c.Key)
}

return nil
}

Expand All @@ -233,7 +248,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
6 changes: 6 additions & 0 deletions microceph/cmd/microceph/cluster_config_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package main
import (
"context"
"fmt"
"strings"

"github.com/canonical/microcluster/v2/microcluster"
"github.com/spf13/cobra"

"github.com/canonical/microceph/microceph/api/types"
"github.com/canonical/microceph/microceph/client"
"github.com/canonical/microceph/microceph/constants"
)

type cmdClusterConfigReset struct {
Expand Down Expand Up @@ -55,6 +57,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(), "experimental") {
fmt.Printf(constants.ExperimentalConfigErrTemplate, "reset", args[0])
return nil
}
return err
}

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

"github.com/canonical/microcluster/v2/microcluster"
"github.com/spf13/cobra"

"github.com/canonical/microceph/microceph/api/types"
"github.com/canonical/microceph/microceph/client"
"github.com/canonical/microceph/microceph/constants"
)

type cmdClusterConfigSet struct {
Expand Down Expand Up @@ -56,6 +58,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(), "experimental") {
fmt.Printf(constants.ExperimentalConfigErrTemplate, "set", args[0])
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 1a6baec

Please sign in to comment.