Skip to content

Commit

Permalink
Fix compilation errors after dependencies update
Browse files Browse the repository at this point in the history
Some of the updated dependencies introduced breaking changes. This
commit deals with the compilation errors that thus arose in our code.

Signed-off-by: Leandro Motta Barros <leandro@balena.io>
Change-type: patch
  • Loading branch information
lmbarros committed Nov 3, 2022
1 parent 091976f commit c1247bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
27 changes: 17 additions & 10 deletions daemon/exec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/container"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/daemon/exec"
"github.com/opencontainers/runc/libcontainer/apparmor"
specs "github.com/opencontainers/runtime-spec/specs-go"
Expand All @@ -18,8 +19,11 @@ func TestExecSetPlatformOpt(t *testing.T) {
if !apparmor.IsEnabled() {
t.Skip("requires AppArmor to be enabled")
}
d := &Daemon{}
c := &container.Container{AppArmorProfile: "my-custom-profile"}
d := &Daemon{configStore: &config.Config{}}
c := &container.Container{
AppArmorProfile: "my-custom-profile",
HostConfig: &containertypes.HostConfig{Privileged: false},
}
ec := &exec.Config{}
p := &specs.Process{}

Expand All @@ -34,21 +38,24 @@ func TestExecSetPlatformOpt(t *testing.T) {
//
// This behavior may change in future, but test for the behavior to prevent it
// from being changed accidentally.
//
// balenaEngine: this test was failing after we upgraded several components
// while updating containerd to 1.6.6. We changed it so it resembles the
// following test case in the more recent Moby codebase:
// https://github.com/moby/moby/blob/572ca799db4b67b7be35904e487f0cc51c3f9f06/daemon/exec_linux_test.go#L37-L39
func TestExecSetPlatformOptPrivileged(t *testing.T) {
if !apparmor.IsEnabled() {
t.Skip("requires AppArmor to be enabled")
}
d := &Daemon{}
c := &container.Container{AppArmorProfile: "my-custom-profile"}
ec := &exec.Config{Privileged: true}
d := &Daemon{configStore: &config.Config{}}
c := &container.Container{
AppArmorProfile: "",
HostConfig: &containertypes.HostConfig{Privileged: true},
}
ec := &exec.Config{Privileged: false}
p := &specs.Process{}

err := d.execSetPlatformOpt(c, ec, p)
assert.NilError(t, err)
assert.Equal(t, "my-custom-profile", p.ApparmorProfile)

c.HostConfig = &containertypes.HostConfig{Privileged: true}
err = d.execSetPlatformOpt(c, ec, p)
assert.NilError(t, err)
assert.Equal(t, unconfinedAppArmorProfile, p.ApparmorProfile)
}
5 changes: 2 additions & 3 deletions oci/devices_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"path/filepath"
"strings"

"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
specs "github.com/opencontainers/runtime-spec/specs-go"
)

// Device transforms a libcontainer configs.Device to a specs.LinuxDevice object.
func Device(d *configs.Device) specs.LinuxDevice {
func Device(d *devices.Device) specs.LinuxDevice {
return specs.LinuxDevice{
Type: string(d.Type),
Path: d.Path,
Expand All @@ -24,7 +23,7 @@ func Device(d *configs.Device) specs.LinuxDevice {
}
}

func deviceCgroup(d *configs.Device) specs.LinuxDeviceCgroup {
func deviceCgroup(d *devices.Device) specs.LinuxDeviceCgroup {
return specs.LinuxDeviceCgroup{
Allow: true,
Type: string(d.Type),
Expand Down
4 changes: 2 additions & 2 deletions plugin/backend_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header

// Make sure we can authenticate the request since the auth scope for plugin repos is different than a normal repo.
ctx = docker.WithScope(ctx, scope(ref, true))
if err := remotes.PushContent(ctx, pusher, desc, pm.blobStore, nil, func(h images.Handler) images.Handler {
if err := remotes.PushContent(ctx, pusher, desc, pm.blobStore, nil, nil, func(h images.Handler) images.Handler {
return images.Handlers(progressHandler, h)
}); err != nil {
// Try fallback to http.
Expand All @@ -433,7 +433,7 @@ func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header
pusher, _ := resolver.Pusher(ctx, ref.String())
if pusher != nil {
logrus.WithField("ref", ref).Debug("Re-attmpting push with http-fallback")
err2 := remotes.PushContent(ctx, pusher, desc, pm.blobStore, nil, func(h images.Handler) images.Handler {
err2 := remotes.PushContent(ctx, pusher, desc, pm.blobStore, nil, nil, func(h images.Handler) images.Handler {
return images.Handlers(progressHandler, h)
})
if err2 == nil {
Expand Down

0 comments on commit c1247bd

Please sign in to comment.