diff --git a/Dockerfile.dapper b/Dockerfile.dapper index eb52dcad..8f44661d 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -11,7 +11,7 @@ RUN apt-get update && \ ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH_arm64=arm64 GOLANG_ARCH=GOLANG_ARCH_${ARCH} \ GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash -RUN wget -O - https://storage.googleapis.com/golang/go1.19.3.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local +RUN wget -O - https://storage.googleapis.com/golang/go1.20.4.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2 diff --git a/cluster/plan.go b/cluster/plan.go index 21c77ae8..02021659 100644 --- a/cluster/plan.go +++ b/cluster/plan.go @@ -69,6 +69,7 @@ var ( parsedRangeAtLeast123 = semver.MustParseRange(">= 1.23.0-rancher0") parsedRangeAtLeast124 = semver.MustParseRange(">= 1.24.0-rancher0") parsedRangeAtLeast125 = semver.MustParseRange(">= 1.25.0-rancher0") + parsedRangeBelow127 = semver.MustParseRange("< 1.27.0-rancher0") parsedRange123 = semver.MustParseRange(">=1.23.0-rancher0 <=1.23.99-rancher-0") parsedRange124 = semver.MustParseRange(">=1.24.0-rancher0 <=1.24.99-rancher-0") ) @@ -505,12 +506,14 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, serviceOptions v3.Kubern var Binds []string if c.IsCRIDockerdEnabled() { - CommandArgs["container-runtime"] = "remote" - CommandArgs["container-runtime-endpoint"] = "/var/run/dockershim.sock" parsedVersion, err := getClusterVersion(c.Version) if err != nil { logrus.Debugf("Error while parsing cluster version: %s", err) } + if parsedRangeBelow127(parsedVersion) { + CommandArgs["container-runtime"] = "remote" // This flag has been removed from v1.27 https://v1-26.docs.kubernetes.io/docs/reference/command-line-tools-reference/kubelet/ + } + CommandArgs["container-runtime-endpoint"] = "/var/run/dockershim.sock" // cri-dockerd must be enabled if the cluster version is 1.24 and higher if parsedRangeAtLeast124(parsedVersion) { CommandArgs["container-runtime-endpoint"] = "unix:///var/run/cri-dockerd.sock" diff --git a/docker/docker.go b/docker/docker.go index 80ab06a2..bb7e97d9 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -381,11 +381,11 @@ func RestartContainer(ctx context.Context, dClient *client.Client, hostname, con return fmt.Errorf("Failed to restart container: docker client is nil for container [%s] on host [%s]", containerName, hostname) } var err error - restartTimeout := RestartTimeout * time.Second + restartTimeout := RestartTimeout // Retry up to RetryCount times to see if image exists for i := 1; i <= RetryCount; i++ { logrus.Infof("Restarting container [%s] on host [%s], try #%d", containerName, hostname, i) - err = dClient.ContainerRestart(ctx, containerName, &restartTimeout) + err = dClient.ContainerRestart(ctx, containerName, container.StopOptions{Timeout: &restartTimeout}) if err != nil { logrus.Warningf("Can't restart Docker container [%s] for host [%s]: %v", containerName, hostname, err) continue @@ -400,11 +400,11 @@ func StopContainer(ctx context.Context, dClient *client.Client, hostname string, } var err error // define the stop timeout - stopTimeoutDuration := StopTimeout * time.Second + stopTimeout := StopTimeout // Retry up to RetryCount times to see if image exists for i := 1; i <= RetryCount; i++ { - logrus.Infof("Stopping container [%s] on host [%s] with stopTimeoutDuration [%s], try #%d", containerName, hostname, stopTimeoutDuration, i) - err = dClient.ContainerStop(ctx, containerName, &stopTimeoutDuration) + logrus.Infof("Stopping container [%s] on host [%s] with stopTimeout [%d], try #%d", containerName, hostname, stopTimeout, i) + err = dClient.ContainerStop(ctx, containerName, container.StopOptions{Timeout: &stopTimeout}) if err != nil { logrus.Warningf("Can't stop Docker container [%s] for host [%s]: %v", containerName, hostname, err) continue @@ -453,11 +453,11 @@ func StartContainer(ctx context.Context, dClient *client.Client, hostname string return err } -func CreateContainer(ctx context.Context, dClient *client.Client, hostname string, containerName string, imageCfg *container.Config, hostCfg *container.HostConfig) (container.ContainerCreateCreatedBody, error) { +func CreateContainer(ctx context.Context, dClient *client.Client, hostname string, containerName string, imageCfg *container.Config, hostCfg *container.HostConfig) (container.CreateResponse, error) { if dClient == nil { - return container.ContainerCreateCreatedBody{}, fmt.Errorf("Failed to create container: docker client is nil for container [%s] on host [%s]", containerName, hostname) + return container.CreateResponse{}, fmt.Errorf("Failed to create container: docker client is nil for container [%s] on host [%s]", containerName, hostname) } - var created container.ContainerCreateCreatedBody + var created container.CreateResponse var err error // Retry up to RetryCount times to see if image exists for i := 1; i <= RetryCount; i++ { @@ -468,7 +468,7 @@ func CreateContainer(ctx context.Context, dClient *client.Client, hostname strin } return created, nil } - return container.ContainerCreateCreatedBody{}, fmt.Errorf("Failed to create Docker container [%s] on host [%s]: %v", containerName, hostname, err) + return container.CreateResponse{}, fmt.Errorf("Failed to create Docker container [%s] on host [%s]: %v", containerName, hostname, err) } func InspectContainer(ctx context.Context, dClient *client.Client, hostname string, containerName string) (types.ContainerJSON, error) {