Skip to content

Commit 8916e2c

Browse files
dmcgowanKern Walster
authored andcommitted
Add platform config to proxy plugins
Signed-off-by: Derek McGowan <[email protected]> (cherry picked from commit 4e56939) Signed-off-by: Kern Walster <[email protected]>
1 parent 6b0cae9 commit 8916e2c

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

services/server/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ type CgroupConfig struct {
164164

165165
// ProxyPlugin provides a proxy plugin configuration
166166
type ProxyPlugin struct {
167-
Type string `toml:"type"`
168-
Address string `toml:"address"`
167+
Type string `toml:"type"`
168+
Address string `toml:"address"`
169+
Platform string `toml:"platform"`
169170
}
170171

171172
// Decode unmarshals a plugin specific configuration by plugin id

services/server/server.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/docker/go-metrics"
3939
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
4040
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
41+
v1 "github.com/opencontainers/image-spec/specs-go/v1"
4142
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
4243
"google.golang.org/grpc"
4344
"google.golang.org/grpc/backoff"
@@ -57,6 +58,7 @@ import (
5758
"github.com/containerd/containerd/pkg/deprecation"
5859
"github.com/containerd/containerd/pkg/dialer"
5960
"github.com/containerd/containerd/pkg/timeout"
61+
"github.com/containerd/containerd/platforms"
6062
"github.com/containerd/containerd/plugin"
6163
srvconfig "github.com/containerd/containerd/services/server/config"
6264
"github.com/containerd/containerd/services/warning"
@@ -454,6 +456,8 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
454456
f func(*grpc.ClientConn) interface{}
455457

456458
address = pp.Address
459+
p v1.Platform
460+
err error
457461
)
458462

459463
switch pp.Type {
@@ -477,12 +481,21 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
477481
default:
478482
log.G(ctx).WithField("type", pp.Type).Warn("unknown proxy plugin type")
479483
}
484+
if pp.Platform != "" {
485+
p, err = platforms.Parse(pp.Platform)
486+
if err != nil {
487+
log.G(ctx).WithError(err).WithField("plugin", name).Warn("skipping proxy platform with bad platform")
488+
}
489+
} else {
490+
p = platforms.DefaultSpec()
491+
}
480492

481493
plugin.Register(&plugin.Registration{
482494
Type: t,
483495
ID: name,
484496
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
485497
ic.Meta.Exports["address"] = address
498+
ic.Meta.Platforms = append(ic.Meta.Platforms, p)
486499
conn, err := clients.getClient(address)
487500
if err != nil {
488501
return nil, err

0 commit comments

Comments
 (0)