summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-10-23 11:33:00 -0400
committerJoey Hess2014-10-23 11:33:00 -0400
commitbdf3e37066a2f01eac7411b77a3b26e3796f5d65 (patch)
tree3b6b78300ed939e91bbe7acc84986dd71b0cd111
parent82838a37ab2fbb5cb35b29e9f0c0583cc0eaba9e (diff)
Revert "propellor spin"
This reverts commit 80f5b53f1b7fdc876d5e45df68c29f53bd9666b2.
-rw-r--r--debian/changelog8
-rw-r--r--doc/todo/docker_todo_list.mdwn2
-rw-r--r--src/Propellor/Property.hs10
-rw-r--r--src/Propellor/Property/Docker.hs30
4 files changed, 35 insertions, 15 deletions
diff --git a/debian/changelog b/debian/changelog
index 012826bd..9e90877d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+propellor (0.9.1) UNRELEASED; urgency=medium
+
+ * Docker: Add ability to control when containers restart.
+ * Docker: Default to always restarting containers, so they come back
+ up after reboots and docker daemon upgrades.
+
+ -- Joey Hess <joeyh@debian.org> Thu, 23 Oct 2014 03:05:22 -0400
+
propellor (0.9.0) unstable; urgency=medium
* Avoid encoding the current stable suite in propellor's code,
diff --git a/doc/todo/docker_todo_list.mdwn b/doc/todo/docker_todo_list.mdwn
index 1321445d..72ded426 100644
--- a/doc/todo/docker_todo_list.mdwn
+++ b/doc/todo/docker_todo_list.mdwn
@@ -1,3 +1,5 @@
* There is no way for a property of a docker container to require
some property be met outside the container. For example, some servers
need ntp installed for a good date source.
+* The SimpleSh was added before `docker exec` existed, and could probably
+ be eliminated by using that.
diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs
index ce825192..4b957317 100644
--- a/src/Propellor/Property.hs
+++ b/src/Propellor/Property.hs
@@ -135,7 +135,7 @@ host hn = Host hn [] mempty
--
-- Can add Properties and RevertableProperties
(&) :: IsProp p => Host -> p -> Host
-(Host hn ps as) & p = Host hn (ps ++ [toProp p]) (as <> getInfo p)
+(Host hn ps is) & p = Host hn (ps ++ [toProp p]) (is <> getInfo p)
infixl 1 &
@@ -145,6 +145,14 @@ h ! p = h & revert p
infixl 1 !
+-- | Like (&), but adds the property as the first property of the host.
+-- Normally, property order should not matter, but this is useful
+-- when it does.
+(&^) :: IsProp p => Host -> p -> Host
+(Host hn ps is) &^ p = Host hn ([toProp p] ++ ps) (getInfo p <> is)
+
+infixl 1 &^
+
-- Changes the action that is performed to satisfy a property.
adjustProperty :: Property -> (Propellor Result -> Propellor Result) -> Property
adjustProperty p f = p { propertySatisfy = f (propertySatisfy p) }
diff --git a/src/Propellor/Property/Docker.hs b/src/Propellor/Property/Docker.hs
index de3c64fb..b717fe19 100644
--- a/src/Propellor/Property/Docker.hs
+++ b/src/Propellor/Property/Docker.hs
@@ -19,7 +19,6 @@ module Propellor.Property.Docker (
-- * Container configuration
dns,
hostname,
- name,
publish,
expose,
user,
@@ -156,12 +155,15 @@ mkContainer cid@(ContainerId hn _cn) h = Container
where
info = _dockerinfo $ hostInfo h'
h' = h
- -- expose propellor directory inside the container
+ -- Restart by default so container comes up on
+ -- boot or when docker is upgraded.
+ &^ restart RestartAlways
+ -- Expose propellor directory inside the container.
& volume (localdir++":"++localdir)
- -- name the container in a predictable way so we
- -- and the user can easily find it later
+ -- Name the container in a predictable way so we
+ -- and the user can easily find it later. This property
+ -- comes last, so it cannot be overridden.
& name (fromContainerId cid)
- & restart RestartAlways
-- | Causes *any* docker images that are not in use by running containers to
-- be deleted. And deletes any containers that propellor has set up
@@ -220,7 +222,7 @@ dns = runProp "dns"
hostname :: String -> Property
hostname = runProp "hostname"
--- | Set name for container. (Normally done automatically.)
+-- | Set name of container.
name :: String -> Property
name = runProp "name"
@@ -283,19 +285,19 @@ restart policy = runProp "restart" (serialize policy)
where
serialize NoRestart = "no"
serialize (RestartOnFailure Nothing) = "on-failure"
- serialize (RestartOnFailure n) = "on-failure:" ++ show n
+ serialize (RestartOnFailure (Just n)) = "on-failure:" ++ show n
serialize RestartAlways = "always"
--- | NoRestart makes docker not restart a container when it exits
--- Note that this includes not restarting it on boot!
---
--- RestartOnFailure will restart the container if it exits nonzero.
--- A max-retry value can be provided to prevent repeated restarts.
---
--- RestartAlways is the default for docker containers configured by
+-- | RestartAlways is the default for docker containers configured by
-- propellor; as well as keeping badly behaved containers running,
-- it ensures that containers get started back up after reboot or
-- after docker is upgraded.
+--
+-- NoRestart makes docker not restart a container when it exits
+-- Note that this includes not restarting it on boot!
+--
+-- RestartOnFailure will restart the container if it exits nonzero.
+-- A max-retry value can be provided to prevent too many restarts.
data RestartPolicy = NoRestart | RestartOnFailure (Maybe Int) | RestartAlways
-- | A container is identified by its name, and the host