summaryrefslogtreecommitdiff
path: root/morphlib/plugins/deploy_plugin.py
Commit message (Collapse)AuthorAgeFilesLines
* deploy: Allow extensions to write to Morph log fileRichard Maw2014-09-011-23/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is achieved by passing it the write end of a pipe, so that the extension has somewhere to write debug messages without clobbering either stdout or stderr. Previously deployment extensions could only display status messages on stdout, which is good for telling the user what is happening but is not useful when trying to do post-mortem debugging, when more information is usually required. This uses the asyncore asynchronous event framework, which is rather specific to sockets, but can be made to work with file descriptors, and has the advantage that it's part of the python standard library. It relies on polling file descriptors, but there's a trick with pipes to use them as a notification that a process has exited: 1. Ensure the write-end of the pipe is only open in the process you want to know when it exits 2. Make sure the pipe's FDs are set in non-blocking read/write mode 3. Call select or poll on the read-end of the file descriptor 4. If select/poll says you can read from that FD, but you get an EOF, then the process has closed it, and if you know it doesn't do that in normal operation, then the process has terminated. It took a few weird hacks to get the async_chat module to unregister its event handlers on EOF, but the result is an event loop that is asleep until the kernel tells it that it has to do something.
* Add `morph upgrade` command, deprecate `morph deploy --upgrade`Sam Thursfield2014-09-011-4/+26
| | | | | | The arguments to `morph deploy` can get quite long, any way we can make it shorter and clearer is useful. We can also avoid having the strange --no-upgrade flag in future.
* Clarify that multiple images can be deployed at once by `morph deploy`Sam Thursfield2014-09-011-1/+1
|
* Avoid creating and pushing temporary build branches when they aren't necessary.Richard Maw2014-08-121-32/+9
| | | | | | | | | | | | | | | | | | | | | Sorry about the big lump, I can split it into a nicer set of changes, but they didn't naturally emerge in a nice series. This creates a pushed_build_branch context manager, to eliminate code duplication between build and deploy. Rather than the build branch being constructed knowing whether it needs to push the branch, it infers that from the state of the repositories, and whether a local build would be possible. If there are no uncommitted changes and all local branches are pushed, then it doesn't create temporary branches or push them, and instead uses what it already has. It will currently create and use temporary build branches even for chunks that have no local changes, but it's pretty cheap, and doesn't require re-working the build-ref injection code to check whether there are local changes.
* Cut BuildBranch out of morphlib.extensionsRichard Maw2014-08-121-2/+1
| | | | | | | | | | | This was previously used just so it could get the right repo and ref to read the file out of. However, there was a subtle bug in this behaviour, as if we had not previously used morph build in that branch, it would attempt to read the extensions from a branch which didn't exist. So now it reads it from the working tree, which always exists.
* Turn BuildBranch methods into regular functionsRichard Maw2014-08-121-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | Previously they were generator functions, which yielded interesting context at interesting times so that the caller could respond by printing status messages. The only benefits this had over callbacks were: 1. 1 fewer function scope to worry about. I don't have data on the amount of memory used for a function scope vs a generator, but it could be less cognitive load for determining which variables are defined in the callback's body. 2. It is possible to yield in the caller, so you could make that into a coroutine too, however this wasn't required in this case, as the yielded value was intended to be informational. The downsides to this are: 1. It's a rather peculiar construct, so can be difficult to understand what's going on, and the implications, which led to 2. If you call the function, but don't use the iterator it returned, then it won't do anything, which is very confusing indeed, if you're not used to how generator functions work.
* Tidy deploy_plugin a littleRichard Maw2014-07-221-5/+5
|
* Make our use of json binary path safebaserock/richardmaw/bugfix/unicode-safe-jsonRichard Maw2014-07-111-1/+2
| | | | | | | | | | | | | | | | | | | | | json only accepts unicode. Various APIs such as file paths and environment variables allow binary data, so we need to support this properly. This patch changes every[1] use of json.load or json.dump to escape non-unicode data strings. This appears exactly as it used to if the input was valid unicode, if it isn't it will insert \xabcd escapes in the place of non-unicode data. When loading back in, if json.load is told to unescape it with `encoding='unicode-escape'` then it will convert it back correctly. This change was primarily to support file paths that weren't valid unicode, where this would choke and die. Now it works, but any tools that parsed the metadata need to unescape the paths. [1]: The interface to the remote repo cache uses json data, but I haven't changes its json.load calls to unescape the data, since the repo caches haven't been made to escape the data.
* Use exact filenames to refer to morphology filesRichard Maw2014-07-101-6/+4
| | | | | | | | | | | | | | | | | | | Rather than repeatedly stripping and appending an optional .morph extension morphology names, instead always use the file path of the morphology relative to the definitions repository. This is an inversion of the previous logic, which would strip the .morph extension and use the "name" internally. The exception to this rule of always using the filename, is that `morph edit CHUNK` uses the name of the morphology as-defined in the stratum. This is based off Adam Coldrick's inital patch, but this version will allow the old style of providing the "name" by converting it into a path if it does not have either a / or a . in it. An unfortunate consequence of this change is that the show-dependencies command's output changed, so the test needed updating.
* Make MorphologyFinder use file pathsRichard Maw2014-07-071-3/+2
| | | | | | | | | | | | | | | | | | | | We want to use file paths to locate morphologies now, so the old model of get a list of names and hand it those back to get the contents doesn't really make sense any more. This abstraction initially came about as one idea I had for moving morphologies out of the source tree was to put them in something like git notes, where it's possible to look up information for one commit in another ref in the repository, at which point this abstraction would have been flexible enough to handle that as well as in the However, moving the chunk morphologies into the definitions repository has other benefits too, so it makes more sense to be honest about using filenames in the API. It remains as a single point where we can put the logic for knowing which files in a repository look like morphologies, but if we need to remove any further functionality, it should be replaced by a single function.
* Update the help text for morph deployAdam Coldrick2014-06-181-1/+5
|
* Allow the user to specify deployments in a clusterAdam Coldrick2014-06-181-8/+43
| | | | | | | | Instead of taking the name of a cluster morphology and zero or more parameters for overriding the cluster morphology, morph deploy should take the name of a cluster morphology and the names of zero or more system deployments that are defined in the cluster morphology. If no deployment names are given then all deployments are deployed.
* Morph deploy should never update git reposPaul Sherwood2014-06-101-0/+1
| | | | | | | | The deploy plugin is relying on existing code which respects the 'no-git-update' setting and updates gits if it is not set. Since deploy can only work for built systems anyway, we can force this True for deployments, to avoid wasting the user/caller's time.
* Add utilities for listing and finding extensions.Mark Doffman2014-03-311-43/+16
| | | | | | | | | Add a module to morphlib that can list all write and configuration extensions either in morph itself or the morphology repository. The module also contains methods to find an extension filename from the name and type.
* Merge branch 'baserock/richardipsum/merge_distbuild'Richard Ipsum2014-03-271-2/+3
|\ | | | | | | | | | | | | | | | | | | Conflicts: morphlib/plugins/deploy_plugin.py without-test-modules Reviewed by: Richard Maw Lars Wirzenius
| * Fix deployRichard Ipsum2014-03-261-2/+3
| | | | | | | | | | | | | | | | | | tarfile's open needs the file-like object to have a tell() method, objects returned from sockets don't have this method. So instead we fetch the artifact from the remote and cache it locally
* | deploy: Set status prefix to show which deployment the status is forRichard Maw2014-03-141-53/+69
| |
* | deploy: Make extension output display which it isRichard Maw2014-03-141-1/+2
| | | | | | | | This also makes it obey status prefix
* | Add the ability to do nested deploymentsRichard Maw2014-03-141-6/+18
| |
* | Move deploy logic into multiple methodsRichard Maw2014-03-141-14/+28
| | | | | | | | | | Check is now separate from setup, which is now separate from running the commands.
* | Move tempdir creation out of the loopRichard Maw2014-03-141-21/+27
| | | | | | | | | | | | We don't need to remove the whole thing every time, and for nested deployments, we want to keep the directories around, since there will be multiple deploys happening in it concurrently.
* | Patch buildcommand once, rather that once per systemRichard Maw2014-03-141-3/+5
| |
* | Remove ugly loading of old b&m pluginRichard Maw2014-03-141-10/+0
| |
* | deploy: Record deployment information in deployed systemSam Thursfield2014-03-041-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a new requirement: USERS MUST NOT HAVE SENSITIVE DATA IN THEIR ENVIRONMENT. Otherwise it will be leaked into the system. Note that configuration fields with 'PASSWORD' in their name are stripped before writing the /baserock/deployment.meta file, so the OpenStack OS_PASSWORD field is not leaked. We want this so that we can run hooks at upgrade-time in the future. These hooks might need to know how the system was configured and what releaseuu it was. I'm not quite sure how we will define 'release' yet, but by using `git tag` and `git describe` we are able to textually label a time period in the history of the system's source code. We already have the specific SHA1 of definitions.git stored in the system metadata, so this should give us enough to be able to implement specific hooks that work around any awkward upgrade complications we encounter in the future.
* | deploy: Add optional 'check' extensionsSam Thursfield2014-03-041-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A write extension will have various kinds of sanity checks to do before actually performing the write. The current architecture of 'morph deploy' means that several minutes pass between the user starting the command and the write extension actually executing. It would be rage-inducing watching `morph deploy` spend 3 minutes unpacking a system only to then abort due to a silly error such as forgetting the --upgrade switch. Therefore it's better for now to split the sanity checks out into separate extensions that can be run as soon as possible and abort if the write extension is not going to be able to operate. For now this will just be used to validate usage of the --upgrade flag but in future checking connectivity to remote servers and the like should be done here too.
* | deploy: Add new --upgrade optionSam Thursfield2014-03-041-0/+7
| |
* | Add missing year to copyright headerLars Wirzenius2014-03-031-1/+1
|/ | | | | | After this, "./check --full" works. Reviewed-by: Daniel Silverstone (on IRC)
* Revert "Add utilities for listing and finding extensions."Mark Doffman2014-02-211-11/+40
| | | | This reverts commit ab0a83a09a93ca33aa402d9c4d3b916a48a1a882.
* Add utilities for listing and finding extensions.Mark Doffman2014-02-211-40/+11
|
* Deploy and cross-bootstrap commands no longer validate host architectureBen Brown2013-12-201-0/+4
|
* Modify morph to strip .morph extensions from parametersBen Brown2013-12-161-1/+1
|
* plugins: Convert deploy to new classes.Richard Maw2013-11-291-85/+70
| | | | | | | | | It now does not push branches as this is not necessary to locate the artifact. It still makes temporary build branches, since it is assumed that if you have changes in your workspace, it's preferable for the deploy to fail, rather than think you've deployed something you haven't.
* Deploying a non-cluster morphology now displays an error messageDaniel Firth2013-10-301-0/+4
|
* Morph now executes extensions in the repository containing the morphologiesDaniel Firth2013-09-261-1/+1
|
* Rework `morph deploy` to work with cluster morphologies.Tiago Gomes2013-08-161-77/+156
| | | | | | | | | | | | | From now on, `morph deploy` will work to only accept a cluster morphology as argument. A cluster morphology defines a list of systems to built, and for each system a list of ways to deploy them. We will not support the old syntax anymore. - Update `morph deploy` docstring with the new syntax, including an explanation of cluster morphologies (also document `tar` deployments). - Fix tests that used the old syntax. - Add tests for cluster deployments.
* deploy: Always cleanup deploy tempdir on failureRichard Maw2013-08-131-45/+52
| | | | | | | | | | | | | | | | | When a configuration extension or write extension fails, then it should abort then, not continue to run other configuration extensions. There was a period where this didn't happen, due to a missing feature of cliapp that was assumed to be there, so failure to run these extensions was not noticed. This has since been fixed, but this would cause deploy to fail to clean up its temporary directories. Now it will cleanup the contents of the temporary directory after any failures after it has been created. A small amount of re-ordering was performed to make this easier.
* deploy: Parse arguments before unpackRichard Maw2013-08-131-3/+3
| | | | | | | | It's a waste of time to unpack the rootfs, only to have to clean it up again when you find out that you messed up the command line arguments. This also has the benefit of reducing the amount of resources that have to be considered for cleanup.
* deploy: refactor environment argument parsingRichard Maw2013-08-131-7/+1
| | | | It is now a tested helper function in morphlib.util
* deploy plugin: Clean up deployments' tempdirsRichard Maw2013-08-091-7/+7
| | | | | | | | | We can't assume an extension cleans up after itself, as they can be arbitrary shell scripts, and the best shell has to offer for cleanup is `trap`, which is difficult to use. So now, anything created with `mktemp` will get automatically cleaned up by morph.
* Add morph cross-bootstrapSam Thursfield2013-07-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cross-bootstrap is a way to build baserock on an architecture that does not currently have Baserock. It can be used by `morph cross-bootstrap <ARCH> <REPO> <REF> <MORPH>`, and will build an artifact that can be used as a root filesystem with a basic build environment with a script named `native-bootstrap` which will build and install every chunk in the system. If done with a devel system, this will give you a suitable environment for building a proper Baserock system. This does not currently provide a kernel for the target architecture. Apart from adding the cross-bootstrap plugin, it also makes the following changes: * Moves the lit of valid_archs into morphlib (instead of locally-scoped in MorphologyFactory) * BuildCommand takes an extra argument, build_env * split BuildCommand's get_artifact_object into create_source_pool and resolve_artifacts (plus changes things that use get_artifact_object to use the new way) * setup_mounts finds out whether to do so by whether build_mode is 'staging', instead of by whether the setting 'staging-chroot' is true. * Makes ChunkBuilder's get_sources use the morphlib.builder2.extract_sources() method, and moved set_mtime_recursively into morphlib.builder2, since it's not currently used anywhere else. * moved ChunkBuilder's get_commands into the Morphology class (plus changes to anything that used get_commands)
* Improve docstring for "morph deploy"Lars Wirzenius2013-07-051-7/+152
|
* deploy plugin: Use sh instead of bash for timestampingRichard Maw2013-06-111-1/+1
| | | | | This was left over from experimentation, it works with sh, and is faster.
* deploy_plugin: Timestamp output of extensionsRichard Maw2013-06-101-1/+3
| | | | | This requires a patch to cliapp to actually print the output, as there is a bug that causes it to always output to a pipe.
* Remove intermediate variablesRichard Maw2013-06-061-3/+2
| | | | | I find it easier to read without them, since there are less variables to remember.
* Merge branch 'baserock/tiagogomes/tmpdir' of ↵Tiago Gomes2013-06-051-2/+5
|\ | | | | | | | | | | | | | | | | | | | | | | git://git.baserock.org/baserock/baserock/morph I had fixed an conflict and change to use morph_tmp instead of morph as default temp dir. Reviewed by Lars Wirzenius Conflicts: morphlib/app.py
| * Change the structure of the temporary directory used by morphTiago Gomes2013-06-051-2/+5
| | | | | | | | | | | | Now, inside the temporary directory we will have the following subdirectories: chunks, staging, failed and deployments. The failed directory will contain the staging areas of failed builds.
* | S7904: Add disk space checks before build & deployRichard Maw2013-06-051-0/+9
|/ | | | | | | The same check that cachedir and tempdir are large enough is used for both build and build-morphology. Deploy only checks for tempdir being large enough.
* Give better error message if extension is not executableLars Wirzenius2013-04-161-0/+9
|
* Merge remote-tracking branch 'origin/baserock/richardholland/ssh-config-ext'Lars Wirzenius2013-04-051-0/+2
|\
| * Added status output to print out running extensionRichard Holland2013-04-031-0/+2
| | | | | | | | | | Terminal will let user know which extension (write or config) is being run.