Merge pull request #27751 from stevvooe/task-naming-correction
cluster/container: correctly name swarm tasks
This commit is contained in:
commit
3dabad7992
1 changed files with 7 additions and 10 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue