mirror of
https://github.com/docker/cli.git
synced 2026-09-26 01:10:35 -04:00
Merge pull request #27751 from stevvooe/task-naming-correction
cluster/container: correctly name swarm tasks Upstream-commit: 3dabad7992e7c75e880ae7b097cc6e119110a947 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