Hash the Swarm Services too
This commit is contained in:
parent
51b4b2e85d
commit
4690696fed
1 changed files with 15 additions and 1 deletions
|
|
@ -345,10 +345,12 @@ class Bouncer
|
|||
private function stateHasChanged(): bool
|
||||
{
|
||||
$newInstanceStates = [];
|
||||
|
||||
// Standard Containers
|
||||
$containers = json_decode($this->client->request('GET', 'containers/json')->getBody()->getContents(), true);
|
||||
foreach ($containers as $container) {
|
||||
$inspect = json_decode($this->client->request('GET', "containers/{$container['Id']}/json")->getBody()->getContents(), true);
|
||||
$newInstanceStates[$inspect['Id']] = implode('::', [
|
||||
$newInstanceStates['container-' . $inspect['Id']] = implode('::', [
|
||||
$inspect['Name'],
|
||||
$inspect['Created'],
|
||||
$inspect['Image'],
|
||||
|
|
@ -356,6 +358,18 @@ class Bouncer
|
|||
sha1(implode('|', $inspect['Config']['Env'])),
|
||||
]);
|
||||
}
|
||||
|
||||
// Swarm Services
|
||||
$services = json_decode($this->client->request('GET', 'services')->getBody()->getContents(), true);
|
||||
if(isset($services['message'])){
|
||||
$this->logger->debug(sprintf('Something happened while interrogating services.. This node is not a swarm node, cannot have services: %s', $services['message']));
|
||||
}else{
|
||||
foreach($services as $service){
|
||||
$newInstanceStates['service-' . $service['ID']] = implode("::", [
|
||||
$service['Version']['Index']
|
||||
]);
|
||||
}
|
||||
}
|
||||
$newStateHash = sha1(implode("\n", $newInstanceStates));
|
||||
//$this->logger->debug(sprintf("Old state = %s. New State = %s.", substr($this->instanceStateHash,0,7), substr($newStateHash, 0,7)));
|
||||
if ($this->instanceStateHash != $newStateHash) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue