diff --git a/microceph/ceph/config.go b/microceph/ceph/config.go index 6b14092e..daf6cf98 100644 --- a/microceph/ceph/config.go +++ b/microceph/ceph/config.go @@ -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 { @@ -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"}}, } } @@ -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, } @@ -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 } @@ -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", @@ -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 } @@ -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 diff --git a/microceph/cmd/microceph/cluster_config_reset.go b/microceph/cmd/microceph/cluster_config_reset.go index c88f5bcd..350f6111 100644 --- a/microceph/cmd/microceph/cluster_config_reset.go +++ b/microceph/cmd/microceph/cluster_config_reset.go @@ -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 { @@ -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 } diff --git a/microceph/cmd/microceph/cluster_config_set.go b/microceph/cmd/microceph/cluster_config_set.go index 670f2354..882dfbe9 100644 --- a/microceph/cmd/microceph/cluster_config_set.go +++ b/microceph/cmd/microceph/cluster_config_set.go @@ -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 { @@ -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 } diff --git a/microceph/constants/constants.go b/microceph/constants/constants.go index 9437fb5c..4dafd9d7 100644 --- a/microceph/constants/constants.go +++ b/microceph/constants/constants.go @@ -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