mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-15 02:37:27 +08:00
Fix undetected bugs in instance renaming
This commit is contained in:
parent
3ec374ed95
commit
861355d4e3
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
@ -94,7 +93,8 @@ func CreateInstance(session *Session, dindImage string) (*Instance, error) {
|
|||||||
session.Id: &network.EndpointSettings{Aliases: []string{nodeName}},
|
session.Id: &network.EndpointSettings{Aliases: []string{nodeName}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
container, err := c.ContainerCreate(context.Background(), conf, h, networkConf, fmt.Sprintf("%s_%s", session.Id[:4], nodeName))
|
containerName := fmt.Sprintf("%s_%s", session.Id[:8], nodeName)
|
||||||
|
container, err := c.ContainerCreate(context.Background(), conf, h, networkConf, containerName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -110,7 +110,7 @@ func CreateInstance(session *Session, dindImage string) (*Instance, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Instance{Name: strings.Replace(cinfo.Name, "/", "", 1), Hostname: cinfo.Config.Hostname, IP: cinfo.NetworkSettings.Networks[session.Id].IPAddress}, nil
|
return &Instance{Name: containerName, Hostname: cinfo.Config.Hostname, IP: cinfo.NetworkSettings.Networks[session.Id].IPAddress}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteContainer(id string) error {
|
func DeleteContainer(id string) error {
|
||||||
|
@ -90,7 +90,7 @@ func (s *sessionWriter) Write(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Instance) CollectStats() {
|
func (o *Instance) CollectStats() {
|
||||||
reader, err := GetContainerStats(o.Hostname)
|
reader, err := GetContainerStats(o.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error while trying to collect instance stats", err)
|
log.Println("Error while trying to collect instance stats", err)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user