Skip to content

Commit 9468414

Browse files
committed
Revert "Make containerd socket path configurable"
This reverts commit 892038f.
1 parent aafdaf9 commit 9468414

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ To interact with `images` and `containers` directly, you can use [`nerdctl`](htt
9494

9595
**Driver Config**
9696

97-
| Option | Type | Required | Default | Description |
98-
|:----------------------:|:------:|:--------:|:---------------------------------:|:------------------------------------------------------------------------------------------------------------------------|
99-
| **enabled** | bool | no | true | Enable/Disable task driver. |
100-
| **containerd_address** | string | no | `/run/containerd/containerd.sock` | Path to containerd socket. |
101-
| **containerd_runtime** | string | yes | N/A | Runtime for containerd e.g. `io.containerd.runc.v1` or `io.containerd.runc.v2`. |
102-
| **stats_interval** | string | no | 1s | Interval for collecting `TaskStats`. |
103-
| **allow_privileged** | bool | no | true | If set to `false`, driver will deny running privileged jobs. |
104-
| **auth** | block | no | N/A | Provide authentication for a private registry. See [Authentication](#authentication-private-registry) for more details. |
97+
| Option | Type | Required | Default | Description |
98+
| :---: | :---: | :---: | :---: | :--- |
99+
| **enabled** | bool | no | true | Enable/Disable task driver. |
100+
| **containerd_runtime** | string | yes | N/A | Runtime for containerd e.g. `io.containerd.runc.v1` or `io.containerd.runc.v2`. |
101+
| **stats_interval** | string | no | 1s | Interval for collecting `TaskStats`. |
102+
| **allow_privileged** | bool | no | true | If set to `false`, driver will deny running privileged jobs. |
103+
| **auth** | block | no | N/A | Provide authentication for a private registry. See [Authentication](#authentication-private-registry) for more details. |
105104

106105
**Task Config**
107106

containerd/driver.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"time"
2525

2626
"github.com/containerd/containerd"
27-
"github.com/containerd/containerd/defaults"
2827
"github.com/containerd/containerd/namespaces"
2928
"github.com/hashicorp/consul-template/signals"
3029
"github.com/hashicorp/go-hclog"
@@ -79,10 +78,6 @@ var (
7978
hclspec.NewAttr("enabled", "bool", false),
8079
hclspec.NewLiteral("true"),
8180
),
82-
"containerd_address": hclspec.NewDefault(
83-
hclspec.NewAttr("containerd_address", "string", false),
84-
hclspec.NewLiteral(defaults.DefaultAddress),
85-
),
8681
"containerd_runtime": hclspec.NewAttr("containerd_runtime", "string", true),
8782
"stats_interval": hclspec.NewAttr("stats_interval", "string", false),
8883
"allow_privileged": hclspec.NewDefault(
@@ -159,7 +154,6 @@ var (
159154
// Config contains configuration information for the plugin
160155
type Config struct {
161156
Enabled bool `codec:"enabled"`
162-
ContainerdAddress string `codec:"containerd_address"`
163157
ContainerdRuntime string `codec:"containerd_runtime"`
164158
StatsInterval string `codec:"stats_interval"`
165159
AllowPrivileged bool `codec:"allow_privileged"`
@@ -262,6 +256,15 @@ type Driver struct {
262256
func NewPlugin(logger log.Logger) drivers.DriverPlugin {
263257
ctx, cancel := context.WithCancel(context.Background())
264258
logger = logger.Named(PluginName)
259+
260+
// This will create a new containerd client which will talk to
261+
// default containerd socket path.
262+
client, err := containerd.New("/run/containerd/containerd.sock")
263+
if err != nil {
264+
logger.Error("Error in creating containerd client", "err", err)
265+
return nil
266+
}
267+
265268
namespace := getNamespaceName()
266269
ctxContainerd := namespaces.WithNamespace(context.Background(), namespace)
267270

@@ -271,6 +274,7 @@ func NewPlugin(logger log.Logger) drivers.DriverPlugin {
271274
tasks: newTaskStore(),
272275
ctx: ctx,
273276
ctxContainerd: ctxContainerd,
277+
client: client,
274278
signalShutdown: cancel,
275279
logger: logger,
276280
}
@@ -320,21 +324,12 @@ func (d *Driver) ConfigSchema() (*hclspec.Spec, error) {
320324
// SetConfig is called by the client to pass the configuration for the plugin.
321325
func (d *Driver) SetConfig(cfg *base.Config) error {
322326
var config Config
323-
var err error
324327
if len(cfg.PluginConfig) != 0 {
325-
if err = base.MsgPackDecode(cfg.PluginConfig, &config); err != nil {
328+
if err := base.MsgPackDecode(cfg.PluginConfig, &config); err != nil {
326329
return err
327330
}
328331
}
329332

330-
// This will create a new containerd client which will talk to
331-
// default containerd socket path.
332-
d.client, err = containerd.New(config.ContainerdAddress)
333-
if err != nil {
334-
d.logger.Error("Error in creating containerd client", "err", err)
335-
return err
336-
}
337-
338333
// Save the configuration to the plugin
339334
d.config = &config
340335

0 commit comments

Comments
 (0)