1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00

Add host connectivity and Docker version check

This commit is contained in:
Sebastiaan van Steenis
2017-12-01 22:06:13 +01:00
parent fa3e30a6dc
commit bd8a966ce6
4 changed files with 43 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"reflect"
"regexp"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
@@ -14,6 +15,10 @@ import (
"github.com/sirupsen/logrus"
)
var K8sDockerVersions = map[string][]string{
"1.8": {"1.12.6", "1.13.1", "17.03.2"},
}
func DoRunContainer(dClient *client.Client, imageCfg *container.Config, hostCfg *container.HostConfig, containerName string, hostname string, plane string) error {
isRunning, err := IsContainerRunning(dClient, hostname, containerName)
if err != nil {
@@ -225,3 +230,15 @@ func IsContainerUpgradable(dClient *client.Client, imageCfg *container.Config, c
logrus.Debugf("[%s] Container [%s] is not eligible for updgrade on host [%s]", plane, containerName, hostname)
return false, nil
}
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
for _, DockerVersion := range K8sDockerVersions[K8sVersion] {
DockerVersionRegexp := regexp.MustCompile("^" + DockerVersion)
if DockerVersionRegexp.MatchString(info.ServerVersion) {
return true, nil
}
}
return false, nil
}