Skip to content

Commit

Permalink
fix(mcl/deploy-spec): Handle 0 agents case and simplify logging
Browse files Browse the repository at this point in the history
  • Loading branch information
PetarKirov committed Jan 23, 2025
1 parent 82830be commit 0496211
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/mcl/src/src/mcl/commands/deploy_spec.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export void deploy_spec()
{
const deploySpecFile = resultDir.buildPath("cachix-deploy-spec.json");

DeploySpec spec;

if (!exists(deploySpecFile))
{
auto nixosConfigs = flakeAttr("legacyPackages", SupportedSystem.x86_64_linux, "bareMetalMachines")
Expand All @@ -39,19 +41,21 @@ export void deploy_spec()
if (!configsMissingFromCachix.empty)
throw new Exception("Some Nixos configurations are not in cachix. Please cache them first.");

auto spec = nixosConfigs.createMachineDeploySpec().toJSON;

infof("Deploy spec: %s", spec.toPrettyString(JSONOptions.doNotEscapeSlashes));

writeFile(deploySpecFile, spec.toString());
spec = nixosConfigs.createMachineDeploySpec();
writeFile(deploySpecFile, spec.toJSON.toPrettyString(JSONOptions.doNotEscapeSlashes));
}
else
{
warningf("Reusing existing deploy spec at:\n'%s'", deploySpecFile.bold);

warningf("\n---\n%s\n---", deploySpecFile.tryDeserializeFromJsonFile!DeploySpec);
spec = deploySpecFile.tryDeserializeFromJsonFile!DeploySpec;
}

infof("\n---\n%s\n---", spec);
infof("%s machines will be deployed.", spec.agents.length);

if (!spec.agents.length)
return;

spawnProcessInline([
"cachix", "deploy", "activate", deploySpecFile, "--async"
]);
Expand Down

0 comments on commit 0496211

Please sign in to comment.