mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
The Nomad client expects certain cgroups paths to exist in order to manage tasks. These paths are created when the agent first starts, but if process fails the agent would just log the error and proceed with its initialization, despite not being able to run tasks. This commit surfaces the errors back to the client initialization so the process can stop early and make clear to operators that something went wrong.
30 lines
606 B
Go
30 lines
606 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
//go:build linux
|
|
|
|
package proclib
|
|
|
|
import (
|
|
"github.com/hashicorp/nomad/client/lib/cgroupslib"
|
|
)
|
|
|
|
// New creates a Wranglers factory for creating ProcessWrangler's appropriate
|
|
// for the given system (i.e. cgroups v1 or cgroups v2).
|
|
func New(configs *Configs) (*Wranglers, error) {
|
|
w := &Wranglers{
|
|
configs: configs,
|
|
m: make(map[Task]ProcessWrangler),
|
|
}
|
|
|
|
var err error
|
|
switch cgroupslib.GetMode() {
|
|
case cgroupslib.CG1:
|
|
w.create, err = newCG1(configs)
|
|
default:
|
|
w.create, err = newCG2(configs)
|
|
}
|
|
|
|
return w, err
|
|
}
|