in cookbooks/aws-parallelcluster-computefleet/files/clusterstatusmgtd/clusterstatusmgtd.py [0:0]
def manage_cluster_status(self):
"""
Manage cluster status.
When running pcluster start/stop command the fleet status is set to START_REQUESTED/STOP_REQUESTED.
The function fetches the current fleet status and performs the following transitions:
- START_REQUESTED -> STARTING -> RUNNING
- STOP_REQUESTED -> STOPPING -> STOPPED
STARTING/STOPPING states are only used to communicate that the request is being processed by clusterstatusmgtd.
On status STARTING|STOPPING, the update event handler baked by the recipe
aws-parallelcluster-entrypoints::update_computefleet_status is called
"""
self._current_time = datetime.now(tz=timezone.utc)
self._compute_fleet_status = self._get_compute_fleet_status(fallback=self._compute_fleet_status)
log.info("Current compute fleet status: %s", self._compute_fleet_status)
try:
if ComputeFleetStatus.is_stop_in_progress(self._compute_fleet_status):
self._update_status(
ComputeFleetStatus.STOP_REQUESTED, ComputeFleetStatus.STOPPING, ComputeFleetStatus.STOPPED
)
elif ComputeFleetStatus.is_start_in_progress(self._compute_fleet_status):
self._update_status(
ComputeFleetStatus.START_REQUESTED, ComputeFleetStatus.STARTING, ComputeFleetStatus.RUNNING
)
except ComputeFleetStatusManager.ConditionalStatusUpdateFailedError:
log.warning(
"Cluster status was updated while handling a transition from %s. "
"Status transition will be retried at the next iteration",
self._compute_fleet_status,
)