diff --git a/cmd/rook/ceph/osd.go b/cmd/rook/ceph/osd.go index 436b4b4e7..3e20f3a72 100644 --- a/cmd/rook/ceph/osd.go +++ b/cmd/rook/ceph/osd.go @@ -238,7 +238,7 @@ func prepareOSD(cmd *cobra.Command, args []string) error { Message: err.Error(), PvcBackedOSD: cfg.pvcBacked, } - oposd.UpdateNodeStatus(kv, cfg.nodeName, status) + oposd.UpdateNodeOrPVCStatus(kv, cfg.nodeName, status) rook.TerminateFatal(err) } diff --git a/pkg/daemon/ceph/osd/daemon.go b/pkg/daemon/ceph/osd/daemon.go index 3eeabea34..b158fc7d7 100644 --- a/pkg/daemon/ceph/osd/daemon.go +++ b/pkg/daemon/ceph/osd/daemon.go @@ -180,7 +180,7 @@ func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation, topolo // set the initial orchestration status status := oposd.OrchestrationStatus{Status: oposd.OrchestrationStatusOrchestrating} - oposd.UpdateNodeStatus(agent.kv, agent.nodeName, status) + oposd.UpdateNodeOrPVCStatus(agent.kv, agent.nodeName, status) if err := client.WriteCephConfig(context, agent.clusterInfo); err != nil { return errors.Wrap(err, "failed to generate ceph config") @@ -221,7 +221,7 @@ func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation, topolo // orchestration is about to start, update the status status = oposd.OrchestrationStatus{Status: oposd.OrchestrationStatusOrchestrating, PvcBackedOSD: agent.pvcBacked} - oposd.UpdateNodeStatus(agent.kv, agent.nodeName, status) + oposd.UpdateNodeOrPVCStatus(agent.kv, agent.nodeName, status) // start the desired OSDs on devices logger.Infof("configuring osd devices: %+v", devices) @@ -238,7 +238,7 @@ func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation, topolo if len(deviceOSDs) == 0 { logger.Warningf("skipping OSD configuration as no devices matched the storage settings for this node %q", agent.nodeName) status = oposd.OrchestrationStatus{OSDs: deviceOSDs, Status: oposd.OrchestrationStatusCompleted, PvcBackedOSD: agent.pvcBacked} - oposd.UpdateNodeStatus(agent.kv, agent.nodeName, status) + oposd.UpdateNodeOrPVCStatus(agent.kv, agent.nodeName, status) return nil } @@ -278,7 +278,7 @@ func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation, topolo // orchestration is completed, update the status status = oposd.OrchestrationStatus{OSDs: deviceOSDs, Status: oposd.OrchestrationStatusCompleted, PvcBackedOSD: agent.pvcBacked} - oposd.UpdateNodeStatus(agent.kv, agent.nodeName, status) + oposd.UpdateNodeOrPVCStatus(agent.kv, agent.nodeName, status) return nil } diff --git a/pkg/operator/ceph/cluster/osd/status.go b/pkg/operator/ceph/cluster/osd/status.go index 9943c7d0b..e1fc4ea88 100644 --- a/pkg/operator/ceph/cluster/osd/status.go +++ b/pkg/operator/ceph/cluster/osd/status.go @@ -99,7 +99,7 @@ func (e *provisionErrors) asMessages() string { // return name of status ConfigMap func (c *Cluster) updateOSDStatus(node string, status OrchestrationStatus) string { - return UpdateNodeStatus(c.kv, node, status) + return UpdateNodeOrPVCStatus(c.kv, node, status) } func statusConfigMapLabels(node string) map[string]string { @@ -110,14 +110,14 @@ func statusConfigMapLabels(node string) map[string]string { } } -// UpdateNodeStatus updates the status ConfigMap for the OSD on the given node. It returns the name +// UpdateNodeOrPVCStatus updates the status ConfigMap for the OSD on the given node or PVC. It returns the name // the ConfigMap used. -func UpdateNodeStatus(kv *k8sutil.ConfigMapKVStore, node string, status OrchestrationStatus) string { - labels := statusConfigMapLabels(node) +func UpdateNodeOrPVCStatus(kv *k8sutil.ConfigMapKVStore, nodeOrPVC string, status OrchestrationStatus) string { + labels := statusConfigMapLabels(nodeOrPVC) // update the status map with the given status now s, _ := json.Marshal(status) - cmName := statusConfigMapName(node) + cmName := statusConfigMapName(nodeOrPVC) if err := kv.SetValueWithLabels( cmName, orchestrationStatusKey, @@ -125,7 +125,7 @@ func UpdateNodeStatus(kv *k8sutil.ConfigMapKVStore, node string, status Orchestr labels, ); err != nil { // log the error, but allow the orchestration to continue even if the status update failed - logger.Errorf("failed to set node %q status to %q for osd orchestration. %s", node, status.Status, status.Message) + logger.Errorf("failed to set node or PVC %q status to %q for osd orchestration. %s", nodeOrPVC, status.Status, status.Message) } return cmName } @@ -133,7 +133,7 @@ func UpdateNodeStatus(kv *k8sutil.ConfigMapKVStore, node string, status Orchestr func (c *Cluster) handleOrchestrationFailure(errors *provisionErrors, nodeName, message string, args ...interface{}) { errors.addError(message, args...) status := OrchestrationStatus{Status: OrchestrationStatusFailed, Message: message} - UpdateNodeStatus(c.kv, nodeName, status) + UpdateNodeOrPVCStatus(c.kv, nodeName, status) } func parseOrchestrationStatus(data map[string]string) *OrchestrationStatus { diff --git a/pkg/operator/ceph/cluster/osd/status_test.go b/pkg/operator/ceph/cluster/osd/status_test.go index 3db934e91..2b3eafe6f 100644 --- a/pkg/operator/ceph/cluster/osd/status_test.go +++ b/pkg/operator/ceph/cluster/osd/status_test.go @@ -56,7 +56,7 @@ func TestOrchestrationStatus(t *testing.T) { // update the status map with some status status := OrchestrationStatus{Status: OrchestrationStatusOrchestrating, Message: "doing work"} - UpdateNodeStatus(kv, nodeName, status) + UpdateNodeOrPVCStatus(kv, nodeName, status) // retrieve the status and verify it statusMap, err := c.context.Clientset.CoreV1().ConfigMaps(c.clusterInfo.Namespace).Get(ctx, cmName, metav1.GetOptions{}) @@ -94,7 +94,7 @@ func mockNodeOrchestrationCompletion(c *Cluster, nodeName string, statusMapWatch }, Status: OrchestrationStatusCompleted, } - UpdateNodeStatus(c.kv, nodeName, *status) + UpdateNodeOrPVCStatus(c.kv, nodeName, *status) // 2) call modify on the fake watcher so a watch event will get triggered s, _ := json.Marshal(status)