Skip to content

Commit

Permalink
Merge pull request rook#12137 from travisn/active-mgr-default
Browse files Browse the repository at this point in the history
mgr: Default to active mgr label
  • Loading branch information
travisn authored Apr 25, 2023
2 parents 46e6b73 + 1fa3c5a commit 844712a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/operator/ceph/cluster/mgr/mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const (
balancerModuleName = "balancer"
balancerModuleMode = "upmap"
mgrRoleLabelName = "mgr_role"
activeMgrStatus = "active"
standbyMgrStatus = "standby"
monitoringPath = "/etc/ceph-monitoring/"
serviceMonitorFile = "service-monitor.yaml"
// minimum amount of memory in MB to run the pod
Expand Down Expand Up @@ -238,9 +240,9 @@ func (c *Cluster) UpdateActiveMgrLabel(daemonNameToUpdate string, prevActiveMgr

labels := pod.GetLabels()
cephDaemonId := labels[controller.DaemonIDLabel]
newMgrRole := "standby"
newMgrRole := standbyMgrStatus
if currActiveMgr == cephDaemonId {
newMgrRole = "active"
newMgrRole = activeMgrStatus
}

currMgrRole, mgrHasLabel := labels[mgrRoleLabelName]
Expand Down Expand Up @@ -323,7 +325,7 @@ func (c *Cluster) updateServiceSelectors() {
_, hasMgrRoleLabel := service.Spec.Selector[mgrRoleLabelName]
if !hasMgrRoleLabel {
logger.Infof("adding %s selector label on mgr service %q", mgrRoleLabelName, service.Name)
service.Spec.Selector[mgrRoleLabelName] = "active"
service.Spec.Selector[mgrRoleLabelName] = activeMgrStatus
updateService = true
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/ceph/cluster/mgr/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ func (c *Cluster) getPodLabels(mgrConfig *mgrConfig, includeNewLabels bool) map[
labels := controller.CephDaemonAppLabels(AppName, c.clusterInfo.Namespace, config.MgrType, mgrConfig.DaemonID, c.clusterInfo.NamespacedName().Name, "cephclusters.ceph.rook.io", includeNewLabels)
// leave "instance" key for legacy usage
labels["instance"] = mgrConfig.DaemonID
if includeNewLabels {
// default to the active mgr label, and allow the sidecar to update if it's in standby mode
labels[mgrRoleLabelName] = activeMgrStatus
}
return labels
}

Expand Down

0 comments on commit 844712a

Please sign in to comment.