Skip to content

Commit

Permalink
Exposed option to force docker pull for each task
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorDoyle committed Apr 14, 2015
1 parent c2e86b1 commit 2a65700
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 33 deletions.
15 changes: 15 additions & 0 deletions docs/docs/native-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ config file.

### Advanced Usage

#### Forcing a Docker Pull

Marathon 0.8.2 with Mesos 0.22.0 supports an option to force Docker to pull
the image before launching each task.

```json
{
"type": "DOCKER",
"docker": {
"image": "group/image",
"forcePullImage": true
}
}
```

#### Command vs Args

As of version 0.7.0, Marathon supports an `args` field in the app JSON. It is
Expand Down
1 change: 1 addition & 0 deletions examples/Docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"docker": {
"image": "libmesos/ubuntu"
},
"forcePullImage": false,
"volumes" : [
{
"containerPath": "/etc/a",
Expand Down
180 changes: 155 additions & 25 deletions src/main/java/mesosphere/marathon/Protos.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/main/proto/marathon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ message ExtendedContainerInfo {
// to be supported moving forward, as we might move away from
// the docker CLI.
repeated mesos.Parameter parameters = 5;

// With this flag set to true, the docker containerizer will
// pull the docker image from the registry even if the image
// is already downloaded on the slave.
optional bool force_pull_image = 6;
}

required mesos.ContainerInfo.Type type = 1;
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/mesosphere/marathon/api/v2/json/Formats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ trait ContainerFormats {
(__ \ "network").formatNullable[Network] ~
(__ \ "portMappings").formatNullable[Seq[Docker.PortMapping]] ~
(__ \ "privileged").formatNullable[Boolean].withDefault(false) ~
(__ \ "parameters").formatNullable[Seq[Parameter]].withDefault(Seq.empty)
)(Docker(_, _, _, _, _), unlift(Docker.unapply))
(__ \ "parameters").formatNullable[Seq[Parameter]].withDefault(Seq.empty) ~
(__ \ "forcePullImage").formatNullable[Boolean].withDefault(false)
)(Docker(_, _, _, _, _, _), unlift(Docker.unapply))

implicit val ModeFormat: Format[mesos.Volume.Mode] =
enumFormat(mesos.Volume.Mode.valueOf, str => s"$str is not a valid mode")
Expand Down
11 changes: 9 additions & 2 deletions src/main/scala/mesosphere/marathon/state/Container.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ object Container {
network: Option[mesos.ContainerInfo.DockerInfo.Network] = None,
portMappings: Option[Seq[Docker.PortMapping]] = None,
privileged: Boolean = false,
parameters: Seq[Parameter] = Nil) {
parameters: Seq[Parameter] = Nil,
forcePullImage: Boolean = false) {

def toProto(): Protos.ExtendedContainerInfo.DockerInfo = {
val builder = Protos.ExtendedContainerInfo.DockerInfo.newBuilder
Expand All @@ -111,6 +112,8 @@ object Container {

builder.addAllParameters(parameters.map(_.toProto).asJava)

builder.setForcePullImage(forcePullImage)

builder.build
}

Expand All @@ -129,6 +132,8 @@ object Container {

builder.addAllParameters(parameters.map(_.toProto).asJava)

builder.setForcePullImage(forcePullImage)

builder.build
}

Expand All @@ -150,7 +155,9 @@ object Container {

privileged = proto.getPrivileged,

parameters = proto.getParametersList.asScala.map(Parameter(_)).to[Seq]
parameters = proto.getParametersList.asScala.map(Parameter(_)).to[Seq],

forcePullImage = if (proto.hasForcePullImage) proto.getForcePullImage else false
)

/**
Expand Down
Loading

7 comments on commit 2a65700

@hekaldama
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can I do to help release this code? Looking to use this feature as soon as possible. Thanks!

@kolloch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in the process of finishing up our blockers. After that I am all in favour of a release myself.

@hekaldama
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be in the release?

@drexin
Copy link
Contributor

@drexin drexin commented on 2a65700 Apr 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been merged a while ago, so yes ;-)

@hekaldama
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drexin k. Guess I don't get the release paradigm. I was assuming releases are made off of master and was looking at when this was merged into master (seems like 7 days ago?). I am just learning how to contribute on github so forgive my ignorance.

@drexin
Copy link
Contributor

@drexin drexin commented on 2a65700 Apr 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct.

@3h4x
Copy link

@3h4x 3h4x commented on 2a65700 Apr 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also waiting for it! :) Killer feature!
Docs on mesosphere already mention this functionality so I upgraded mesos but I was amazed that marathon 0.8.2 wasn't released yet
https://mesosphere.github.io/marathon/docs/native-docker.html

Please sign in to comment.