mon: remove out of quorum mons from ceph.conf
The mons that are out of quorum may cause ceph commands to timeout
or fail unnecessarily trying to connect to a mon that is no longer
online. Now the mon health check will update the mon endpoints configmap
when a mon is detected out of quorum. This also means that if the
operator is restarted during a mon failover, the failed mon will no
longer remain in the ceph.conf, thus allowing the quorum to be more
likely to respond to the mons that are still in quorum.
The update for mons out of quorum only applies if other mons are in
quorum. If quorum is down, the configmap will not keep track of the offline
mons since too many are offline.
Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit b6e8ea2b50)
This commit is contained in:
1 parent
3fd49f2204
commit
96aef8a1ae
6 files changed
+168
-13
No files matched your search
@@ -56,6 +56,8 @@ const (
|
||||
EndpointConfigMapName = "rook-ceph-mon-endpoints"
|
||||
// EndpointDataKey is the name of the key inside the mon configmap to get the endpoints
|
||||
EndpointDataKey = "data"
|
||||
// OutOfQuorumKey is the name of the key for tracking mons detected out of quorum
|
||||
OutOfQuorumKey = "outOfQuorum"
|
||||
// MaxMonIDKey is the name of the max mon id used
|
||||
MaxMonIDKey = "maxMonId"
|
||||
// MappingKey is the name of the mapping for the mon->node and node->port
|
||||
@@ -249,6 +251,21 @@ func ExtractKey(contents string) (string, error) {
|
||||
return secret, nil
|
||||
}
|
||||
|
||||
func UpdateMonsOutOfQuorum(clientset kubernetes.Interface, namespace string, monsOutOfQuorum []string) error {
|
||||
ctx := context.TODO()
|
||||
cm, err := clientset.CoreV1().ConfigMaps(namespace).Get(ctx, EndpointConfigMapName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get mon endpoints configmap")
|
||||
}
|
||||
|
||||
cm.Data[OutOfQuorumKey] = strings.Join(monsOutOfQuorum, ",")
|
||||
_, err = clientset.CoreV1().ConfigMaps(namespace).Update(ctx, cm, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update mon endpoints configmap with mon(s) out of quorum")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// loadMonConfig returns the monitor endpoints and maxMonID
|
||||
func loadMonConfig(clientset kubernetes.Interface, namespace string) (map[string]*cephclient.MonInfo, int, *Mapping, error) {
|
||||
ctx := context.TODO()
|
||||
@@ -272,6 +289,18 @@ func loadMonConfig(clientset kubernetes.Interface, namespace string) (map[string
|
||||
monEndpointMap = ParseMonEndpoints(info)
|
||||
}
|
||||
|
||||
// Parse the mons that were detected out of quorum
|
||||
if outOfQuorum, ok := cm.Data[OutOfQuorumKey]; ok && len(outOfQuorum) > 0 {
|
||||
monNames := strings.Split(outOfQuorum, ",")
|
||||
for _, monName := range monNames {
|
||||
if monInfo, ok := monEndpointMap[monName]; ok {
|
||||
monInfo.OutOfQuorum = true
|
||||
} else {
|
||||
logger.Warningf("did not find mon %q to set it out of quorum in the cluster info", monName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the max monitor id
|
||||
storedMaxMonID := -1
|
||||
if id, ok := cm.Data[MaxMonIDKey]; ok {
|
||||
|
||||
Reference in new issue
Block a user