ceph: allow setting primary-affinity to osd#7807
Conversation
pkg/operator/ceph/cluster/osd/osd.go
Outdated
|
|
||
| err = prepareForDeployment(c, osdProps, osd, osdLongName) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to apply deployment fixup for %s", osdLongName) |
There was a problem hiding this comment.
fixup? Also please use %q instead of %s
There was a problem hiding this comment.
@leseb used "%s" to follow same pattern as rest of this error-formatting in this function. Note that "%q" is already used to format 'osdLongName'
pkg/operator/ceph/cluster/osd/osd.go
Outdated
|
|
||
| err = prepareForDeployment(c, osdProps, osd, osdLongName) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to prepare for deployment %s", osdLongName) |
There was a problem hiding this comment.
| return nil, errors.Wrapf(err, "failed to prepare for deployment %s", osdLongName) | |
| return nil, errors.Wrapf(err, "failed to prepare for deployment %q", osdLongName) |
pkg/operator/ceph/cluster/osd/osd.go
Outdated
| return d, nil | ||
| } | ||
|
|
||
| func prepareForDeployment(c *Cluster, osdProps osdProperties, osd OSDInfo, osdLongName string) error { |
There was a problem hiding this comment.
It feels unnecessary to pass osdLongNamesince you have osd OSDInfo, you can build it directly within prepareForDeployment()
pkg/operator/ceph/cluster/osd/osd.go
Outdated
|
|
||
| func prepareForDeployment(c *Cluster, osdProps osdProperties, osd OSDInfo, osdLongName string) error { | ||
| if osdProps.storeConfig.PrimaryAffinity != "" { | ||
| logger.Infof("Set primary-affinity %s for %s", osdProps.storeConfig.PrimaryAffinity, osdLongName) |
There was a problem hiding this comment.
Move this logger inside cephclient.OsdPrimaryAffinity.
sp98
left a comment
There was a problem hiding this comment.
(asking to better understand how primary-affinity works) I've seen some docs where its mentioned that we need to set mon osd allow primary affinity = true on ceph.conf to enable this functionality. Do we no longer need to do that ?
Some nits
6cd6785 to
786cdc7
Compare
pkg/apis/rook.io/v1/types.go
Outdated
| // +optional | ||
| CrushInitialWeight string `json:"crushInitialWeight,omitempty"` | ||
| // CrushPrimaryAffinity represents OSD primary-affinity within range [0,1) | ||
| // +kubebuilder:validation:Pattern=`^0.[0-9]+$` |
There was a problem hiding this comment.
Could you use a float type with a min and max value, instead of the string?
There was a problem hiding this comment.
We actually don't use the schema for VolumeSource so you don't need to worry about this schema. I'm opening a separate PR to clean that up...
There was a problem hiding this comment.
It appears that floats are highly discouraged in k8s API (kubernetes-sigs/controller-tools#245)
However, as there is no schema for VolumeSource, I will change it to float (optional, pointer).
There was a problem hiding this comment.
We already have the flag to force the generation if the API has floats, I'm not saying we should continue though. Also, I think the validation only works on strings IIRC.
There was a problem hiding this comment.
IMHO, if float is acceptable I think it would be better (and I will also make a fix for InitialWeight).
There was a problem hiding this comment.
IMHO, if float is acceptable I think it would be better (and I will also make a fix for InitialWeight).
Can we still use the validation pattern?
pkg/daemon/ceph/client/osd.go
Outdated
| } | ||
|
|
||
| // OsdPrimaryAffinity assigns primary-affinity (within range [0.0, 1.0]) to a specific OSD. | ||
| func OsdPrimaryAffinity(context *clusterd.Context, clusterInfo *ClusterInfo, osdID int, affinity string) error { |
There was a problem hiding this comment.
If the method doesn't indicate taking action, it's typically a "get" operation. How about this?
| func OsdPrimaryAffinity(context *clusterd.Context, clusterInfo *ClusterInfo, osdID int, affinity string) error { | |
| func SetPrimaryAffinity(context *clusterd.Context, clusterInfo *ClusterInfo, osdID int, affinity string) error { |
pkg/operator/ceph/cluster/osd/osd.go
Outdated
|
|
||
| func prepareForDeployment(c *Cluster, osdProps osdProperties, osd OSDInfo) error { | ||
| if osdProps.storeConfig.PrimaryAffinity != "" { | ||
| return cephclient.OsdPrimaryAffinity(c.context, c.clusterInfo, osd.ID, osdProps.storeConfig.PrimaryAffinity) |
There was a problem hiding this comment.
I'm not excited about setting this property with every reconcile, so would prefer if we can set it with a command line param.
pkg/operator/ceph/cluster/osd/osd.go
Outdated
| return d, nil | ||
| } | ||
|
|
||
| func prepareForDeployment(c *Cluster, osdProps osdProperties, osd OSDInfo) error { |
There was a problem hiding this comment.
| func prepareForDeployment(c *Cluster, osdProps osdProperties, osd OSDInfo) error { | |
| func setOSDProperties(c *Cluster, osdProps osdProperties, osd OSDInfo) error { |
|
This pull request has merge conflicts that must be resolved before it can be merged. @synarete please rebase it. https://rook.io/docs/rook/master/development-flow.html#updating-your-fork |
786cdc7 to
a22b0fe
Compare
travisn
left a comment
There was a problem hiding this comment.
The code changes look good. Please add this new setting to the docs in ceph-cluster-crds.md next to the deviceClass setting.
a22b0fe to
2016e35
Compare
pkg/operator/ceph/cluster/osd/osd.go
Outdated
|
|
||
| err = setOSDProperties(c, osdProps, osd) | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "failed to prepare for deployment %s", osdLongName) |
There was a problem hiding this comment.
| return nil, errors.Wrapf(err, "failed to prepare for deployment %s", osdLongName) | |
| return nil, errors.Wrapf(err, "failed to prepare deployment for %s", osdLongName) |
and there is already a comment about using %q
fe07667 to
f252aaf
Compare
A user with unbalanced system (e.g., some OSDs use a partition which resides on a device along-side OS partition) may want to have a fine-grained control on the overall load of specific OSD. While osd weight affects write-load, primary-affinity affects read-load. This patch allow user to define osd's primary-affinity (similar to 'DeviceClass' and 'InitialWeight'), which is sent to the osd (via mon) as part of deployment sequence, using 'ceph osd primary-affinity' command. Valid values are within the range [0.0, 1.0). If not set, default value is 1. ROOK issue: rook#7773 Signed-off-by: Shachar Sharon <ssharon@redhat.com>
f252aaf to
2a3cfc6
Compare
ceph: allow setting primary-affinity to osd (backport #7807)
A user with unbalanced system (e.g., some OSDs use a partition which
resides on a device along-side OS partition) may want to have a
fine-grained control on the overall load of specific OSD. While osd
weight affects write-load, primary-affinity affects read-load.
This patch allow user to define osd's primary-affinity (similar to
'DeviceClass' and 'InitialWeight'), which is sent to the osd (via mon)
as part of deployment sequence, using 'ceph osd primary-affinity' command.
Valid values are within the range [0.0, 1.0). If not set, default value
is 1.
ROOK issue: #7773
Signed-off-by: Shachar Sharon ssharon@redhat.com
Description of your changes:
Which issue is resolved by this Pull Request:
Resolves #
Checklist:
make codegen) has been run to update object specifications, if necessary.