morph icon indicating copy to clipboard operation
morph copied to clipboard

feat: dont build configuration locally before uploading it to remote host

Open srghma opened this issue 6 years ago • 5 comments

i've made morph push <config> and I see that it created lots of files in my local machine

https://github.com/DBCDK/morph/blob/master/morph.go#L328 https://github.com/DBCDK/morph/blob/master/nix/nix.go#L168

It seems like you are building them with nix-build

Consider how nix-rebuild is implemented

https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/tools/nixos-rebuild.sh#L100-L102

it uses nix-copy-closure to upload machine configuration to remote and build packages on remote

srghma avatar Feb 25 '19 12:02 srghma

Hi,

This was a conscious choice we made, since our network topology doesn't allow for hosts to arbitrarily go online.

However, we've recently discussed implemented an alternative approach similar to what you're suggesting, to make it possible at runtime to ask morph to build locally and push, or to upload the configuration and make the remote host do the heavy lifting.

adamtulinius avatar Feb 25 '19 13:02 adamtulinius

Giving this is :+1:, because it would definitely be nice to have, but I think the user should be able to choose between methods of deployment. Either via morph cmdline flags or via host deployment config (or perhaps both). @srghma Thanks for the issue, and btw feel free to submit a PR anytime :)

johanot avatar Feb 25 '19 13:02 johanot

There's plenty of things to figure out though, like, do we actually want the remote host to end up building software, or should it fail if it can't pull everything from a cache? It could end up pretty bad if a bunch of wimpy host each starts building ceph or something similar.

adamtulinius avatar Feb 25 '19 13:02 adamtulinius

The general approach to this in NixOps is, as far as I understand it, to locally check which packages are in the binary cache, build locally the ones that aren't (and upload them to the target systems), and then let the target systems fetch all the cache-available packages directly from the cache themselves.

That seems like a reasonable default to me, considering that it means that non-cache-available packages are only ever built once no matter how many target systems there are.

joepie91 avatar Jun 12 '19 21:06 joepie91

I feel like something that allows building on one node and propagating nix builds from that remote node would be a pretty good idea.

A scenario that I'm struggling with right now is deploying over CI/CD, and although morph did a good enough job, having to rebuild and refetch the Nix packages is a pain.

diamondburned avatar Sep 16 '19 07:09 diamondburned