Turn rkt network status failure into Start failure
If the rkt driver cannot get the network status, for a task with a configured port mapping, it will now fail the Start() call and kill the task instead of simply logging. This matches the Docker behavior. If no port map is specified, the warnings will be logged but the task will be allowed to start.
This commit is contained in:
parent
55a2e60e1a
commit
f55f2b8f24
|
@ -593,13 +593,8 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse,
|
|||
d.logger.Printf("[DEBUG] driver.rkt: retrieving status for pod %q (UUID %s) for task %q with", img, uuid, d.taskName)
|
||||
deadline := time.Now().Add(rktNetworkDeadline)
|
||||
var driverNetwork *cstructs.DriverNetwork
|
||||
var notFirst bool
|
||||
networkLoop:
|
||||
for driverNetwork == nil && time.Now().Before(deadline) {
|
||||
if notFirst {
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
}
|
||||
notFirst = true
|
||||
|
||||
status, err := rktGetStatus(uuid)
|
||||
if err != nil {
|
||||
continue
|
||||
|
@ -616,20 +611,29 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse,
|
|||
if err == nil {
|
||||
portmap, err = rktManifestMakePortMap(manifest, driverConfig.PortMap)
|
||||
if err != nil {
|
||||
d.logger.Printf("[DEBUG] driver.rkt: could not create manifest-based portmap for %q (UUID %s) for task %q: %v", img, uuid, d.taskName, err)
|
||||
d.logger.Printf("[WARN] driver.rkt: could not create manifest-based portmap for %q (UUID %s) for task %q: %v", img, uuid, d.taskName, err)
|
||||
break networkLoop
|
||||
}
|
||||
} else {
|
||||
d.logger.Printf("[WARN] driver.rkt: could get not pod manifest for %q (UUID %s) for task %q: %v", img, uuid, d.taskName, err)
|
||||
break networkLoop
|
||||
}
|
||||
|
||||
driverNetwork = &cstructs.DriverNetwork{
|
||||
PortMap: portmap,
|
||||
IP: status.Networks[0].IP.String(),
|
||||
}
|
||||
break
|
||||
break networkLoop
|
||||
}
|
||||
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
}
|
||||
if driverNetwork == nil {
|
||||
// If a portmap was given, this turns into a fatal error
|
||||
if len(driverConfig.PortMap) != 0 {
|
||||
pluginClient.Kill()
|
||||
return nil, fmt.Errorf("Trying to map ports but driver could not determine network information")
|
||||
}
|
||||
d.logger.Printf("[WARN] driver.rkt: network status retrieval for pod %q (UUID %s) for task %q failed", img, uuid, d.taskName)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue