Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceph: always apply config flags for mds and rgw #7681

Merged
merged 1 commit into from Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/operator/ceph/file/filesystem_test.go
Expand Up @@ -256,8 +256,10 @@ func TestCreateFilesystem(t *testing.T) {
return "", nil
} else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data1", "size", "1"}) {
return "", nil
} else if args[0] == "config" && args[1] == "set" {
return "", nil
}
assert.Fail(t, "Unexpected command")
assert.Fail(t, fmt.Sprintf("Unexpected command: %v", args))
return "", nil
},
}
Expand Down
24 changes: 14 additions & 10 deletions pkg/operator/ceph/file/mds/mds.go
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"strconv"
"strings"
"syscall"
"time"

"github.com/banzaicloud/k8s-objectmatcher/patch"
Expand All @@ -34,6 +35,7 @@ import (
"github.com/rook/rook/pkg/operator/ceph/config"
"github.com/rook/rook/pkg/operator/ceph/controller"
"github.com/rook/rook/pkg/operator/k8sutil"
"github.com/rook/rook/pkg/util/exec"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -136,17 +138,19 @@ func (c *Cluster) Start() error {
return errors.Wrapf(err, "failed to generate keyring for %q", resourceName)
}

// Check for existing deployment and set the daemon config flags
_, err = c.context.Clientset.AppsV1().Deployments(c.fs.Namespace).Get(ctx, mdsConfig.ResourceName, metav1.GetOptions{})
// We don't need to handle any error here
// Set the mds config flags
// Previously we were checking if the deployment was present, if not we would set the config flags
// Which means that we would only set the flag on newly created CephFilesystem CR
// Unfortunately, on upgrade we would not set the flags which is not ideal for old clusters where we were no setting those flags
// The KV supports setting those flags even if the MDS is running
logger.Info("setting mds config flags")
err = c.setDefaultFlagsMonConfigStore(mdsConfig.DaemonID)
if err != nil {
// Apply the flag only when the deployment is not found
if kerrors.IsNotFound(err) {
logger.Info("setting mds config flags")
err = c.setDefaultFlagsMonConfigStore(mdsConfig.DaemonID)
if err != nil {
return errors.Wrap(err, "failed to set default mds config options")
}
// Getting EPERM typically happens when the flag may not be modified at runtime
// This is fine to ignore
code, ok := exec.ExitStatus(err)
if ok && code != int(syscall.EPERM) {
return errors.Wrap(err, "failed to set default rgw config options")
}
}

Expand Down
24 changes: 14 additions & 10 deletions pkg/operator/ceph/object/rgw.go
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"fmt"
"reflect"
"syscall"

"github.com/banzaicloud/k8s-objectmatcher/patch"
"github.com/pkg/errors"
Expand All @@ -31,6 +32,7 @@ import (
"github.com/rook/rook/pkg/operator/ceph/config"
"github.com/rook/rook/pkg/operator/ceph/pool"
"github.com/rook/rook/pkg/operator/k8sutil"
"github.com/rook/rook/pkg/util/exec"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -113,17 +115,19 @@ func (c *clusterConfig) startRGWPods(realmName, zoneGroupName, zoneName string)
return errors.Wrap(err, "failed to create rgw keyring")
}

// Check for existing deployment and set the daemon config flags
_, err = c.context.Clientset.AppsV1().Deployments(c.store.Namespace).Get(ctx, rgwConfig.ResourceName, metav1.GetOptions{})
// We don't need to handle any error here
// Set the rgw config flags
// Previously we were checking if the deployment was present, if not we would set the config flags
// Which means that we would only set the flag on newly created CephObjectStore CR
// Unfortunately, on upgrade we would not set the flags which is not ideal for old clusters where we were no setting those flags
// The KV supports setting those flags even if the RGW is running
logger.Info("setting rgw config flags")
err = c.setDefaultFlagsMonConfigStore(rgwConfig.ResourceName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for a separate PR if anything... Could we set these flags instead with cmd line args instead of the ceph config? Or do we need to keep them as config so they can be overridden?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the flags are sensitive so we want to keep them as config so they can be overridden.

if err != nil {
// Apply the flag only when the deployment is not found
if kerrors.IsNotFound(err) {
logger.Info("setting rgw config flags")
err = c.setDefaultFlagsMonConfigStore(rgwConfig.ResourceName)
if err != nil {
return errors.Wrap(err, "failed to set default rgw config options")
}
// Getting EPERM typically happens when the flag may not be modified at runtime
// This is fine to ignore
code, ok := exec.ExitStatus(err)
if ok && code != int(syscall.EPERM) {
return errors.Wrap(err, "failed to set default rgw config options")
}
}

Expand Down