-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use label "com.amazonaws.ecs.container-name" to render container names
- Loading branch information
Alfonso Acosta
committed
Sep 7, 2015
1 parent
e81efe6
commit e81cdb1
Showing
5 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package render | ||
|
||
import ( | ||
"github.com/weaveworks/scope/probe/docker" | ||
"github.com/weaveworks/scope/report" | ||
) | ||
|
||
// AmazonECSContainerNameLabel is exported for testing | ||
const AmazonECSContainerNameLabel = "com.amazonaws.ecs.container-name" | ||
|
||
// GetRenderableContainerName obtains a user-friendly container name, to render in the UI | ||
func GetRenderableContainerName(nmd report.Node) (string, bool) { | ||
// Amazon's ecs-agent uses huge Docker container names, destructively | ||
// derived from mangling the Container Definition name in Task | ||
// Definitions. | ||
// | ||
// taskFamiliyName-Version-TransformedContainerName-UUID | ||
// | ||
// For instance, a Container Definition name "http-server" declared in | ||
// Task Definition "task-example" with version 5 will lead to a container name | ||
// "task-example-5-httpserver-aceb93e2f2b797caba01" | ||
// | ||
// Note how the dash in http-server is removed not allowing to recover the original | ||
// Container Definition name. | ||
// | ||
// Luckily, the ecs-agent provides label | ||
// "com.amazonaws.ecs.container-name" containing the original Container | ||
// Definition name, which we will use for rendering. | ||
// | ||
if labelValue, ok := nmd.Metadata[docker.LabelPrefix+AmazonECSContainerNameLabel]; ok { | ||
return labelValue, true | ||
} | ||
|
||
name, ok := nmd.Metadata[docker.ContainerName] | ||
return name, ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters