From 23a03c59aa85d06b34369e5ba40dfc20dc7fae86 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 10 Jul 2020 14:27:55 +0200 Subject: [PATCH 1/3] Change single container tag to `docker-single-container` ; added tag `docker-compose-application`. The compose tag is not used yet, can be useful for metrics, and maybe other things later on. --- azure/backend.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/azure/backend.go b/azure/backend.go index b043e5975..baf5d1d7f 100644 --- a/azure/backend.go +++ b/azure/backend.go @@ -42,7 +42,8 @@ import ( ) const ( - singleContainerTag = "single--container--aci" + singleContainerTag = "docker-single-container" + composeContainerTag = "docker-compose-application" composeContainerSeparator = "_" statusUnknown = "Unknown" ) @@ -182,13 +183,16 @@ func (cs *aciContainerService) Run(ctx context.Context, r containers.ContainerCo if err != nil { return err } + addTag(groupDefinition, singleContainerTag) + return createACIContainers(ctx, cs.ctx, groupDefinition) +} + +func addTag(groupDefinition containerinstance.ContainerGroup, tagName string) { if groupDefinition.Tags == nil { groupDefinition.Tags = make(map[string]*string, 1) } - groupDefinition.Tags[singleContainerTag] = to.StringPtr("") - - return createACIContainers(ctx, cs.ctx, groupDefinition) + groupDefinition.Tags[tagName] = to.StringPtr("") } func (cs *aciContainerService) Stop(ctx context.Context, containerName string, timeout *uint32) error { @@ -315,6 +319,7 @@ func (cs *aciComposeService) Up(ctx context.Context, opts cli.ProjectOptions) er } logrus.Debugf("Up on project with name %q\n", project.Name) groupDefinition, err := convert.ToContainerGroup(cs.ctx, *project) + addTag(groupDefinition, composeContainerTag) if err != nil { return err From e2b0ee08ac8ed198e75576a5f0a2c7514c6afb4b Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 10 Jul 2020 14:29:24 +0200 Subject: [PATCH 2/3] Fixed wrong error message --- azure/backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/backend.go b/azure/backend.go index baf5d1d7f..2888285d1 100644 --- a/azure/backend.go +++ b/azure/backend.go @@ -132,7 +132,7 @@ func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.C if _, ok := group.Tags[singleContainerTag]; ok { if group.Containers == nil || len(*group.Containers) < 1 { - return []containers.Container{}, fmt.Errorf("no containers to run") + return []containers.Container{}, fmt.Errorf("found no containers in ACI container group %s", *containerGroup.Name) } container := (*group.Containers)[0] c := getContainer(*containerGroup.Name, group.IPAddress, container) From 042fb66ad8c5e2a51482f21ca405540dfc18a3fe Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 10 Jul 2020 14:41:13 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Better=20progress=20display:=20=E2=80=9CGro?= =?UTF-8?q?up=20xxx=E2=80=9D=20for=20container=20group=20creation,=20then?= =?UTF-8?q?=20separate=20lines=20for=20containers.=20For=20single=20contai?= =?UTF-8?q?ners,=20there=20was=20a=20single=20mixed=20line=20now=20that=20?= =?UTF-8?q?the=20group=20and=20the=20container=20have=20the=20same=20name.?= =?UTF-8?q?=20```=20=20$=20./bin/docker=20--context=20acitest=20run=20ngin?= =?UTF-8?q?x=20[+]=20Running=202/2=20=E2=A0=BF=20Group=20strange-bartik=20?= =?UTF-8?q?=20Created=20=20=20=20=20=20=20=20=204.2s=20=E2=A0=BF=20strange?= =?UTF-8?q?-bartik=20=20=20=20=20=20=20=20Done=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=2020.6s=20strange-bartik=20``?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- azure/aci.go | 5 +++-- azure/backend.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/azure/aci.go b/azure/aci.go index 74f4bf4cf..d488b0edb 100644 --- a/azure/aci.go +++ b/azure/aci.go @@ -71,8 +71,9 @@ func createOrUpdateACIContainers(ctx context.Context, aciContext store.AciContex if err != nil { return errors.Wrapf(err, "cannot get container group client") } + groupDisplay := "Group " + *groupDefinition.Name w.Event(progress.Event{ - ID: *groupDefinition.Name, + ID: groupDisplay, Status: progress.Working, StatusText: "Waiting", }) @@ -88,7 +89,7 @@ func createOrUpdateACIContainers(ctx context.Context, aciContext store.AciContex } w.Event(progress.Event{ - ID: *groupDefinition.Name, + ID: groupDisplay, Status: progress.Done, StatusText: "Created", }) diff --git a/azure/backend.go b/azure/backend.go index 2888285d1..858bdc08b 100644 --- a/azure/backend.go +++ b/azure/backend.go @@ -132,7 +132,7 @@ func (cs *aciContainerService) List(ctx context.Context, _ bool) ([]containers.C if _, ok := group.Tags[singleContainerTag]; ok { if group.Containers == nil || len(*group.Containers) < 1 { - return []containers.Container{}, fmt.Errorf("found no containers in ACI container group %s", *containerGroup.Name) + return []containers.Container{}, fmt.Errorf("no containers found in ACI container group %s", *containerGroup.Name) } container := (*group.Containers)[0] c := getContainer(*containerGroup.Name, group.IPAddress, container)