From c5f8822caf2e6c8ac687ffa5e2d84c38cfa4fa7d Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Fri, 12 Jun 2020 07:33:46 +0300 Subject: [PATCH] Use containerd from Docker packages when possible --- nodeup/pkg/model/containerd.go | 25 +++++++++++++------ nodeup/pkg/model/convenience.go | 2 ++ nodeup/pkg/model/docker.go | 16 +++++++++--- .../tests/containerdbuilder/simple/tasks.yaml | 8 +++--- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/nodeup/pkg/model/containerd.go b/nodeup/pkg/model/containerd.go index 8d84ac40c2f16..9ac4df3580b96 100644 --- a/nodeup/pkg/model/containerd.go +++ b/nodeup/pkg/model/containerd.go @@ -56,8 +56,12 @@ var containerdVersions = []packageVersion{ PackageVersion: "1.2.10", PlainBinary: true, Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, - Source: "https://storage.googleapis.com/cri-containerd-release/cri-containerd-1.2.10.linux-amd64.tar.gz", - Hash: "9125a6ae5a89dfe9403fea7d03a8d8ba9fa97b6863ee8698c4e6c258fb14f1fd", + Source: "https://download.docker.com/linux/static/stable/x86_64/docker-19.03.4.tgz", + Hash: "efef2ad32d262674501e712351be0df9dd31d6034b175d0020c8f5d5c9c3fd10", + MapFiles: map[string]string{ + "docker/c*": "/usr/bin", + "docker/runc": "/usr/bin", + }, }, // 1.2.13 - Linux Generic @@ -65,8 +69,12 @@ var containerdVersions = []packageVersion{ PackageVersion: "1.2.13", PlainBinary: true, Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, - Source: "https://storage.googleapis.com/cri-containerd-release/cri-containerd-1.2.13.linux-amd64.tar.gz", - Hash: "92d6ae6c60f6b068652b31811ce23d650ec0f6cc1e618ec9ae23db9321956258", + Source: "https://download.docker.com/linux/static/stable/x86_64/docker-19.03.11.tgz", + Hash: "0f4336378f61ed73ed55a356ac19e46699a995f2aff34323ba5874d131548b9e", + MapFiles: map[string]string{ + "docker/c*": "/usr/bin", + "docker/runc": "/usr/bin", + }, }, // 1.3.4 - Linux Generic @@ -76,6 +84,10 @@ var containerdVersions = []packageVersion{ Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, Source: "https://storage.googleapis.com/cri-containerd-release/cri-containerd-1.3.4.linux-amd64.tar.gz", Hash: "4616971c3ad21c24f2f2320fa1c085577a91032a068dd56a41c7c4b71a458087", + MapFiles: map[string]string{ + "./usr/local/bin": "/usr", + "./usr/local/sbin": "/usr", + }, }, // TIP: When adding the next version, copy the previous version, string replace the version and run: @@ -165,11 +177,8 @@ func (b *ContainerdBuilder) Build(c *fi.ModelBuilderContext) error { Name: "containerd.io", Source: dv.Source, Hash: dv.Hash, + MapFiles: dv.MapFiles, TargetDir: "/", - MapFiles: map[string]string{ - "./usr/local/bin": "/usr", - "./usr/local/sbin": "/usr", - }, } c.AddTask(packageTask) } else { diff --git a/nodeup/pkg/model/convenience.go b/nodeup/pkg/model/convenience.go index 0e952f0899de1..ef2c7d888b9ea 100644 --- a/nodeup/pkg/model/convenience.go +++ b/nodeup/pkg/model/convenience.go @@ -148,6 +148,8 @@ type packageVersion struct { // PlainBinary indicates that the Source is not an OS, but a "bare" tar.gz PlainBinary bool + // MapFiles is the list of files to extract with corresponding directories for PlainBinary + MapFiles map[string]string // MarkImmutable is a list of files on which we should perform a `chattr +i ` MarkImmutable []string diff --git a/nodeup/pkg/model/docker.go b/nodeup/pkg/model/docker.go index 758d86d7820d8..ae290feef7f0e 100644 --- a/nodeup/pkg/model/docker.go +++ b/nodeup/pkg/model/docker.go @@ -305,6 +305,9 @@ var dockerVersions = []packageVersion{ Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, Source: "https://download.docker.com/linux/static/stable/x86_64/docker-18.09.9.tgz", Hash: "82a362af7689038c51573e0fd0554da8703f0d06f4dfe95dd5bda5acf0ae45fb", + MapFiles: map[string]string{ + "docker/docker*": "/usr/bin", + }, }, // 19.03.4 - Linux Generic @@ -314,6 +317,9 @@ var dockerVersions = []packageVersion{ Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, Source: "https://download.docker.com/linux/static/stable/x86_64/docker-19.03.4.tgz", Hash: "efef2ad32d262674501e712351be0df9dd31d6034b175d0020c8f5d5c9c3fd10", + MapFiles: map[string]string{ + "docker/docker*": "/usr/bin", + }, }, // 19.03.8 - Linux Generic @@ -323,6 +329,9 @@ var dockerVersions = []packageVersion{ Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, Source: "https://download.docker.com/linux/static/stable/x86_64/docker-19.03.8.tgz", Hash: "7f4115dc6a3c19c917f8b9664d7b51c904def1c984e082c4600097433323cf6f", + MapFiles: map[string]string{ + "docker/docker*": "/usr/bin", + }, }, // 19.03.11 - Linux Generic @@ -332,6 +341,9 @@ var dockerVersions = []packageVersion{ Architectures: []architectures.Architecture{architectures.ArchitectureAmd64}, Source: "https://download.docker.com/linux/static/stable/x86_64/docker-19.03.11.tgz", Hash: "0f4336378f61ed73ed55a356ac19e46699a995f2aff34323ba5874d131548b9e", + MapFiles: map[string]string{ + "docker/docker*": "/usr/bin", + }, }, // TIP: When adding the next version, copy the previous version, string replace the version and run: @@ -406,10 +418,8 @@ func (b *DockerBuilder) Build(c *fi.ModelBuilderContext) error { Name: "docker-ce", Source: dv.Source, Hash: dv.Hash, + MapFiles: dv.MapFiles, TargetDir: "/", - MapFiles: map[string]string{ - "docker/docker*": "/usr/bin", - }, } c.AddTask(packageTask) diff --git a/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml b/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml index d8ed50798a8a5..f88357a3671bb 100644 --- a/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml +++ b/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml @@ -1,9 +1,9 @@ Name: containerd.io -hash: 9125a6ae5a89dfe9403fea7d03a8d8ba9fa97b6863ee8698c4e6c258fb14f1fd +hash: efef2ad32d262674501e712351be0df9dd31d6034b175d0020c8f5d5c9c3fd10 mapFiles: - ./usr/local/bin: /usr - ./usr/local/sbin: /usr -source: https://storage.googleapis.com/cri-containerd-release/cri-containerd-1.2.10.linux-amd64.tar.gz + docker/c*: /usr/bin + docker/runc: /usr/bin +source: https://download.docker.com/linux/static/stable/x86_64/docker-19.03.4.tgz target: / --- contents: |-