cluster/container: correctly name swarm tasks
Even after a slew of PRs, this still wasn't quite right. Now, we ensure the task name is calculared in one place in the executor, as least. We'll have to follow this up once the `api/naming` package from SwarmKit lands. Signed-off-by: Stephen J Day <stephen.day@docker.com> Upstream-commit: 3b1af1751897680d32f4685e86d5dd1d9f3720b1 Component: engine
This commit is contained in:
@@ -104,8 +104,13 @@ func (c *containerConfig) name() string {
|
||||
return c.task.Annotations.Name
|
||||
}
|
||||
|
||||
slot := fmt.Sprint(c.task.Slot)
|
||||
if slot == "" || c.task.Slot == 0 {
|
||||
slot = c.task.NodeID
|
||||
}
|
||||
|
||||
// fallback to service.slot.id.
|
||||
return strings.Join([]string{c.task.ServiceAnnotations.Name, fmt.Sprint(c.task.Slot), c.task.ID}, ".")
|
||||
return fmt.Sprintf("%s.%s.%s", c.task.ServiceAnnotations.Name, slot, c.task.ID)
|
||||
}
|
||||
|
||||
func (c *containerConfig) image() string {
|
||||
@@ -143,19 +148,11 @@ func (c *containerConfig) config() *enginecontainer.Config {
|
||||
}
|
||||
|
||||
func (c *containerConfig) labels() map[string]string {
|
||||
taskName := c.task.Annotations.Name
|
||||
if taskName == "" {
|
||||
if c.task.Slot != 0 {
|
||||
taskName = fmt.Sprintf("%v.%v.%v", c.task.ServiceAnnotations.Name, c.task.Slot, c.task.ID)
|
||||
} else {
|
||||
taskName = fmt.Sprintf("%v.%v.%v", c.task.ServiceAnnotations.Name, c.task.NodeID, c.task.ID)
|
||||
}
|
||||
}
|
||||
var (
|
||||
system = map[string]string{
|
||||
"task": "", // mark as cluster task
|
||||
"task.id": c.task.ID,
|
||||
"task.name": taskName,
|
||||
"task.name": c.name(),
|
||||
"node.id": c.task.NodeID,
|
||||
"service.id": c.task.ServiceID,
|
||||
"service.name": c.task.ServiceAnnotations.Name,
|
||||
|
||||
Reference in New Issue
Block a user