Docker API client version bumped to 1.24 everywhere
This commit is contained in:
1 parent
55a46992d4
commit
e50040883f
12 files changed
+118
-27
No files matched your search
@@ -14,7 +14,7 @@ func containerAddrs(args []string) error {
|
|||||||
}
|
}
|
||||||
bridgeName := args[0]
|
bridgeName := args[0]
|
||||||
|
|
||||||
client, err := docker.NewVersionedClientFromEnv("1.18")
|
client, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func inspectContainer(containerNameOrID string) (*docker.Container, error) {
|
func inspectContainer(containerNameOrID string) (*docker.Container, error) {
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to connect to docker: %s", err)
|
return nil, fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ func parseContainerArgs(args []string) docker.CreateContainerOptions {
|
|||||||
func runContainer(args []string) error {
|
func runContainer(args []string) error {
|
||||||
containerOptions := parseContainerArgs(args)
|
containerOptions := parseContainerArgs(args)
|
||||||
|
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to connect to docker: %s", err)
|
return fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ func listContainers(args []string) error {
|
|||||||
cmdUsage("list-containers", "[<label>]")
|
cmdUsage("list-containers", "[<label>]")
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to connect to docker: %s", err)
|
return fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ func stopContainer(args []string) error {
|
|||||||
cmdUsage("stop-container", "<container-id> [<container-id2> ...]")
|
cmdUsage("stop-container", "<container-id> [<container-id2> ...]")
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to connect to docker: %s", err)
|
return fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ func killContainer(args []string) error {
|
|||||||
cmdUsage("kill-container", "<container-id> [<container-id2> ...]")
|
cmdUsage("kill-container", "<container-id> [<container-id2> ...]")
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to connect to docker: %s", err)
|
return fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ func removeContainer(args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to connect to docker: %s", err)
|
return fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaulDockerAPIVersion = "1.24"
|
||||||
|
const swarmDockerAPIVersion = "1.26"
|
||||||
|
|
||||||
|
// newVersionedDockerClientFromEnv offers some control over the version
|
||||||
|
// of the docker client weaveutil uses for a number of operations.
|
||||||
|
// The version specified by the caller, usually defaulDockerAPIVersion,
|
||||||
|
// may be overridden by setting an environment variable called
|
||||||
|
// DOCKER_API_VERSION.
|
||||||
|
func newVersionedDockerClientFromEnv(apiVersionString string) (*docker.Client, error) {
|
||||||
|
overridenAPIVersion, ok := os.LookupEnv("DOCKER_API_VERSION")
|
||||||
|
if ok && overridenAPIVersion != "" {
|
||||||
|
apiVersionString = overridenAPIVersion
|
||||||
|
}
|
||||||
|
return docker.NewVersionedClientFromEnv(apiVersionString)
|
||||||
|
}
|
||||||
@@ -90,6 +90,8 @@ func usage() {
|
|||||||
for cmd := range commands {
|
for cmd := range commands {
|
||||||
fmt.Fprintln(os.Stderr, cmd)
|
fmt.Fprintln(os.Stderr, cmd)
|
||||||
}
|
}
|
||||||
|
fmt.Fprintln(os.Stderr)
|
||||||
|
fmt.Fprintf(os.Stderr, "Set an environment variable called DOCKER_API_VERSION to control the API version used.\nDefault is: %v\n", defaulDockerAPIVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdUsage(cmd string, usage string) {
|
func cmdUsage(cmd string, usage string) {
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ func isDockerPluginEnabled(args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newDockerClient() (*docker.Client, error) {
|
func newDockerClient() (*docker.Client, error) {
|
||||||
// API 1.21 is the first version that supports docker network
|
// API 1.21 was the first version that supports docker network
|
||||||
// commands
|
// commands. In March 2024, the minimum suupported API is 1.24
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.21")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to connect to docker: %s", err)
|
return nil, fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DOCKER_API_VERSION = "1.26"
|
|
||||||
|
|
||||||
func swarmManagerPeers(args []string) error {
|
func swarmManagerPeers(args []string) error {
|
||||||
info, err := dockerInfo()
|
info, err := dockerInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -32,7 +30,7 @@ func swarmManagerPeers(args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func dockerInfo() (*docker.DockerInfo, error) {
|
func dockerInfo() (*docker.DockerInfo, error) {
|
||||||
client, err := docker.NewVersionedClientFromEnv(DOCKER_API_VERSION)
|
client, err := newVersionedDockerClientFromEnv(swarmDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "docker.NewVersionedClientFromEnv")
|
return nil, errors.Wrap(err, "docker.NewVersionedClientFromEnv")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func createVolumeContainer(args []string) error {
|
|||||||
label := args[2]
|
label := args[2]
|
||||||
bindMounts := args[3:]
|
bindMounts := args[3:]
|
||||||
|
|
||||||
c, err := docker.NewVersionedClientFromEnv("1.18")
|
c, err := newVersionedDockerClientFromEnv(defaulDockerAPIVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to connect to docker: %s", err)
|
return fmt.Errorf("unable to connect to docker: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package proxy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
type createExecInterceptor struct{ proxy *Proxy }
|
type createExecInterceptor struct{ proxy *Proxy }
|
||||||
@@ -18,7 +21,19 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, hasWeaveWait := container.Volumes["/w"]; !hasWeaveWait {
|
// The .Volumes property seems to have been replaced with .Mounts in Docker
|
||||||
|
// API 1.20.
|
||||||
|
// .Volumes was a list, where the key was the mount path or destination
|
||||||
|
// .Mounts is an array of objects, where the .Destination property
|
||||||
|
// corresponds to the old .Volumes list key.
|
||||||
|
//
|
||||||
|
// if _, hasWeaveWait := container.Volumes["/w"]; !hasWeaveWait {
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
mountIndex := slices.IndexFunc(container.Mounts, func(m docker.Mount) bool {
|
||||||
|
return m.Destination == "/w"
|
||||||
|
})
|
||||||
|
if mountIndex == -1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+42
-6
@@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
@@ -125,6 +126,16 @@ func (j attachJob) Stop() {
|
|||||||
j.timer.Stop()
|
j.timer.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaulDockerAPIVersion = "1.24"
|
||||||
|
|
||||||
|
func dockerAPIVersion() string {
|
||||||
|
overridenAPIVersion, ok := os.LookupEnv("DOCKER_API_VERSION")
|
||||||
|
if ok && overridenAPIVersion != "" {
|
||||||
|
return overridenAPIVersion
|
||||||
|
}
|
||||||
|
return defaulDockerAPIVersion
|
||||||
|
}
|
||||||
|
|
||||||
func StubProxy(c Config) (*Proxy, error) {
|
func StubProxy(c Config) (*Proxy, error) {
|
||||||
p := &Proxy{
|
p := &Proxy{
|
||||||
Config: c,
|
Config: c,
|
||||||
@@ -139,7 +150,14 @@ func StubProxy(c Config) (*Proxy, error) {
|
|||||||
// to insulate ourselves from breaking changes to the API, as
|
// to insulate ourselves from breaking changes to the API, as
|
||||||
// happened in 1.20 (Docker 1.8.0) when the presentation of
|
// happened in 1.20 (Docker 1.8.0) when the presentation of
|
||||||
// volumes changed in `inspect`.
|
// volumes changed in `inspect`.
|
||||||
client, err := weavedocker.NewVersionedClient(c.DockerHost, "1.18")
|
// Updated in March 2024: We can't do that any more. Protocol
|
||||||
|
// version has to be updated to minimum 1.24.
|
||||||
|
// The presentation of volumes aspect has been handled later in
|
||||||
|
// this file. There may be other breaking changes if we change
|
||||||
|
// the protocol again, so will wait and watch.
|
||||||
|
// The default, 1.24, can be overridden using an environment
|
||||||
|
// variable called DOCKER_API_VERSION.
|
||||||
|
client, err := weavedocker.NewVersionedClient(c.DockerHost, dockerAPIVersion())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -212,15 +230,33 @@ func (proxy *Proxy) findVolume(v string) (string, error) {
|
|||||||
return "", fmt.Errorf("Could not find the weavewait volume: %s", err)
|
return "", fmt.Errorf("Could not find the weavewait volume: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if container.Volumes == nil {
|
// The .Volumes property seems to have been replaced with .Mounts in Docker
|
||||||
return "", fmt.Errorf("Could not find the weavewait volume")
|
// API 1.20.
|
||||||
|
// .Volumes was a list, where the key was the mount path or destination
|
||||||
|
// .Mounts is an array of objects, where the .Destination property
|
||||||
|
// corresponds to the old .Volumes list key.
|
||||||
|
//
|
||||||
|
// if container.Volumes == nil {
|
||||||
|
// return "", fmt.Errorf("Could not find the weavewait volume - no volumes : %+v", container)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// volume, ok := container.Volumes[v]
|
||||||
|
// if !ok {
|
||||||
|
// return "", fmt.Errorf("Could not find the weavewait volume named '%v' : %+v", v, container)
|
||||||
|
// }
|
||||||
|
mounts := container.Mounts
|
||||||
|
if mounts == nil {
|
||||||
|
return "", fmt.Errorf("Could not find the weavewait volume - no volumes : %+v", container)
|
||||||
}
|
}
|
||||||
|
|
||||||
volume, ok := container.Volumes[v]
|
mountIndex := slices.IndexFunc(mounts, func(m docker.Mount) bool {
|
||||||
if !ok {
|
return m.Destination == v
|
||||||
return "", fmt.Errorf("Could not find the weavewait volume")
|
})
|
||||||
|
if mountIndex < 0 {
|
||||||
|
return "", fmt.Errorf("Could not find the weavewait volume named '%v' : %+v", v, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volume := container.Mounts[mountIndex].Name
|
||||||
return volume, nil
|
return volume, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-1
@@ -2,7 +2,22 @@
|
|||||||
|
|
||||||
All changes made to the weave net codebase during the reweave effort will be documented in this file.
|
All changes made to the weave net codebase during the reweave effort will be documented in this file.
|
||||||
|
|
||||||
## 2.8.2 latest
|
## latest
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* The docker API client version, used by the proxy package and the weaveutil command, was bumped from 1.18 to 1.24. As of March 2024, Docker API versions below 1.24 are deprecated. This means that the minimum supported Docker version is now 1.12.0
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Provision was made in weaveutil program and the weave script to override the API version used, via the environment variable `DOCKER_API_VERSION`. The same variable is used by standard docker clients
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Fixed `proxy.go` in the proxy package to handle changes in the Docker API. In the 1.24 API, container objects expose a `.Mounts` property rather than a `.Volumes` property.
|
||||||
|
* The `weave` script was modified to add a `-t` switch when invoking functionality inside a container. This ensures that output is visible even when using the Weave docker proxy
|
||||||
|
|
||||||
|
## 2.8.2 (7b087168)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
IMAGE_VERSION ?= 2.8.2
|
IMAGE_VERSION ?= 2.8.3-beta1
|
||||||
REGISTRY_USER ?= rajchaudhuri
|
REGISTRY_USER ?= rajchaudhuri
|
||||||
|
|
||||||
ALPINE_BASEIMAGE ?= alpine:3.19.1
|
ALPINE_BASEIMAGE ?= alpine:3.19.1
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ IMAGE_VERSION=latest
|
|||||||
IMAGE_VERSION=${WEAVE_VERSION:-$IMAGE_VERSION}
|
IMAGE_VERSION=${WEAVE_VERSION:-$IMAGE_VERSION}
|
||||||
|
|
||||||
# Minimum tested version of Docker + Weave Net
|
# Minimum tested version of Docker + Weave Net
|
||||||
MIN_DOCKER_VERSION=1.10.0
|
MIN_DOCKER_VERSION=1.12.0
|
||||||
|
|
||||||
# These are needed for remote execs, hence we introduce them here
|
# These are needed for remote execs, hence we introduce them here
|
||||||
DOCKERHUB_USER=${DOCKERHUB_USER:-weaveworks}
|
DOCKERHUB_USER=${DOCKERHUB_USER:-rajchaudhuri}
|
||||||
BASE_EXEC_IMAGE=$DOCKERHUB_USER/weaveexec
|
BASE_EXEC_IMAGE=$DOCKERHUB_USER/weaveexec
|
||||||
EXEC_IMAGE=$BASE_EXEC_IMAGE:$IMAGE_VERSION
|
EXEC_IMAGE=$BASE_EXEC_IMAGE:$IMAGE_VERSION
|
||||||
WEAVEDB_IMAGE=$DOCKERHUB_USER/weavedb:latest
|
WEAVEDB_IMAGE=$DOCKERHUB_USER/weavedb:latest
|
||||||
@@ -95,8 +95,8 @@ where <peer> = <ip_address_or_fqdn>[:<port>]
|
|||||||
<peer_id> = <nickname> | <weave internal peer ID>
|
<peer_id> = <nickname> | <weave internal peer ID>
|
||||||
<mode> = consensus[=<count>] | seed=<mac>,... | observer
|
<mode> = consensus[=<count>] | seed=<mac>,... | observer
|
||||||
|
|
||||||
To troubleshoot and visualize Weave networks, try Weave Cloud: http://www.weave.works/product/cloud/
|
|
||||||
EOF
|
EOF
|
||||||
|
# To troubleshoot and visualize Weave networks, try Weave : http://www.weave.works/product/cloud/
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@@ -155,6 +155,8 @@ exec_remote() {
|
|||||||
-e COVERAGE \
|
-e COVERAGE \
|
||||||
-e CHECKPOINT_DISABLE \
|
-e CHECKPOINT_DISABLE \
|
||||||
-e AWSVPC \
|
-e AWSVPC \
|
||||||
|
-e DOCKER_API_VERSION \
|
||||||
|
-t \
|
||||||
$WEAVEEXEC_DOCKER_ARGS $EXEC_IMAGE --local "$@"
|
$WEAVEEXEC_DOCKER_ARGS $EXEC_IMAGE --local "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user