Files
nomad/client/allocrunner/allocdir_hook.go
Seth Hoenig 5b7f4746ce client/allocdir: use an interface in place of AllocDir structs (#19703)
* 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
2024-01-12 14:13:29 -06:00

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()
}