ajoute le self-healing des VM (sonde de santé, relance automatique, stock écarté) — bloc A, semaine 6
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b054888f5a
commit
f2649d0f8b
21 changed files with 938 additions and 28 deletions
|
|
@ -107,6 +107,44 @@ class StockChaud
|
|||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stacks prêtes, tous labs confondus (lues par SurveillanceVm).
|
||||
*
|
||||
* @return list<array{lab: string, nom: string, id: string, instances: array<string, string>, cree_a: int, brut: string}>
|
||||
*/
|
||||
public function pretes(): array
|
||||
{
|
||||
$pretes = [];
|
||||
|
||||
foreach (array_keys($this->labsDisponibles()) as $lab) {
|
||||
foreach (Redis::lrange(self::clePretes($lab), 0, -1) as $brut) {
|
||||
$stack = json_decode($brut, true);
|
||||
|
||||
if (is_array($stack) && isset($stack['nom'], $stack['id'], $stack['instances'])) {
|
||||
$pretes[] = ['lab' => $lab, 'cree_a' => (int) ($stack['cree_a'] ?? 0), 'brut' => $brut] + $stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $pretes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retire une stack prête précise du stock et la supprime. Faux si elle
|
||||
* n'y est plus (déjà donnée à un élève entre-temps) : on n'y touche pas.
|
||||
*/
|
||||
public function retirer(string $lab, string $brut): bool
|
||||
{
|
||||
if ((int) Redis::lrem(self::clePretes($lab), 1, $brut) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stack = json_decode($brut, true);
|
||||
$this->supprimerSansErreur($stack['nom'], $stack['id']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function commandeTerminee(string $lab, string $base): void
|
||||
{
|
||||
Redis::zrem(self::cleCommandes($lab), $base);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue