def is_resource_ready(self, resource): sts = resource name = sts.metadata.name spec = sts.spec status = sts.status gen = sts.metadata.generation or 0 observed_gen = status.observed_generation or 0 replicas = spec.replicas or 0 ready_replicas = status.ready_replicas or 0 updated_replicas = status.updated_replicas or 0 current_replicas = status.current_replicas or 0 if not self.allow_async_updates: is_update = observed_gen > 1 if is_update: strategy = spec.update_strategy.type or '' is_rolling = strategy == ROLLING_UPDATE_STRATEGY_TYPE if not is_rolling: msg = "{}: update strategy type = {}" raise armada_exceptions.WaitException( msg.format(ASYNC_UPDATE_NOT_ALLOWED_MSG, strategy)) if (is_rolling and replicas and spec.update_strategy.rolling_update and spec.update_strategy.rolling_update.partition): msg = "{}: partitioned rollout" raise armada_exceptions.WaitException( msg.format(ASYNC_UPDATE_NOT_ALLOWED_MSG)) if (observed_gen == 0 or gen > observed_gen): msg = "Waiting for statefulset spec update to be observed..." return (msg, False) if replicas and not self._is_min_ready(ready_replicas, replicas): msg = ( "Waiting for statefulset {} rollout to finish: {} of {} " "pods are ready, with min_ready={}") return ( msg.format( name, ready_replicas, replicas, self.min_ready.source), False) update_revision = status.update_revision or 0 current_revision = status.current_revision or 0 if update_revision != current_revision: msg = ( "waiting for statefulset rolling update to complete {} " "pods at revision {}...") return (msg.format(updated_replicas, update_revision), False) msg = "statefulset rolling update complete {} pods at revision {}..." return (msg.format(current_replicas, current_revision), True)
def is_resource_ready(self, resource): daemon = resource name = daemon.metadata.name spec = daemon.spec status = daemon.status if spec.update_strategy.type != ROLLING_UPDATE_STRATEGY_TYPE: msg = ("Assuming non-readiness for strategy type {}, can only " "determine for {}") raise armada_exceptions.WaitException( msg.format(spec.update_strategy.type, ROLLING_UPDATE_STRATEGY_TYPE)) if daemon.metadata.generation <= status.observed_generation: if (status.updated_number_scheduled < status.desired_number_scheduled): msg = ("Waiting for daemon set {} rollout to finish: {} out " "of {} new pods have been updated...") return (msg.format(name, status.updated_number_scheduled, status.desired_number_scheduled), False) if not self._is_min_ready(status.number_available, status.desired_number_scheduled): msg = ("Waiting for daemon set {} rollout to finish: {} of {} " "updated pods are available, with min_ready={}") return (msg.format(name, status.number_available, status.desired_number_scheduled, self.min_ready.source), False) msg = "daemon set {} successfully rolled out" return (msg.format(name), True) msg = "Waiting for daemon set spec update to be observed..." return (msg.format(), False)
def is_resource_ready(self, resource): daemon = resource name = daemon.metadata.name spec = daemon.spec status = daemon.status gen = daemon.metadata.generation or 0 observed_gen = status.observed_generation or 0 if not self.allow_async_updates: is_update = observed_gen > 1 if is_update: strategy = spec.update_strategy.type or '' is_rolling = strategy == ROLLING_UPDATE_STRATEGY_TYPE if not is_rolling: msg = "{}: update strategy type = {}" raise armada_exceptions.WaitException( msg.format(ASYNC_UPDATE_NOT_ALLOWED_MSG, strategy)) if gen <= observed_gen: updated_number_scheduled = status.updated_number_scheduled or 0 desired_number_scheduled = status.desired_number_scheduled or 0 number_available = status.number_available or 0 if (updated_number_scheduled < desired_number_scheduled): msg = ( "Waiting for daemon set {} rollout to finish: {} out " "of {} new pods have been updated...") return ( msg.format( name, updated_number_scheduled, desired_number_scheduled), False) if not self._is_min_ready(number_available, desired_number_scheduled): msg = ( "Waiting for daemon set {} rollout to finish: {} of {} " "updated pods are available, with min_ready={}") return ( msg.format( name, number_available, desired_number_scheduled, self.min_ready.source), False) msg = "daemon set {} successfully rolled out" return (msg.format(name), True) msg = "Waiting for daemon set spec update to be observed..." return (msg.format(), False)
def is_resource_ready(self, resource): sts = resource name = sts.metadata.name spec = sts.spec status = sts.status update_strategy_type = spec.update_strategy.type or '' if update_strategy_type != ROLLING_UPDATE_STRATEGY_TYPE: msg = ("Assuming non-readiness for strategy type {}, can only " "determine for {}") raise armada_exceptions.WaitException( msg.format(update_strategy_type, ROLLING_UPDATE_STRATEGY_TYPE)) gen = sts.metadata.generation or 0 observed_gen = status.observed_generation or 0 if (observed_gen == 0 or gen > observed_gen): msg = "Waiting for statefulset spec update to be observed..." return (msg, False) replicas = spec.replicas or 0 ready_replicas = status.ready_replicas or 0 updated_replicas = status.updated_replicas or 0 current_replicas = status.current_replicas or 0 if replicas and not self._is_min_ready(ready_replicas, replicas): msg = ("Waiting for statefulset {} rollout to finish: {} of {} " "pods are ready, with min_ready={}") return (msg.format(name, ready_replicas, replicas, self.min_ready.source), False) if (update_strategy_type == ROLLING_UPDATE_STRATEGY_TYPE and spec.update_strategy.rolling_update): if replicas and spec.update_strategy.rolling_update.partition: msg = ("Waiting on partitioned rollout not supported, " "assuming non-readiness of statefulset {}") return (msg.format(name), False) update_revision = status.update_revision or 0 current_revision = status.current_revision or 0 if update_revision != current_revision: msg = ("waiting for statefulset rolling update to complete {} " "pods at revision {}...") return (msg.format(updated_replicas, update_revision), False) msg = "statefulset rolling update complete {} pods at revision {}..." return (msg.format(current_replicas, current_revision), True)