Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade containerd to v1.7 #785

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ steps:
command:
- make -C runtime integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_runtime

- label: ":running: snapshotter isolated tests"
agents:
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
hostname: "${BUILDKITE_AGENT_META_DATA_HOSTNAME}"
env:
DOCKER_IMAGE_TAG: "$BUILDKITE_BUILD_NUMBER"
NUMBER_OF_VMS: 10
EXTRAGOARGS: "-v -count=1 -race -timeout 3m"
FICD_DM_VOLUME_GROUP: fcci-vg
artifact_paths:
- "snapshotter/logs/*"
command:
- make -C snapshotter integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_snapshotter
timeout_in_minutes: 10
# - label: ":running: snapshotter isolated tests"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we intend to enable these tests in the future? Please cut a issue so that we can track it once this PR is merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. The snapshotter is no longer needed. But i just commented this block in case we'd like to revoke this decision later.

# agents:
# queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
# distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
# hostname: "${BUILDKITE_AGENT_META_DATA_HOSTNAME}"
# env:
# DOCKER_IMAGE_TAG: "$BUILDKITE_BUILD_NUMBER"
# NUMBER_OF_VMS: 10
# EXTRAGOARGS: "-v -count=1 -race -timeout 3m"
# FICD_DM_VOLUME_GROUP: fcci-vg
# artifact_paths:
# - "snapshotter/logs/*"
# command:
# - make -C snapshotter integ-test FICD_DM_POOL=build_${BUILDKITE_BUILD_NUMBER}_snapshotter
# timeout_in_minutes: 10

- label: ":weight_lifter: stress tests"
concurrency_group: stress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04']
go: ['1.17', '1.18', '1.19']
go: ['1.21', '1.22']
# Build all variants regardless of failures
fail-fast: false

Expand Down
6 changes: 2 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ linters:
enable:
- govet
- staticcheck
- unused
# - unused
- gosimple
- structcheck
- varcheck
- ineffassign
- deadcode
- typecheck
- gosec
- unconvert
Expand All @@ -33,3 +30,4 @@ issues:
- G304 # Potential file inclusion via variable
- G306 # WriteFile permissions 0600 or less to be audited
- G307 # Deferring unsafe method "Close" on type "*os.File" to be audited
-
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SUBMODULES=_submodules
UID:=$(shell id -u)
GID:=$(shell id -g)

FIRECRACKER_CONTAINERD_BUILDER_IMAGE?=golang:1.17-bullseye
FIRECRACKER_CONTAINERD_BUILDER_IMAGE?=golang:1.21-bullseye
export FIRECRACKER_CONTAINERD_TEST_IMAGE?=localhost/firecracker-containerd-test
export GO_CACHE_VOLUME_NAME?=gocache

Expand Down Expand Up @@ -136,14 +136,14 @@ tidy:
./tools/tidy.sh

$(BINPATH)/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(BINPATH) v1.48.0
GOBIN=$(BINPATH) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
$(BINPATH)/golangci-lint --version

$(BINPATH)/git-validation:
GOBIN=$(BINPATH) GO111MODULE=off go get -u github.com/vbatts/git-validation
GOBIN=$(BINPATH) go install github.com/vbatts/git-validation@v1.2.0

$(BINPATH)/ltag:
GOBIN=$(BINPATH) GO111MODULE=off go get -u github.com/kunalkushwaha/ltag
GOBIN=$(BINPATH) go install github.com/kunalkushwaha/ltag@v0.2.5

install:
for d in $(SUBDIRS); do $(MAKE) -C $$d install; done
Expand Down Expand Up @@ -273,31 +273,31 @@ $(CNI_BIN_ROOT):

BRIDGE_BIN?=$(BINPATH)/bridge
$(BRIDGE_BIN):
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/main/bridge
GOBIN=$(dir $@) go install github.com/containernetworking/plugins/plugins/main/bridge@v1.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to pin the version here. Can we not use @latest? This will need separate update mechanism otherwise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to pin the plugins to some older versions to pass integ-tests, which still have the CNI configured for older versions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides CNI, there are some other packages such as git-validation etc that have their versions pinned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. For toolchain binaries, it's better to pin to a known good version otherwise upgrade may (surprisingly) break our build.


PTP_BIN?=$(BINPATH)/ptp
$(PTP_BIN):
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/main/ptp
GOBIN=$(dir $@) go install github.com/containernetworking/plugins/plugins/main/ptp@v1.1.0

