remove atlas
This commit is contained in:
parent
2506f4081f
commit
701f462d33
|
@ -21,7 +21,6 @@ var (
|
|||
DefaultEnvBlacklist = strings.Join([]string{
|
||||
"CONSUL_TOKEN",
|
||||
"VAULT_TOKEN",
|
||||
"ATLAS_TOKEN",
|
||||
"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN",
|
||||
"GOOGLE_APPLICATION_CREDENTIALS",
|
||||
}, ",")
|
||||
|
|
|
@ -27,7 +27,6 @@ import (
|
|||
"github.com/hashicorp/nomad/helper/gated-writer"
|
||||
"github.com/hashicorp/nomad/nomad/structs/config"
|
||||
"github.com/hashicorp/nomad/version"
|
||||
"github.com/hashicorp/scada-client/scada"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
@ -50,9 +49,6 @@ type Command struct {
|
|||
logFilter *logutils.LevelFilter
|
||||
logOutput io.Writer
|
||||
retryJoinErrCh chan struct{}
|
||||
|
||||
scadaProvider *scada.Provider
|
||||
scadaHttp *HTTPServer
|
||||
}
|
||||
|
||||
func (c *Command) readConfig() *Config {
|
||||
|
@ -63,7 +59,6 @@ func (c *Command) readConfig() *Config {
|
|||
|
||||
// Make a new, empty config.
|
||||
cmdConfig := &Config{
|
||||
Atlas: &AtlasConfig{},
|
||||
Client: &ClientConfig{},
|
||||
Consul: &config.ConsulConfig{},
|
||||
Ports: &Ports{},
|
||||
|
@ -107,11 +102,6 @@ func (c *Command) readConfig() *Config {
|
|||
flags.StringVar(&cmdConfig.LogLevel, "log-level", "", "")
|
||||
flags.StringVar(&cmdConfig.NodeName, "node", "", "")
|
||||
|
||||
// Atlas options
|
||||
flags.StringVar(&cmdConfig.Atlas.Infrastructure, "atlas", "", "")
|
||||
flags.BoolVar(&cmdConfig.Atlas.Join, "atlas-join", false, "")
|
||||
flags.StringVar(&cmdConfig.Atlas.Token, "atlas-token", "", "")
|
||||
|
||||
// Consul options
|
||||
flags.StringVar(&cmdConfig.Consul.Auth, "consul-auth", "", "")
|
||||
flags.Var((flaghelper.FuncBoolVar)(func(b bool) error {
|
||||
|
@ -224,9 +214,6 @@ func (c *Command) readConfig() *Config {
|
|||
}
|
||||
|
||||
// Ensure the sub-structs at least exist
|
||||
if config.Atlas == nil {
|
||||
config.Atlas = &AtlasConfig{}
|
||||
}
|
||||
if config.Client == nil {
|
||||
config.Client = &ClientConfig{}
|
||||
}
|
||||
|
@ -380,13 +367,6 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, inmem *metrics
|
|||
}
|
||||
c.agent = agent
|
||||
|
||||
// Enable the SCADA integration
|
||||
if err := c.setupSCADA(config); err != nil {
|
||||
agent.Shutdown()
|
||||
c.Ui.Error(fmt.Sprintf("Error starting SCADA: %s", err))
|
||||
return err
|
||||
}
|
||||
|
||||
// Setup the HTTP server
|
||||
http, err := NewHTTPServer(agent, config)
|
||||
if err != nil {
|
||||
|
@ -497,17 +477,11 @@ func (c *Command) Run(args []string) int {
|
|||
}
|
||||
defer c.agent.Shutdown()
|
||||
|
||||
// Check and shut down the SCADA listeners at the end
|
||||
// Shudown the HTTP server at the end
|
||||
defer func() {
|
||||
if c.httpServer != nil {
|
||||
c.httpServer.Shutdown()
|
||||
}
|
||||
if c.scadaHttp != nil {
|
||||
c.scadaHttp.Shutdown()
|
||||
}
|
||||
if c.scadaProvider != nil {
|
||||
c.scadaProvider.Shutdown()
|
||||
}
|
||||
}()
|
||||
|
||||
// Join startup nodes if specified
|
||||
|
@ -767,52 +741,6 @@ func (c *Command) setupTelemetry(config *Config) (*metrics.InmemSink, error) {
|
|||
return inm, nil
|
||||
}
|
||||
|
||||
// setupSCADA is used to start a new SCADA provider and listener,
|
||||
// replacing any existing listeners.
|
||||
func (c *Command) setupSCADA(config *Config) error {
|
||||
// Shut down existing SCADA listeners
|
||||
if c.scadaProvider != nil {
|
||||
c.scadaProvider.Shutdown()
|
||||
}
|
||||
if c.scadaHttp != nil {
|
||||
c.scadaHttp.Shutdown()
|
||||
}
|
||||
|
||||
// No-op if we don't have an infrastructure
|
||||
if config.Atlas == nil || config.Atlas.Infrastructure == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create the new provider and listener
|
||||
c.Ui.Output("Connecting to Atlas: " + config.Atlas.Infrastructure)
|
||||
|
||||
scadaConfig := &scada.Config{
|
||||
Service: "nomad",
|
||||
Version: config.Version.VersionNumber(),
|
||||
ResourceType: "nomad-cluster",
|
||||
Meta: map[string]string{
|
||||
"auto-join": strconv.FormatBool(config.Atlas.Join),
|
||||
"region": config.Region,
|
||||
"datacenter": config.Datacenter,
|
||||
"client": strconv.FormatBool(config.Client != nil && config.Client.Enabled),
|
||||
"server": strconv.FormatBool(config.Server != nil && config.Server.Enabled),
|
||||
},
|
||||
Atlas: scada.AtlasConfig{
|
||||
Endpoint: config.Atlas.Endpoint,
|
||||
Infrastructure: config.Atlas.Infrastructure,
|
||||
Token: config.Atlas.Token,
|
||||
},
|
||||
}
|
||||
|
||||
provider, list, err := scada.NewHTTPProvider(scadaConfig, c.logOutput)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.scadaProvider = provider
|
||||
c.scadaHttp = newScadaHttp(c.agent, list)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Command) startupJoin(config *Config) error {
|
||||
if len(config.Server.StartJoin) == 0 || !config.Server.Enabled {
|
||||
return nil
|
||||
|
@ -1100,22 +1028,6 @@ Vault Options:
|
|||
|
||||
-vault-tls-server-name=<token>
|
||||
Used to set the SNI host when connecting over TLS.
|
||||
|
||||
Atlas Options:
|
||||
|
||||
-atlas=<infrastructure>
|
||||
The Atlas infrastructure name to configure. This enables the SCADA
|
||||
client and attempts to connect Nomad to the HashiCorp Atlas service
|
||||
using the provided infrastructure name and token.
|
||||
|
||||
-atlas-token=<token>
|
||||
The Atlas token to use when connecting to the HashiCorp Atlas
|
||||
service. This must be provided to successfully connect your Nomad
|
||||
agent to Atlas.
|
||||
|
||||
-atlas-join
|
||||
Enable the Atlas join feature. This mode allows agents to discover
|
||||
eachother automatically using the SCADA integration features.
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
|
|
@ -106,12 +106,6 @@ enable_syslog = true
|
|||
syslog_facility = "LOCAL1"
|
||||
disable_update_check = true
|
||||
disable_anonymous_signature = true
|
||||
atlas {
|
||||
infrastructure = "armon/test"
|
||||
token = "abcd"
|
||||
join = true
|
||||
endpoint = "127.0.0.1:1234"
|
||||
}
|
||||
http_api_response_headers {
|
||||
Access-Control-Allow-Origin = "*"
|
||||
}
|
||||
|
|
|
@ -94,9 +94,6 @@ type Config struct {
|
|||
// for security bulletins
|
||||
DisableAnonymousSignature bool `mapstructure:"disable_anonymous_signature"`
|
||||
|
||||
// AtlasConfig is used to configure Atlas
|
||||
Atlas *AtlasConfig `mapstructure:"atlas"`
|
||||
|
||||
// Consul contains the configuration for the Consul Agent and
|
||||
// parameters necessary to register services, their checks, and
|
||||
// discover the current Nomad servers.
|
||||
|
@ -135,24 +132,6 @@ type Config struct {
|
|||
Sentinel *config.SentinelConfig `mapstructure:"sentinel"`
|
||||
}
|
||||
|
||||
// AtlasConfig is used to enable an parameterize the Atlas integration
|
||||
type AtlasConfig struct {
|
||||
// Infrastructure is the name of the infrastructure
|
||||
// we belong to. e.g. hashicorp/stage
|
||||
Infrastructure string `mapstructure:"infrastructure"`
|
||||
|
||||
// Token is our authentication token from Atlas
|
||||
Token string `mapstructure:"token" json:"-"`
|
||||
|
||||
// Join controls if Atlas will attempt to auto-join the node
|
||||
// to it's cluster. Requires Atlas integration.
|
||||
Join bool `mapstructure:"join"`
|
||||
|
||||
// Endpoint is the SCADA endpoint used for Atlas integration. If
|
||||
// empty, the defaults from the provider are used.
|
||||
Endpoint string `mapstructure:"endpoint"`
|
||||
}
|
||||
|
||||
// ClientConfig is configuration specific to the client mode
|
||||
type ClientConfig struct {
|
||||
// Enabled controls if we are a client
|
||||
|
@ -584,7 +563,6 @@ func DefaultConfig() *Config {
|
|||
},
|
||||
Addresses: &Addresses{},
|
||||
AdvertiseAddrs: &AdvertiseAddrs{},
|
||||
Atlas: &AtlasConfig{},
|
||||
Consul: config.DefaultConsulConfig(),
|
||||
Vault: config.DefaultVaultConfig(),
|
||||
Client: &ClientConfig{
|
||||
|
@ -756,14 +734,6 @@ func (c *Config) Merge(b *Config) *Config {
|
|||
result.AdvertiseAddrs = result.AdvertiseAddrs.Merge(b.AdvertiseAddrs)
|
||||
}
|
||||
|
||||
// Apply the Atlas configuration
|
||||
if result.Atlas == nil && b.Atlas != nil {
|
||||
atlasConfig := *b.Atlas
|
||||
result.Atlas = &atlasConfig
|
||||
} else if b.Atlas != nil {
|
||||
result.Atlas = result.Atlas.Merge(b.Atlas)
|
||||
}
|
||||
|
||||
// Apply the Consul Configuration
|
||||
if result.Consul == nil && b.Consul != nil {
|
||||
result.Consul = b.Consul.Copy()
|
||||
|
@ -1282,25 +1252,6 @@ func (a *AdvertiseAddrs) Merge(b *AdvertiseAddrs) *AdvertiseAddrs {
|
|||
return &result
|
||||
}
|
||||
|
||||
// Merge merges two Atlas configurations together.
|
||||
func (a *AtlasConfig) Merge(b *AtlasConfig) *AtlasConfig {
|
||||
result := *a
|
||||
|
||||
if b.Infrastructure != "" {
|
||||
result.Infrastructure = b.Infrastructure
|
||||
}
|
||||
if b.Token != "" {
|
||||
result.Token = b.Token
|
||||
}
|
||||
if b.Join {
|
||||
result.Join = true
|
||||
}
|
||||
if b.Endpoint != "" {
|
||||
result.Endpoint = b.Endpoint
|
||||
}
|
||||
return &result
|
||||
}
|
||||
|
||||
func (r *Resources) Merge(b *Resources) *Resources {
|
||||
result := *r
|
||||
if b.CPU != 0 {
|
||||
|
|
|
@ -92,7 +92,6 @@ func parseConfig(result *Config, list *ast.ObjectList) error {
|
|||
"syslog_facility",
|
||||
"disable_update_check",
|
||||
"disable_anonymous_signature",
|
||||
"atlas",
|
||||
"consul",
|
||||
"vault",
|
||||
"tls",
|
||||
|
@ -116,7 +115,6 @@ func parseConfig(result *Config, list *ast.ObjectList) error {
|
|||
delete(m, "client")
|
||||
delete(m, "server")
|
||||
delete(m, "telemetry")
|
||||
delete(m, "atlas")
|
||||
delete(m, "consul")
|
||||
delete(m, "vault")
|
||||
delete(m, "tls")
|
||||
|
@ -178,13 +176,6 @@ func parseConfig(result *Config, list *ast.ObjectList) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Parse atlas config
|
||||
if o := list.Filter("atlas"); len(o.Items) > 0 {
|
||||
if err := parseAtlas(&result.Atlas, o); err != nil {
|
||||
return multierror.Prefix(err, "atlas ->")
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the consul config
|
||||
if o := list.Filter("consul"); len(o.Items) > 0 {
|
||||
if err := parseConsulConfig(&result.Consul, o); err != nil {
|
||||
|
@ -671,39 +662,6 @@ func parseTelemetry(result **Telemetry, list *ast.ObjectList) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func parseAtlas(result **AtlasConfig, list *ast.ObjectList) error {
|
||||
list = list.Elem()
|
||||
if len(list.Items) > 1 {
|
||||
return fmt.Errorf("only one 'atlas' block allowed")
|
||||
}
|
||||
|
||||
// Get our atlas object
|
||||
listVal := list.Items[0].Val
|
||||
|
||||
// Check for invalid keys
|
||||
valid := []string{
|
||||
"infrastructure",
|
||||
"token",
|
||||
"join",
|
||||
"endpoint",
|
||||
}
|
||||
if err := helper.CheckHCLKeys(listVal, valid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var m map[string]interface{}
|
||||
if err := hcl.DecodeObject(&m, listVal); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var atlas AtlasConfig
|
||||
if err := mapstructure.WeakDecode(m, &atlas); err != nil {
|
||||
return err
|
||||
}
|
||||
*result = &atlas
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseConsulConfig(result **config.ConsulConfig, list *ast.ObjectList) error {
|
||||
list = list.Elem()
|
||||
if len(list.Items) > 1 {
|
||||
|
|
|
@ -129,12 +129,6 @@ func TestConfig_Parse(t *testing.T) {
|
|||
SyslogFacility: "LOCAL1",
|
||||
DisableUpdateCheck: true,
|
||||
DisableAnonymousSignature: true,
|
||||
Atlas: &AtlasConfig{
|
||||
Infrastructure: "armon/test",
|
||||
Token: "abcd",
|
||||
Join: true,
|
||||
Endpoint: "127.0.0.1:1234",
|
||||
},
|
||||
Consul: &config.ConsulConfig{
|
||||
ServerServiceName: "nomad",
|
||||
ClientServiceName: "nomad-client",
|
||||
|
|
|
@ -30,7 +30,6 @@ func TestConfig_Merge(t *testing.T) {
|
|||
Ports: &Ports{},
|
||||
Addresses: &Addresses{},
|
||||
AdvertiseAddrs: &AdvertiseAddrs{},
|
||||
Atlas: &AtlasConfig{},
|
||||
Vault: &config.VaultConfig{},
|
||||
Consul: &config.ConsulConfig{},
|
||||
Sentinel: &config.SentinelConfig{},
|
||||
|
@ -125,12 +124,6 @@ func TestConfig_Merge(t *testing.T) {
|
|||
RPC: "127.0.0.1",
|
||||
Serf: "127.0.0.1",
|
||||
},
|
||||
Atlas: &AtlasConfig{
|
||||
Infrastructure: "hashicorp/test1",
|
||||
Token: "abc",
|
||||
Join: false,
|
||||
Endpoint: "foo",
|
||||
},
|
||||
HTTPAPIResponseHeaders: map[string]string{
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
},
|
||||
|
@ -273,12 +266,6 @@ func TestConfig_Merge(t *testing.T) {
|
|||
RPC: "127.0.0.2",
|
||||
Serf: "127.0.0.2",
|
||||
},
|
||||
Atlas: &AtlasConfig{
|
||||
Infrastructure: "hashicorp/test2",
|
||||
Token: "xyz",
|
||||
Join: true,
|
||||
Endpoint: "bar",
|
||||
},
|
||||
HTTPAPIResponseHeaders: map[string]string{
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
||||
|
|
|
@ -25,12 +25,6 @@ const (
|
|||
// ErrInvalidMethod is used if the HTTP method is not supported
|
||||
ErrInvalidMethod = "Invalid method"
|
||||
|
||||
// scadaHTTPAddr is the address associated with the
|
||||
// HTTPServer. When populating an ACL token for a request,
|
||||
// this is checked to switch between the ACLToken and
|
||||
// AtlasACLToken
|
||||
scadaHTTPAddr = "SCADA"
|
||||
|
||||
// ErrEntOnly is the error returned if accessing an enterprise only
|
||||
// endpoint
|
||||
ErrEntOnly = "Nomad Enterprise only endpoint"
|
||||
|
@ -113,28 +107,6 @@ func NewHTTPServer(agent *Agent, config *Config) (*HTTPServer, error) {
|
|||
return srv, nil
|
||||
}
|
||||
|
||||
// newScadaHttp creates a new HTTP server wrapping the SCADA
|
||||
// listener such that HTTP calls can be sent from the brokers.
|
||||
func newScadaHttp(agent *Agent, list net.Listener) *HTTPServer {
|
||||
// Create the mux
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Create the server
|
||||
srv := &HTTPServer{
|
||||
agent: agent,
|
||||
mux: mux,
|
||||
listener: list,
|
||||
logger: agent.logger,
|
||||
Addr: scadaHTTPAddr,
|
||||
}
|
||||
srv.registerHandlers(false) // Never allow debug for SCADA
|
||||
|
||||
// Handle requests with gzip compression
|
||||
go http.Serve(list, gziphandler.GzipHandler(mux))
|
||||
|
||||
return srv
|
||||
}
|
||||
|
||||
// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted
|
||||
// connections. It's used by NewHttpServer so
|
||||
// dead TCP connections eventually go away.
|
||||
|
|
Loading…
Reference in New Issue