propellor spin

This commit is contained in:
Joey Hess 2014-10-23 11:26:05 -04:00
parent 5bfeb3f9aa
commit 80f5b53f1b
Failed to extract signature
4 changed files with 15 additions and 35 deletions

8
debian/changelog vendored
View File

@ -1,11 +1,3 @@
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 propellor (0.9.0) unstable; urgency=medium
* Avoid encoding the current stable suite in propellor's code, * Avoid encoding the current stable suite in propellor's code,

View File

@ -1,5 +1,3 @@
* There is no way for a property of a docker container to require * There is no way for a property of a docker container to require
some property be met outside the container. For example, some servers some property be met outside the container. For example, some servers
need ntp installed for a good date source. need ntp installed for a good date source.
* The SimpleSh was added before `docker exec` existed, and could probably
be eliminated by using that.

View File

@ -135,7 +135,7 @@ host hn = Host hn [] mempty
-- --
-- Can add Properties and RevertableProperties -- Can add Properties and RevertableProperties
(&) :: IsProp p => Host -> p -> Host (&) :: IsProp p => Host -> p -> Host
(Host hn ps is) & p = Host hn (ps ++ [toProp p]) (is <> getInfo p) (Host hn ps as) & p = Host hn (ps ++ [toProp p]) (as <> getInfo p)
infixl 1 & infixl 1 &
@ -145,14 +145,6 @@ h ! p = h & revert p
infixl 1 ! 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. -- Changes the action that is performed to satisfy a property.
adjustProperty :: Property -> (Propellor Result -> Propellor Result) -> Property adjustProperty :: Property -> (Propellor Result -> Propellor Result) -> Property
adjustProperty p f = p { propertySatisfy = f (propertySatisfy p) } adjustProperty p f = p { propertySatisfy = f (propertySatisfy p) }

View File

@ -19,6 +19,7 @@ module Propellor.Property.Docker (
-- * Container configuration -- * Container configuration
dns, dns,
hostname, hostname,
name,
publish, publish,
expose, expose,
user, user,
@ -155,15 +156,12 @@ mkContainer cid@(ContainerId hn _cn) h = Container
where where
info = _dockerinfo $ hostInfo h' info = _dockerinfo $ hostInfo h'
h' = h h' = h
-- Restart by default so container comes up on -- expose propellor directory inside the container
-- boot or when docker is upgraded.
&^ restart RestartAlways
-- Expose propellor directory inside the container.
& volume (localdir++":"++localdir) & volume (localdir++":"++localdir)
-- Name the container in a predictable way so we -- name the container in a predictable way so we
-- and the user can easily find it later. This property -- and the user can easily find it later
-- comes last, so it cannot be overridden.
& name (fromContainerId cid) & name (fromContainerId cid)
& restart RestartAlways
-- | Causes *any* docker images that are not in use by running containers to -- | Causes *any* docker images that are not in use by running containers to
-- be deleted. And deletes any containers that propellor has set up -- be deleted. And deletes any containers that propellor has set up
@ -222,7 +220,7 @@ dns = runProp "dns"
hostname :: String -> Property hostname :: String -> Property
hostname = runProp "hostname" hostname = runProp "hostname"
-- | Set name of container. -- | Set name for container. (Normally done automatically.)
name :: String -> Property name :: String -> Property
name = runProp "name" name = runProp "name"
@ -285,19 +283,19 @@ restart policy = runProp "restart" (serialize policy)
where where
serialize NoRestart = "no" serialize NoRestart = "no"
serialize (RestartOnFailure Nothing) = "on-failure" serialize (RestartOnFailure Nothing) = "on-failure"
serialize (RestartOnFailure (Just n)) = "on-failure:" ++ show n serialize (RestartOnFailure n) = "on-failure:" ++ show n
serialize RestartAlways = "always" serialize RestartAlways = "always"
-- | RestartAlways is the default for docker containers configured by -- | NoRestart makes docker not restart a container when it exits
-- 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! -- Note that this includes not restarting it on boot!
-- --
-- RestartOnFailure will restart the container if it exits nonzero. -- RestartOnFailure will restart the container if it exits nonzero.
-- A max-retry value can be provided to prevent too many restarts. -- A max-retry value can be provided to prevent repeated restarts.
--
-- 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.
data RestartPolicy = NoRestart | RestartOnFailure (Maybe Int) | RestartAlways data RestartPolicy = NoRestart | RestartOnFailure (Maybe Int) | RestartAlways
-- | A container is identified by its name, and the host -- | A container is identified by its name, and the host