summaryrefslogtreecommitdiff
path: root/morphlib/plugins
Commit message (Collapse)AuthorAgeFilesLines
* Add status message on successful `morph checkout` / `morph branch`sam/no-git-update-fixesSam Thursfield2014-11-051-1/+2
| | | | The message tells the user where the newly created directory is.
* Make branch and merge commands honour --no-git-updateSam Thursfield2014-11-051-1/+3
| | | | | Previously they would do `git remote update --prune` after creating the system branch, without checking for the --no-git-update flag.
* Fix lines longer than 79 charactersSam Thursfield2014-10-291-2/+2
|
* Merge remote-tracking branch 'origin/sam/build-fix-3'Sam Thursfield2014-10-291-6/+15
|\ | | | | | | | | Reviewed-By: Richard Ipsum <richard.ipsum@codethink.co.uk> Reviewed-By: Richard Maw <richard.maw@codethink.co.uk>
| * Fix distbuild to allow passing a commit instead of a named ref to be builtSam Thursfield2014-10-271-6/+15
|/ | | | | | | | | | | The recent changes to the BuildCommand.build() function caused distbuild to break, because I didn't make the same change to the InitiatorBuildCommand.build() function but did change how it was called. This commit adds the ability to have optional fields in distbuild messages. This is used to add an optional 'original_ref' field, which will get passed to `morph serialise-artifact` by new distbuild controllers, and will be ignored by older ones.
* build: Resolve the ref being built in the user's local definitions.gitSam Thursfield2014-10-242-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Most usefully, this patch means that Morph no longer updates its cached copy of definitions.git every time you run `morph build`. Also, it prevents confusion in the following situation. Imagine I have run: morph checkout baserock:baserock/definitions master I then wait a while, during which time someone pushes to 'master' in the definitions.git repo that I cloned from. Now I run: cd master morph build systems/whatever.morph Which commit does it build, the local head of 'master' or the remote head of 'master'? The answer, both before and after this patch, is that it builds the local version of master. But previously, this only happened because of the magic that we have to detect local changes. With this patch, the local change detection could be disabled and `morph build` would still build what the user had checked out as 'master' locally, not whatever 'master' pointed to in the remote repo.
* build: Restructure how BuildCommand.build() is calledSam Thursfield2014-10-241-3/+5
| | | | | | | | | Rather than take a list of triplets to build, the BuildCommand.build() function now takes a single repo/ref/morph triplet. Iterating through multiple sets of triplets is now done in the build plugin. There are a couple of cosmetic changes to the status output at the start and end of a build as a result.
* Fix synopsis of `morph edit` commandSam Thursfield2014-10-221-1/+1
| | | | | Previously it was incorrect in the `morph help` output and in Morph's man page.
* Fix the `morph list-artifacts` commandSam Thursfield2014-10-101-6/+7
| | | | It was broken by the per-source building changes.
* Allow distbuilds to choose where to put logsRichard Maw2014-10-081-0/+5
|
* Fix issues with distbuild caused by moving to building per-sourceRichard Maw2014-10-082-3/+5
|
* Allow ephemeral ports for distbuild servicesRichard Maw2014-10-021-1/+1
|
* distbuild: allow daemons to bind to ephemeral portsRichard Maw2014-10-011-2/+22
| | | | | | | | | | | | | You can bind to an ephemeral port by passing 0 as the port number. To work out which port you actually got, you need to call getsockname(). To facilitate being able to spawn multiple copies of the daemons for testing environments, you can pass a -file option, which will make the daemon write which port it actually bound to. If this path is a fifo, reading from it in the spawner process will allow synchronisation of only spawning services that require that port to be ready after it is.
* Remove overlap detection logicRichard Maw2014-10-011-32/+0
| | | | | | | I've rarely needed to use it, and on those rare occasions, it would have been easy enough to calculate it. Let's get rid of this step, and save everyone some time in future.
* Remove run-in-artifact subcommandRichard Maw2014-10-011-1/+1
| | | | It's easy enough to deploy the image.
* Merge branch 'baserock/richardmaw-os/tidy-build-logic-v7'Richard Maw2014-09-222-72/+57
|\ | | | | | | | | | | Reviewed-by: Lars Wirzenius (+2 to misc fixups) Reviewed-by: Sam Thursfield (+1 to per-source building) Reviewed-by: Paul Sherwood (+1 to per-source building)
| * Fix show-dependencies plugin to use source deps.Richard Maw2014-09-191-2/+2
| |
| * Build per-source rather than per-artifactRichard Maw2014-09-191-66/+55
| |
| * Remove Morphology.builds_artifactsRichard Maw2014-09-191-4/+0
| | | | | | | | | | This was used before the Artifact splitting code landed to determine which artifacts should be produced.
| * Rename BuildCommand.get_sources to fetch_sourcesRichard Maw2014-09-191-1/+1
| | | | | | | | | | There's other methods called get_sources in other modules, and fetch_sources explains more about what it does in the context.
* | Don't log environment variables with 'PASSWORD' in their name.Sam Thursfield2014-09-191-2/+1
|/ | | | | | | | | | | | | | | | | | | This involved rewriting the util.log_dict_diff() function. It has been renamed to log_environment_changes() to better reflect its purpose. It no longer logs both the old and new values in the event of an environment variable changing. It now just logs the new value. This makes the code simpler and seems like it should not be a big problem. Some projects recommend passing credentials through the environment. OpenStack does this, for example, see: <http://docs.openstack.org/user-guide/content/cli_openrc.html> It's unlikely that users would be happy about applications saving these passwords in log files all over their system. I do not recommend ever storing valuable passwords in the environment.
* Fix `morph branch-from-image` to work for deployed imagesbaserock/richardmaw/bugfix/branch-from-deployed-imageRichard Maw2014-09-111-1/+2
| | | | | | It broke when we added /baserock/deployment.meta. We didn't notice this because our test suite was looking at the artifact produced by morph build, and listed on the terminal.
* 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
|
* morphloader: Get commands when loading morphologyAdam Coldrick2014-08-141-1/+1
| | | | | | Rather than having a `get_commands` method to obtain missing commands from the build system when they are needed, get the commands when loading a morphology.
* show-dependencies: Use sanitise_morphology_path instead of stripping `.morph`Adam Coldrick2014-08-141-2/+2
|
* Merge branch 'baserock/richardmaw/misc-fixups'baserock/richardmaw/tmpRichard Maw2014-08-121-104/+15
|\ | | | | | | | | Reviewed-by: Daniel Silverstone Reviewed-by: Pedro Alvarez
| * Fix `morph edit` when repo has the same ref as system branchRichard Maw2014-08-121-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a check in it to see whether it needed to do the git branch and git checkout based on whether the name of the branch matched that in the morphology. This had a couple of problems: 1. Now that we aren't always building from HEAD, we need to be able to roll its commit back, so using the existing branch isn't always the best idea. 2. It only checks the "ref" field, not "unpetrify-ref", so even though we clone the right ref in there, it's checking the commit id against the system branch name, so would always try to re-create the branch, and fail when it already exists. So now, we remove the original ref and re-create it with our preferred HEAD. A better solution might be to change the clone logic to not automatically checkout HEAD, and instead require an explicit branch then checkout, but the initial clone logic is shared with build, and I didn't feel like tracking down all the different places that it was used.
| * Make morph show-branch-root print the pathRichard Maw2014-08-121-3/+4
| | | | | | | | | | | | | | | | | | The help for the show-branch-root command said it returns a path, but the command and the yarns just showed the aliased url it was cloned from. Given I found myself needing the path in some scripts, not the repo url, I think it's more useful to reconcile the difference this way.
| * Remove petrify and unpetrify commandsRichard Maw2014-08-121-98/+0
|/ | | | | | | We don't use this any more, and instead prefer to always keep definitions.git petrified, and update the refs ourselves. branch-from-image still uses some of the remaining petrify code.
* Avoid creating and pushing temporary build branches when they aren't necessary.Richard Maw2014-08-122-64/+16
| | | | | | | | | | | | | | | | | | | | | 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-122-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use sanitise_morphology_path in serialise_artifactRichard Ipsum2014-07-311-1/+1
|
* Fix list-artifacts post chunks-in-definitionsbaserock/richardmaw/bugfix/fix-list-artifactsRichard Maw2014-07-281-1/+1
| | | | | | | The chunks in definitions change changed the api of create_source_pool, and because list artifacts is not covered by any tests, and the create_source_pool method was confused with a function of the same name that did not need changing, it failed to be fixed.
* Remove update-gits commandRichard Maw2014-07-221-83/+0
| | | | | | | | | This hasn't been used in a long time to my knowledge, its API completely misses the point, and its implementation relies on old APIs that need to change. Until we discover we need it, and work out what it should look like, I think the best thing to do is get rid of it.
* Tidy deploy_plugin a littleRichard Maw2014-07-221-5/+5
|
* Fix JSON file handling to be binary filename safeLars Wirzenius2014-07-151-1/+2
|\ | | | | | | | | Reviewed-by: Lars Wirzenius Reviewed-by: Pedro Alvarez
| * 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.
* | Fix bug in list-artifacts pluginRichard Ipsum2014-07-111-1/+1
|/
* Use exact filenames to refer to morphology filesRichard Maw2014-07-105-27/+28
| | | | | | | | | | | | | | | | | | | 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.
* Exorcise some old and unused commandsRichard Maw2014-07-072-2442/+536
| | | | | | | | | | | | | `morph merge` only worked for a small subset of cases, and has been left to bit-rot, since we don't use it. `morph tag` is just a `git tag` when we have petrified definitions repository. We don't use it, nor do we need it, so it can go away rather than take up valuable development time fixing it when requirements change. `old-foo` have all been superceded by newer versions and are no-longer used.
* Remove check on checkout/branch that there are systemsRichard Maw2014-07-071-22/+0
| | | | | | | This was the wrong response to the problem of accidentally checking-out morph when trying to check out morphs. Now that it's called definitions, this is irrelevent, and aborting a checkout when this check fails is the wrong thing to do.
* Remove code made vestigial from the `morph edit` rewriteRichard Maw2014-07-071-64/+0
| | | | | | This was originally used by `morph edit`, but since we removed the need to run `morph edit system stratum` and could shorten it to `morph edit chunk`, this function is no longer used.
* 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.
* Merge remote-tracking branch 'origin/sam/distbuild-gc-fix'Sam Thursfield2014-06-161-0/+3
|\ | | | | | | Reviewed-By: Lars Wirzenius <lars.wirzenius@codethink.co.uk>
| * Don't delete subdirectories of tempdir in gc pluginSam Thursfield2014-06-131-0/+3
| | | | | | | | | | | | There is code that assumes these exist in at least one place: StagingArea.abort(). That code should be fixed, but we should also stop deleting them every time we run 'morph gc'.