Files
nomad/client/lib/proclib/wrangler_default.go
Luiz Aoqui db5ffde2b7 client: prevent start on cgroups init error (#19915)
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.
2024-02-09 13:45:29 -05:00

41 lines
817 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
//go:build !linux
package proclib
// New creates a Wranglers backed by the DefaultWrangler implementation, which
// does not do anything.
func New(configs *Configs) (*Wranglers, error) {
w := &Wranglers{
configs: configs,
m: make(map[Task]ProcessWrangler),
create: doNothing(configs),
}
return w, nil
}
func doNothing(*Configs) create {
return func(Task) ProcessWrangler {
return new(DefaultWrangler)
}
}
// A DefaultWrangler has a no-op implementation. In the task drivers
// we trust for cleaning themselves up.
type DefaultWrangler struct{}
func (w *DefaultWrangler) Initialize() error {
return nil
}
func (w *DefaultWrangler) Kill() error {
return nil
}
func (w *DefaultWrangler) Cleanup() error {
return nil
}