Make task stats interval configurable.
This commit is contained in:
parent
67a84542d6
commit
1debb6b35a
@ -61,6 +61,7 @@ var (
|
||||
hclspec.NewLiteral("true"),
|
||||
),
|
||||
"containerd_runtime": hclspec.NewAttr("containerd_runtime", "string", true),
|
||||
"stats_interval": hclspec.NewAttr("stats_interval", "string", false),
|
||||
})
|
||||
|
||||
// taskConfigSpec is the specification of the plugin's configuration for
|
||||
@ -85,6 +86,7 @@ var (
|
||||
type Config struct {
|
||||
Enabled bool `codec:"enabled"`
|
||||
ContainerdRuntime string `codec:"containerd_runtime"`
|
||||
StatsInterval string `codec:"stats_interval"`
|
||||
}
|
||||
|
||||
// TaskConfig contains configuration information for a task that runs with
|
||||
@ -499,6 +501,17 @@ func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Dur
|
||||
return nil, drivers.ErrTaskNotFound
|
||||
}
|
||||
|
||||
if d.config.StatsInterval != "" {
|
||||
statsInterval, err := time.ParseDuration(d.config.StatsInterval)
|
||||
if err != nil {
|
||||
d.logger.Warn("Error parsing driver stats interval, fallback on default interval")
|
||||
} else {
|
||||
msg := fmt.Sprintf("Overriding client stats interval: %v with driver stats interval: %v", interval, d.config.StatsInterval)
|
||||
d.logger.Debug(msg)
|
||||
interval = statsInterval
|
||||
}
|
||||
}
|
||||
|
||||
return handle.stats(ctx, d.ctxContainerd, interval)
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,6 @@ plugin "containerd-driver" {
|
||||
config {
|
||||
enabled = true
|
||||
containerd_runtime = "io.containerd.runc.v2"
|
||||
stats_interval = "5s"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user