mirror of
https://github.com/kemko/nomad.git
synced 2026-01-02 00:15:43 +03:00
* client/allocdir: use an interface in place of AllocDir structs This PR replace *allocdir.AllocDir with allocdir.Interface such that we may eventually have another implementation of alloc directories. This is in support of the exec2 driver, which will need an implementation of the alloc directory incompatibile with the current version. * use rlock
37 lines
755 B
Go
37 lines
755 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package allocrunner
|
|
|
|
import (
|
|
"github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/nomad/client/allocdir"
|
|
)
|
|
|
|
// allocDirHook creates and destroys the root directory and shared directories
|
|
// for an allocation.
|
|
type allocDirHook struct {
|
|
allocDir allocdir.Interface
|
|
logger hclog.Logger
|
|
}
|
|
|
|
func newAllocDirHook(logger hclog.Logger, allocDir allocdir.Interface) *allocDirHook {
|
|
ad := &allocDirHook{
|
|
allocDir: allocDir,
|
|
}
|
|
ad.logger = logger.Named(ad.Name())
|
|
return ad
|
|
}
|
|
|
|
func (h *allocDirHook) Name() string {
|
|
return "alloc_dir"
|
|
}
|
|
|
|
func (h *allocDirHook) Prerun() error {
|
|
return h.allocDir.Build()
|
|
}
|
|
|
|
func (h *allocDirHook) Destroy() error {
|
|
return h.allocDir.Destroy()
|
|
}
|