Merge branch 'harduino-siemonster_improve_k8s' into launch

This commit is contained in:
frikky
2021-02-26 08:07:10 +01:00
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ func getThisContainerId() {
}
if fCol != "" {
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f%s", fCol)
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f%s | grep -o -E '[0-9A-z]{64}'", fCol)
out, err := exec.Command("bash", "-c", cmd).Output()
if err == nil {
containerId = strings.TrimSpace(string(out))
+6 -1
View File
@@ -52,8 +52,12 @@ var containerId string
// form container id of current running container
func getThisContainerId() string {
if len(containerId) > 0 {
return containerId
}
id := ""
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f3")
cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f3 | grep -o -E '[0-9A-z]{64}'")
out, err := exec.Command("bash", "-c", cmd).Output()
if err == nil {
id = strings.TrimSpace(string(out))
@@ -861,6 +865,7 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
}
// form container id and use it as network source if it's not empty
containerId = getThisContainerId()
if containerId != "" {
hostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", containerId))
} else {