HOSTLOCAL_BIN?=$(BINPATH)/host-local
$(HOSTLOCAL_BIN):
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/ipam/host-local
GOBIN=$(dir $@) go install github.com/containernetworking/plugins/plugins/ipam/host-local@v1.1.0

FIREWALL_BIN?=$(BINPATH)/firewall
$(FIREWALL_BIN):
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/meta/firewall
GOBIN=$(dir $@) go install github.com/containernetworking/plugins/plugins/meta/firewall@v1.1.0

TC_REDIRECT_TAP_BIN?=$(BINPATH)/tc-redirect-tap
$(TC_REDIRECT_TAP_BIN):
GOBIN=$(dir $@) go install github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap
GOBIN=$(dir $@) go install github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap@v0.0.0-20211025175357-e30dfca224c2

TEST_BRIDGED_TAP_BIN?=$(BINPATH)/test-bridged-tap
$(TEST_BRIDGED_TAP_BIN): $(shell find internal/cmd/test-bridged-tap -name *.go) $(GOMOD) $(GOSUM)
go build -o $@ $(CURDIR)/internal/cmd/test-bridged-tap

LOOPBACK_BIN?=$(BINPATH)/loopback
$(LOOPBACK_BIN):
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/main/loopback
GOBIN=$(dir $@) go install github.com/containernetworking/plugins/plugins/main/loopback@v1.1.0

.PHONY: cni-bins
cni-bins: $(BRIDGE_BIN) $(PTP_BIN) $(HOSTLOCAL_BIN) $(FIREWALL_BIN) $(TC_REDIRECT_TAP_BIN) $(LOOPBACK_BIN)
Expand Down
2 changes: 1 addition & 1 deletion agent/drive_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/protobuf/types"
"github.com/firecracker-microvm/firecracker-containerd/internal"
drivemount "github.com/firecracker-microvm/firecracker-containerd/proto/service/drivemount/ttrpc"
"github.com/gogo/protobuf/types"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions agent/ioproxy_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package main
import (
"context"

task "github.com/containerd/containerd/api/runtime/task/v2"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/runtime/v2/task"
"github.com/containerd/containerd/protobuf/types"
"github.com/firecracker-microvm/firecracker-containerd/internal/vm"
ioproxy "github.com/firecracker-microvm/firecracker-containerd/proto/service/ioproxy/ttrpc"
"github.com/gogo/protobuf/types"
)

// ioProxyHandler implements IOProxyService that exposes the state of
Expand Down
2 changes: 1 addition & 1 deletion agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"os/signal"
"syscall"

taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/namespaces"
taskAPI "github.com/containerd/containerd/runtime/v2/task"
"github.com/containerd/containerd/sys/reaper"
"github.com/containerd/ttrpc"
"github.com/firecracker-microvm/firecracker-go-sdk/vsock"
Expand Down
6 changes: 3 additions & 3 deletions agent/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
"strconv"
"sync"

taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/protobuf/types"
runc "github.com/containerd/containerd/runtime/v2/runc/v2"
"github.com/containerd/containerd/runtime/v2/shim"
taskAPI "github.com/containerd/containerd/runtime/v2/task"
"github.com/gogo/protobuf/types"
"github.com/hashicorp/go-multierror"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -121,7 +121,7 @@ func logPanicAndDie(logger *logrus.Entry) {
func unmarshalExtraData(marshalled *types.Any) (*proto.ExtraData, error) {
// get json bytes from task request
extraData := &proto.ExtraData{}
err := types.UnmarshalAny(marshalled, extraData)
err := marshalled.UnmarshalTo(extraData)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion docker-credential-mmds/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/firecracker-microvm/firecracker-containerd/docker-credential-mmds

go 1.17
go 1.21

require (
github.com/docker/docker-credential-helpers v0.6.4
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You need to have the following things in order to use firecracker-containerd:
* git
* gcc, required by the Firecracker agent for building
* A recent installation of [Docker CE](https://docker.com).
* Go 1.17 or later, which you can download from [here](https://golang.org/dl/).
* Go 1.21 or later, which you can download from [here](https://golang.org/dl/).

## Setup

Expand Down
10 changes: 5 additions & 5 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ files into `/usr/local/bin`.

cd ~

# Install git, Go 1.17, make, curl
# Install git, Go 1.21, make, curl
sudo mkdir -p /etc/apt/sources.list.d
echo "deb http://ftp.debian.org/debian bullseye-backports main" | \
sudo tee /etc/apt/sources.list.d/bullseye-backports.list
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get \
install --yes \
golang-1.17 \
golang-1.21 \
make \
git \
curl \
Expand All @@ -44,8 +44,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get \
bc \
gnupg

# Debian's Go 1.17 package installs "go" command under /usr/lib/go-1.17/bin
export PATH=/usr/lib/go-1.17/bin:$PATH
# Debian's Go 1.21 package installs "go" command under /usr/lib/go-1.21/bin
export PATH=/usr/lib/go-1.21/bin:$PATH

cd ~

Expand Down Expand Up @@ -93,7 +93,7 @@ sudo yum -y install \
# need to source environment variables afterwards for the existing shell session.
curl -LO https://get.golang.org/$(uname)/go_installer && \
chmod +x go_installer && \
./go_installer -version 1.17 && \
./go_installer -version 1.21 && \
rm go_installer && \
source .bash_profile

Expand Down
2 changes: 1 addition & 1 deletion docs/remote-snapshotter-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You will need the following to use firecracker-containerd with support for remot

* git

* Go 1.17 or later
* Go 1.21 or later

* This repository cloned onto your local machine

Expand Down
11 changes: 6 additions & 5 deletions eventbridge/eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import (
// We need the typeurl register calls that occur in the init of this package in order to be able to unmarshal events
// in the Republish func below
_ "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/protobuf"

// Even though we are following the v2 runtime model, we are currently re-using a struct definition (Envelope) from
// the v1 event API
eventapi "github.com/containerd/containerd/api/services/events/v1"

"github.com/containerd/containerd/events"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/ttrpc"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"
"github.com/containerd/typeurl/v2"
)

const (
Expand Down Expand Up @@ -67,10 +68,10 @@ func (s *getterService) GetEvent(ctx context.Context) (*eventapi.Envelope, error
select {
case receivedEnvelope := <-s.eventChan:
return &eventapi.Envelope{
Timestamp: receivedEnvelope.Timestamp,
Timestamp: protobuf.ToTimestamp(receivedEnvelope.Timestamp),
Namespace: receivedEnvelope.Namespace,
Topic: receivedEnvelope.Topic,
Event: receivedEnvelope.Event,
Event: protobuf.FromAny(receivedEnvelope.Event),
}, nil
case err := <-s.errChan:
// containerd's eventExchange will return a nil error if context is canceled, so if context is canceled and
Expand Down Expand Up @@ -141,7 +142,7 @@ func Attach(ctx context.Context, source Getter, sink events.Forwarder) <-chan er
}

err = sink.Forward(ctx, &events.Envelope{
Timestamp: envelope.Timestamp,
Timestamp: protobuf.FromTimestamp(envelope.Timestamp),
Namespace: envelope.Namespace,
Topic: envelope.Topic,
Event: envelope.Event,
Expand Down
7 changes: 4 additions & 3 deletions eventbridge/eventbridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
eventtypes "github.com/containerd/containerd/events"
"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/typeurl"
"github.com/containerd/containerd/protobuf"
"github.com/containerd/typeurl/v2"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -84,7 +85,7 @@ func verifyPublishAndReceive(ctx context.Context, t *testing.T, source eventtype
ID: fmt.Sprintf("id-%d", i),
Pid: uint32(i),
ExitStatus: uint32(i + 1),
ExitedAt: time.Now().UTC(),
ExitedAt: protobuf.ToTimestamp(time.Now().UTC()),
}

err := source.Publish(ctx, topic, taskExitEvent)
Expand All @@ -108,7 +109,7 @@ func verifyPublishAndReceive(ctx context.Context, t *testing.T, source eventtype
require.Equal(t, taskExitEvent.ID, receivedTaskExitEvent.ID, "received expected ID")
require.Equal(t, taskExitEvent.Pid, receivedTaskExitEvent.Pid, "received expected Pid")
require.Equal(t, taskExitEvent.ExitStatus, receivedTaskExitEvent.ExitStatus, "received expected ExitStatus")
require.Equal(t, taskExitEvent.ExitedAt, receivedTaskExitEvent.ExitedAt, "received expected ExitedAt")
require.Equal(t, taskExitEvent.ExitedAt.AsTime(), receivedTaskExitEvent.ExitedAt.AsTime(), "received expected ExitedAt")
default:
require.Fail(t, "unexpected event", "received unexpected event type on topic %s", envelope.Topic)
}
Expand Down
Loading
Loading