-
Notifications
You must be signed in to change notification settings - Fork 788
AIO-interface: add Unhealthy container state #5307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,35 @@ | |
|
||
namespace AIO\Container; | ||
|
||
enum ContainerState: string { | ||
case ImageDoesNotExist = 'image_does_not_exist'; | ||
case NotRestarting = 'not_restarting'; | ||
case Restarting = 'restarting'; | ||
case Running = 'running'; | ||
case Starting = 'starting'; | ||
case Stopped = 'stopped'; | ||
enum ContainerState { | ||
case DoesNotExist; | ||
case Restarting; | ||
case Healthy; | ||
case Starting; | ||
case Stopped; | ||
case Unhealthy; | ||
|
||
public function isStopped(): bool { | ||
return $this == self::Stopped; | ||
} | ||
|
||
public function isStarting(): bool { | ||
return $this == self::Starting; | ||
} | ||
|
||
public function isRestarting(): bool { | ||
return $this == self::Restarting; | ||
} | ||
|
||
public function isHealthy(): bool { | ||
return $this == self::Healthy; | ||
} | ||
|
||
public function isUnhealthy(): bool { | ||
return $this == self::Unhealthy; | ||
} | ||
|
||
public function isRunning(): bool { | ||
return $this->isHealthy() || $this->isUnhealthy() || $this->isStarting() || $this->isRestarting(); | ||
} | ||
Comment on lines
+17
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Running state corresponds to the old GetRunningContainerState state. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace AIO\Container; | ||
|
||
enum UpdateState { | ||
case Outdated; | ||
case Latest; | ||
|
||
public function isUpdatableAvailable(): bool { | ||
return $this == self::Outdated; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
use AIO\Container\ContainerState; | ||
use AIO\ContainerDefinitionFetcher; | ||
use AIO\Docker\DockerActionManager; | ||
use GuzzleHttp\Exception\GuzzleException; | ||
use Psr\Http\Message\ResponseInterface as Response; | ||
use Psr\Http\Message\ServerRequestInterface as Request; | ||
use AIO\Data\ConfigurationManager; | ||
|
@@ -19,6 +20,7 @@ public function __construct( | |
) { | ||
} | ||
|
||
/** @throws GuzzleException */ | ||
private function PerformRecursiveContainerStart(string $id, bool $pullImage = true) : void { | ||
$container = $this->containerDefinitionFetcher->GetContainerById($id); | ||
|
||
|
@@ -28,7 +30,7 @@ private function PerformRecursiveContainerStart(string $id, bool $pullImage = tr | |
|
||
// Don't start if container is already running | ||
// This is expected to happen if a container is defined in depends_on of multiple containers | ||
if ($container->GetRunningState() === ContainerState::Running) { | ||
if ($container->GetContainerState()->isRunning()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. container->GetRunningState does not include Starting and Restarting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid it being hard to understand I went through the isSomething function |
||
error_log('Not starting ' . $id . ' because it was already started.'); | ||
return; | ||
} | ||
|
@@ -240,6 +242,7 @@ public function stopTopContainer() : void { | |
$this->PerformRecursiveContainerStop($id); | ||
} | ||
|
||
/** @throws GuzzleException */ | ||
public function StartDomaincheckContainer() : void | ||
{ | ||
# Don't start if domain is already set | ||
|
@@ -254,10 +257,10 @@ public function StartDomaincheckContainer() : void | |
$domaincheckContainer = $this->containerDefinitionFetcher->GetContainerById($id); | ||
$apacheContainer = $this->containerDefinitionFetcher->GetContainerById(self::TOP_CONTAINER); | ||
// Don't start if apache is already running | ||
if ($apacheContainer->GetRunningState() === ContainerState::Running) { | ||
if ($apacheContainer->GetContainerState()->isRunning()) { | ||
return; | ||
// Don't start if domaincheck is already running | ||
} elseif ($domaincheckContainer->GetRunningState() === ContainerState::Running) { | ||
} elseif ($domaincheckContainer->GetContainerState()->isRunning()) { | ||
$domaincheckWasStarted = apcu_fetch($cacheKey); | ||
// Start domaincheck again when 10 minutes are over by not returning here | ||
if($domaincheckWasStarted !== false && is_string($domaincheckWasStarted)) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.