Merge pull request #8417 from dmcgowan/add-proxy-platforms
Add platform config to proxy plugins
This commit is contained in:
commit
ab843a1e2d
@ -167,8 +167,9 @@ type CgroupConfig struct {
|
|||||||
|
|
||||||
// ProxyPlugin provides a proxy plugin configuration
|
// ProxyPlugin provides a proxy plugin configuration
|
||||||
type ProxyPlugin struct {
|
type ProxyPlugin struct {
|
||||||
Type string `toml:"type"`
|
Type string `toml:"type"`
|
||||||
Address string `toml:"address"`
|
Address string `toml:"address"`
|
||||||
|
Platform string `toml:"platform"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode unmarshals a plugin specific configuration by plugin id
|
// Decode unmarshals a plugin specific configuration by plugin id
|
||||||
|
@ -45,6 +45,7 @@ import (
|
|||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/dialer"
|
"github.com/containerd/containerd/pkg/dialer"
|
||||||
"github.com/containerd/containerd/pkg/timeout"
|
"github.com/containerd/containerd/pkg/timeout"
|
||||||
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
srvconfig "github.com/containerd/containerd/services/server/config"
|
srvconfig "github.com/containerd/containerd/services/server/config"
|
||||||
ssproxy "github.com/containerd/containerd/snapshots/proxy"
|
ssproxy "github.com/containerd/containerd/snapshots/proxy"
|
||||||
@ -53,6 +54,7 @@ import (
|
|||||||
"github.com/docker/go-metrics"
|
"github.com/docker/go-metrics"
|
||||||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||||
|
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/backoff"
|
"google.golang.org/grpc/backoff"
|
||||||
@ -396,6 +398,8 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
|
|||||||
f func(*grpc.ClientConn) interface{}
|
f func(*grpc.ClientConn) interface{}
|
||||||
|
|
||||||
address = pp.Address
|
address = pp.Address
|
||||||
|
p v1.Platform
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
switch pp.Type {
|
switch pp.Type {
|
||||||
@ -419,12 +423,21 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
|
|||||||
default:
|
default:
|
||||||
log.G(ctx).WithField("type", pp.Type).Warn("unknown proxy plugin type")
|
log.G(ctx).WithField("type", pp.Type).Warn("unknown proxy plugin type")
|
||||||
}
|
}
|
||||||
|
if pp.Platform != "" {
|
||||||
|
p, err = platforms.Parse(pp.Platform)
|
||||||
|
if err != nil {
|
||||||
|
log.G(ctx).WithError(err).WithField("plugin", name).Warn("skipping proxy platform with bad platform")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p = platforms.DefaultSpec()
|
||||||
|
}
|
||||||
|
|
||||||
plugin.Register(&plugin.Registration{
|
plugin.Register(&plugin.Registration{
|
||||||
Type: t,
|
Type: t,
|
||||||
ID: name,
|
ID: name,
|
||||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||||
ic.Meta.Exports["address"] = address
|
ic.Meta.Exports["address"] = address
|
||||||
|
ic.Meta.Platforms = append(ic.Meta.Platforms, p)
|
||||||
conn, err := clients.getClient(address)
|
conn, err := clients.getClient(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user