Files
nomad/client/config/config_ce.go
Tim Gross 50f0ce5412 config: remove old Vault/Consul config blocks from client (#18994)
Remove the now-unused original configuration blocks for Consul and Vault from
the client. When the client needs to refer to a Consul or Vault block it will
always be for a specific cluster for the task/service. Add a helper for
accessing the default clusters (for the client's own use).

This is two of three changesets for this work. The remainder will implement the
same changes in the `command/agent` package.

As part of this work I discovered and fixed two bugs:

* The gRPC proxy socket that we create for Envoy is only ever created using the
  default Consul cluster's configuration. This will prevent Connect from being
  used with the non-default cluster.
* The Consul configuration we use for templates always comes from the default
  Consul cluster's configuration, but will use the correct Consul token for the
  non-default cluster. This will prevent templates from being used with the
  non-default cluster.

Ref: https://github.com/hashicorp/nomad/issues/18947
Ref: https://github.com/hashicorp/nomad/pull/18991
Fixes: https://github.com/hashicorp/nomad/issues/18984
Fixes: https://github.com/hashicorp/nomad/issues/18983
2023-11-07 09:15:37 -05:00

39 lines
1.1 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
//go:build !ent
package config
import (
"github.com/hashicorp/go-hclog"
structsc "github.com/hashicorp/nomad/nomad/structs/config"
)
// GetVaultConfigs returns the set of Vault configurations available for this
// client. In Nomad CE we only use the default Vault.
func (c *Config) GetVaultConfigs(logger hclog.Logger) map[string]*structsc.VaultConfig {
if c.VaultConfigs["default"] == nil || !c.VaultConfigs["default"].IsEnabled() {
return nil
}
if len(c.VaultConfigs) > 1 {
logger.Warn("multiple Vault configurations are only supported in Nomad Enterprise")
}
return c.VaultConfigs
}
// GetConsulConfigs returns the set of Consul configurations the fingerprint needs
// to check. In Nomad CE we only check the default Consul.
func (c *Config) GetConsulConfigs(logger hclog.Logger) map[string]*structsc.ConsulConfig {
if c.ConsulConfigs["default"] == nil {
return nil
}
if len(c.ConsulConfigs) > 1 {
logger.Warn("multiple Consul configurations are only supported in Nomad Enterprise")
}
return c.ConsulConfigs
}