mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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>
This commit is contained in:
parent
6e462412d7
commit
3b1af17518
1 changed files with 7 additions and 10 deletions
|
@ -104,8 +104,13 @@ func (c *containerConfig) name() string {
|
||||||
return c.task.Annotations.Name
|
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.
|
// 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 {
|
func (c *containerConfig) image() string {
|
||||||
|
@ -143,19 +148,11 @@ func (c *containerConfig) config() *enginecontainer.Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *containerConfig) labels() map[string]string {
|
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 (
|
var (
|
||||||
system = map[string]string{
|
system = map[string]string{
|
||||||
"task": "", // mark as cluster task
|
"task": "", // mark as cluster task
|
||||||
"task.id": c.task.ID,
|
"task.id": c.task.ID,
|
||||||
"task.name": taskName,
|
"task.name": c.name(),
|
||||||
"node.id": c.task.NodeID,
|
"node.id": c.task.NodeID,
|
||||||
"service.id": c.task.ServiceID,
|
"service.id": c.task.ServiceID,
|
||||||
"service.name": c.task.ServiceAnnotations.Name,
|
"service.name": c.task.ServiceAnnotations.Name,
|
||||||
|
|
Loading…
Add table
Reference in a new issue