client: fix panic on alloc stop in non-Linux environments (#17515)
Provide a no-op implementation of the drivers.DriverNetoworkManager interface to be used by systems that don't support network isolation and prevent panics where a network manager is expected.
This commit is contained in:
parent
70fc0fd701
commit
ec80d051d8
|
@ -14,9 +14,21 @@ import (
|
|||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
)
|
||||
|
||||
// noopNetworkManager implements the drivers.DriverNetoworkManager interface to
|
||||
// provide a no-op manager for systems that don't support network isolation.
|
||||
type noopNetworkManager struct{}
|
||||
|
||||
func (*noopNetworkManager) CreateNetwork(_ string, _ *drivers.NetworkCreateRequest) (*drivers.NetworkIsolationSpec, bool, error) {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
func (*noopNetworkManager) DestroyNetwork(_ string, _ *drivers.NetworkIsolationSpec) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: Support windows shared networking
|
||||
func newNetworkManager(alloc *structs.Allocation, driverManager drivermanager.Manager) (nm drivers.DriverNetworkManager, err error) {
|
||||
return nil, nil
|
||||
return &noopNetworkManager{}, nil
|
||||
}
|
||||
|
||||
func newNetworkConfigurator(log hclog.Logger, alloc *structs.Allocation, config *clientconfig.Config) (NetworkConfigurator, error) {
|
||||
|
|
Loading…
Reference in New Issue