/** * @task break */ private function breakResource(DrydockResource $resource, Exception $ex) { switch ($resource->getStatus()) { case DrydockResourceStatus::STATUS_BROKEN: case DrydockResourceStatus::STATUS_RELEASED: case DrydockResourceStatus::STATUS_DESTROYED: // If the resource was already broken, just throw a normal exception. // This will retry the task eventually. throw new PhutilProxyException(pht('Unexpected failure while destroying resource ("%s").', $resource->getPHID()), $ex); } $resource->setStatus(DrydockResourceStatus::STATUS_BROKEN)->save(); $resource->scheduleUpdate(); $resource->logEvent(DrydockResourceActivationFailureLogType::LOGCONST, array('class' => get_class($ex), 'message' => $ex->getMessage())); throw new PhabricatorWorkerPermanentFailureException(pht('Permanent failure while activating resource ("%s"): %s', $resource->getPHID(), $ex->getMessage())); }
protected function reclaimResource(DrydockResource $resource, DrydockLease $lease) { $viewer = $this->getViewer(); $command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($resource->getPHID())->setAuthorPHID($lease->getPHID())->setCommand(DrydockCommand::COMMAND_RECLAIM)->save(); $resource->scheduleUpdate(); return $this; }