mirror of
https://github.com/rancher/rke.git
synced 2025-09-05 17:00:20 +00:00
Cmd, Entrypoint are not guarenteed to be in the same order every time
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
ref "github.com/docker/distribution/reference"
|
ref "github.com/docker/distribution/reference"
|
||||||
@@ -19,6 +18,7 @@ import (
|
|||||||
"github.com/rancher/rke/log"
|
"github.com/rancher/rke/log"
|
||||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -209,7 +209,7 @@ func UseLocalOrPull(ctx context.Context, dClient *client.Client, hostname string
|
|||||||
logrus.Debugf("[%s] No pull necessary, image [%s] exists on host [%s]", plane, containerImage, hostname)
|
logrus.Debugf("[%s] No pull necessary, image [%s] exists on host [%s]", plane, containerImage, hostname)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
logrus.Infof("[%s] Pulling image [%s] on host [%s]", plane, containerImage, hostname)
|
log.Infof(ctx, "[%s] Pulling image [%s] on host [%s]", plane, containerImage, hostname)
|
||||||
if err := pullImage(ctx, dClient, hostname, containerImage, prsMap); err != nil {
|
if err := pullImage(ctx, dClient, hostname, containerImage, prsMap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -296,8 +296,8 @@ func IsContainerUpgradable(ctx context.Context, dClient *client.Client, imageCfg
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if containerInspect.Config.Image != imageCfg.Image ||
|
if containerInspect.Config.Image != imageCfg.Image ||
|
||||||
!reflect.DeepEqual(containerInspect.Config.Entrypoint, imageCfg.Entrypoint) ||
|
!sliceEqualsIgnoreOrder(containerInspect.Config.Entrypoint, imageCfg.Entrypoint) ||
|
||||||
!reflect.DeepEqual(containerInspect.Config.Cmd, imageCfg.Cmd) {
|
!sliceEqualsIgnoreOrder(containerInspect.Config.Cmd, imageCfg.Cmd) {
|
||||||
logrus.Debugf("[%s] Container [%s] is eligible for updgrade on host [%s]", plane, containerName, hostname)
|
logrus.Debugf("[%s] Container [%s] is eligible for updgrade on host [%s]", plane, containerName, hostname)
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@@ -305,6 +305,10 @@ func IsContainerUpgradable(ctx context.Context, dClient *client.Client, imageCfg
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sliceEqualsIgnoreOrder(left, right []string) bool {
|
||||||
|
return sets.NewString(left...).Equal(sets.NewString(right...))
|
||||||
|
}
|
||||||
|
|
||||||
func IsSupportedDockerVersion(info types.Info, K8sVersion string) (bool, error) {
|
func IsSupportedDockerVersion(info types.Info, K8sVersion string) (bool, error) {
|
||||||
// Docker versions are not semver compliant since stable/edge version (17.03 and higher) so we need to check if the reported ServerVersion starts with a compatible version
|
// Docker versions are not semver compliant since stable/edge version (17.03 and higher) so we need to check if the reported ServerVersion starts with a compatible version
|
||||||
for _, DockerVersion := range K8sDockerVersions[K8sVersion] {
|
for _, DockerVersion := range K8sDockerVersions[K8sVersion] {
|
||||||
|
Reference in New Issue
Block a user