Merge pull request #14 from rdelval/mesosContainerizerSupport
Initial support for Mesos Containerizer
This commit is contained in:
commit
51699eda4e
3 changed files with 47 additions and 2 deletions
27
container.go
27
container.go
|
@ -22,7 +22,6 @@ type Container interface {
|
|||
Build() *aurora.Container
|
||||
}
|
||||
|
||||
// TODO(rdelvalle): Implement Mesos container builder
|
||||
type MesosContainer struct {
|
||||
container *aurora.MesosContainer
|
||||
}
|
||||
|
@ -48,3 +47,29 @@ func (c DockerContainer) AddParameter(name, value string) DockerContainer {
|
|||
c.container.Parameters = append(c.container.Parameters, &aurora.DockerParameter{name, value})
|
||||
return c
|
||||
}
|
||||
|
||||
func NewMesosContainer() MesosContainer {
|
||||
return MesosContainer{container: aurora.NewMesosContainer()}
|
||||
}
|
||||
|
||||
func (c MesosContainer) Build() *aurora.Container {
|
||||
return &aurora.Container{Mesos: c.container}
|
||||
}
|
||||
|
||||
func (c MesosContainer) DockerImage(name, tag string) MesosContainer {
|
||||
if c.container.Image == nil {
|
||||
c.container.Image = aurora.NewImage()
|
||||
}
|
||||
|
||||
c.container.Image.Docker = &aurora.DockerImage{name, tag}
|
||||
return c
|
||||
}
|
||||
|
||||
func (c MesosContainer) AppcImage(name, imageId string) MesosContainer {
|
||||
if c.container.Image == nil {
|
||||
c.container.Image = aurora.NewImage()
|
||||
}
|
||||
|
||||
c.container.Image.Appc = &aurora.AppcImage{name, imageId}
|
||||
return c
|
||||
}
|
||||
|
|
|
@ -156,6 +156,27 @@ func main() {
|
|||
}
|
||||
fmt.Println(resp.String())
|
||||
|
||||
if resp.ResponseCode == aurora.ResponseCode_OK {
|
||||
if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 10, 300); !ok || err != nil {
|
||||
_, err := r.KillJob(job.JobKey())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
case "createMesosContainer":
|
||||
fmt.Println("Creating a docker based job")
|
||||
container := realis.NewMesosContainer().DockerImage("python", "2.7")
|
||||
job.Container(container)
|
||||
resp, err := r.CreateJob(job)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println(resp.String())
|
||||
|
||||
if resp.ResponseCode == aurora.ResponseCode_OK {
|
||||
if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 10, 300); !ok || err != nil {
|
||||
_, err := r.KillJob(job.JobKey())
|
||||
|
|
1
job.go
1
job.go
|
@ -274,7 +274,6 @@ func (j AuroraJob) AddLimitConstraint(name string, limit int32) Job {
|
|||
}
|
||||
|
||||
// Set a container to run for the job configuration to run.
|
||||
// TODO (rdelvalle): Add no thermos mode where container is launched as a task and not an executor.
|
||||
func (j AuroraJob) Container(container Container) Job {
|
||||
j.jobConfig.TaskConfig.Container = container.Build()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue