1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 06:40:31 +00:00

Handle system containers with no hash

This commit is contained in:
Darren Shepherd
2015-03-06 21:21:42 -07:00
parent c837a2ae59
commit f7b5b4f83b

View File

@@ -4,7 +4,6 @@ import (
"crypto/sha1"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"os"
"sort"
@@ -287,8 +286,12 @@ func (c *Container) renameOld(client *dockerClient.Client, opts *dockerClient.Cr
return nil
}
var newName string
if label, ok := existing.Config.Labels[HASH]; ok {
newName := fmt.Sprintf("%s-%s", existing.Name, label)
newName = fmt.Sprintf("%s-%s", existing.Name, label)
} else {
newName = fmt.Sprintf("%s-unknown-%s", existing.Name, util.RandSeq(12))
}
if existing.State.Running {
err := client.StopContainer(existing.ID, 2)
@@ -304,10 +307,6 @@ func (c *Container) renameOld(client *dockerClient.Client, opts *dockerClient.Cr
log.Debugf("Renaming %s to %s", existing.Name, newName)
return client.RenameContainer(existing.ID, newName)
} else {
//TODO: do something with containers with no hash
return errors.New("Existing container doesn't have a hash")
}
}
func (c *Container) getCreateOpts(client *dockerClient.Client) (*dockerClient.CreateContainerOptions, error) {