etcdconfig

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package etcdconfig defines etcd test configuration.

Index

Constants

This section is empty.

Variables

View Source
var Versions = map[string]map[uint64]map[string]bool{

	"3.4": {
		0: {
			"initial-election-tick-advance": true,
		},
	},

	"3.3": {
		10: {
			"initial-election-tick-advance": true,
		},
		9: {
			"initial-election-tick-advance": true,
		},
		8: {
			"initial-election-tick-advance": true,
		},
		7: {
			"initial-election-tick-advance": true,
		},
		6: {
			"initial-election-tick-advance": true,
		},
		5: {
			"initial-election-tick-advance": true,
		},
		4: {
			"initial-election-tick-advance": true,
		},
		3: {
			"initial-election-tick-advance": false,
		},
		2: {
			"initial-election-tick-advance": false,
		},
		1: {
			"initial-election-tick-advance": false,
		},
		0: {
			"initial-election-tick-advance": false,
		},
	},

	"3.2": {
		25: {
			"initial-election-tick-advance": true,
		},
		24: {
			"initial-election-tick-advance": true,
		},
		23: {
			"initial-election-tick-advance": true,
		},
		22: {
			"initial-election-tick-advance": true,
		},
		21: {
			"initial-election-tick-advance": true,
		},
		20: {
			"initial-election-tick-advance": true,
		},
		19: {
			"initial-election-tick-advance": true,
		},
		18: {
			"initial-election-tick-advance": false,
		},
		17: {
			"initial-election-tick-advance": false,
		},
		16: {
			"initial-election-tick-advance": false,
		},
		15: {
			"initial-election-tick-advance": false,
		},
		14: {
			"initial-election-tick-advance": false,
		},
		13: {
			"initial-election-tick-advance": false,
		},
		12: {
			"initial-election-tick-advance": false,
		},
		11: {
			"initial-election-tick-advance": false,
		},
		10: {
			"initial-election-tick-advance": false,
		},
		9: {
			"initial-election-tick-advance": false,
		},
		8: {
			"initial-election-tick-advance": false,
		},
		7: {
			"initial-election-tick-advance": false,
		},
		6: {
			"initial-election-tick-advance": false,
		},
		5: {
			"initial-election-tick-advance": false,
		},
		4: {
			"initial-election-tick-advance": false,
		},
		3: {
			"initial-election-tick-advance": false,
		},
		2: {
			"initial-election-tick-advance": false,
		},
		1: {
			"initial-election-tick-advance": false,
		},
		0: {
			"initial-election-tick-advance": false,
		},
	},

	"3.1": {
		20: {
			"initial-election-tick-advance": true,
		},
		19: {
			"initial-election-tick-advance": true,
		},
		18: {
			"initial-election-tick-advance": true,
		},
		17: {
			"initial-election-tick-advance": true,
		},
		16: {
			"initial-election-tick-advance": true,
		},
		15: {
			"initial-election-tick-advance": true,
		},
		14: {
			"initial-election-tick-advance": true,
		},
		13: {
			"initial-election-tick-advance": false,
		},
		12: {
			"initial-election-tick-advance": false,
		},
	},
}

Versions lists all new features per release version.

Functions

func CheckInitialElectionTickAdvance

func CheckInitialElectionTickAdvance(ver string) (ok bool)

CheckInitialElectionTickAdvance returns true if "--initial-election-tick-advance" is supported.

Types

type Config

type Config struct {
	// Tag is the tag used for S3 bucket name.
	// If empty, deployer auto-populates it.
	Tag string `json:"tag,omitempty"`
	// ClusterName is the cluster name.
	// If empty, deployer auto-populates it.
	ClusterName string `json:"cluster-name,omitempty"`

	// DestroyWaitTime is the duration to sleep before cluster tear down.
	DestroyWaitTime time.Duration `json:"destroy-wait-time,omitempty"`
	// Down is true to automatically tear down cluster in "test".
	// Deployer implementation should not call "Down" inside "Up" method.
	// This is meant to be used as a flag for test.
	Down bool `json:"down"`

	// ConfigPath is the configuration file path.
	// Must be left empty, and let deployer auto-populate this field.
	// Deployer is expected to update this file with latest status,
	// and to make a backup of original configuration
	// with the filename suffix ".backup.yaml" in the same directory.
	ConfigPath       string `json:"config-path,omitempty"`
	ConfigPathBucket string `json:"config-path-bucket,omitempty"`
	ConfigPathURL    string `json:"config-path-url,omitempty"`

	// LogLevel configures log level. Only supports debug, info, warn, error, panic, or fatal. Default 'info'.
	LogLevel string `json:"log-level"`
	// LogOutputs is a list of log outputs. Valid values are 'default', 'stderr', 'stdout', or file names.
	// Logs are appended to the existing file, if any.
	// Multiple values are accepted. If empty, it sets to 'default', which outputs to stderr.
	// See https://godoc.org/go.uber.org/zap#Open and https://godoc.org/go.uber.org/zap#Config for more details.
	LogOutputs []string `json:"log-outputs,omitempty"`
	// LogOutputToUploadPath is the aws-k8s-tester log file path to upload to cloud storage.
	// Must be left empty.
	// This will be overwritten by cluster name.
	LogOutputToUploadPath       string `json:"log-output-to-upload-path,omitempty"`
	LogOutputToUploadPathBucket string `json:"log-output-to-upload-path-bucket,omitempty"`
	LogOutputToUploadPathURL    string `json:"log-output-to-upload-path-url,omitempty"`

	// Logs is a list of node log file paths, fetched via SSH.
	Logs map[string]string `json:"logs,omitempty"`

	// UploadTesterLogs is true to auto-upload log files.
	UploadTesterLogs bool `json:"upload-tester-logs"`

	// EC2 defines ec2 instance configuration.
	EC2 *ec2config.Config `json:"ec2"`
	// EC2Bastion is used for test clients.
	EC2Bastion *ec2config.Config `json:"ec2-bastion"`

	// ClusterSize is the number of nodes.
	ClusterSize int `json:"cluster-size"`
	// Cluster is the shared configuration for initial cluster setup.
	// "DataDir" and "URLs" fields should not be set.
	// Will automatically be updated after EC2 creation.
	Cluster *ETCD `json:"cluster"`
	// ClusterState maps ID to etcd instance.
	ClusterState map[string]ETCD `json:"cluster-state"`

	// TestTimeout is the test operation timeout.
	TestTimeout time.Duration `json:"test-timeout,omitempty"`
}

Config defines etcd test configuration.

func Load

func Load(p string) (cfg *Config, err error)

Load loads configuration from YAML. Useful when injecting shared configuration via ConfigMap.

Example usage:

import "github.com/aws/aws-k8s-tester/etcdconfig"
cfg := etcdconfig.Load("test.yaml")
err := cfg.ValidateAndSetDefaults()

Do not set default values in this function. "ValidateAndSetDefaults" must be called separately, to prevent overwriting previous data when loaded from disks.

func NewDefault

func NewDefault() *Config

NewDefault returns a copy of the default configuration.

func (*Config) ClientURLs

func (cfg *Config) ClientURLs() (eps []string)

func (*Config) Sync

func (cfg *Config) Sync() (err error)

Sync persists current configuration and states to disk.

func (*Config) UpdateFromEnvs

func (cfg *Config) UpdateFromEnvs() error

UpdateFromEnvs updates fields from environmental variables.

func (*Config) ValidateAndSetDefaults

func (cfg *Config) ValidateAndSetDefaults() (err error)

ValidateAndSetDefaults returns an error for invalid configurations. And updates empty fields with default values. At the end, it writes populated YAML to aws-k8s-tester config path.

type ETCD

type ETCD struct {
	// Version is the etcd version.
	Version string `json:"version"`

	// TopLevel is true if this is only used for top-level configuration.
	TopLevel bool `json:"top-level"`

	SSHPrivateKeyPath string `json:"ssh-private-key-path,omitempty"`
	PublicIP          string `json:"public-ip,omitempty"`
	PublicDNSName     string `json:"public-dns-name,omitempty"`

	// MemberID is the etcd node ID in hexadecimal unit.
	// It is different than ID or Name which is set with instance ID.
	MemberID string `json:"member-id,omitempty"`

	Name                string `json:"name,omitempty" etcd:"name"`
	DataDir             string `json:"data-dir,omitempty" etcd:"data-dir"`
	ListenClientURLs    string `json:"listen-client-urls,omitempty" etcd:"listen-client-urls"`
	AdvertiseClientURLs string `json:"advertise-client-urls,omitempty" etcd:"advertise-client-urls"`
	ListenPeerURLs      string `json:"listen-peer-urls,omitempty" etcd:"listen-peer-urls"`
	AdvertisePeerURLs   string `json:"advertise-peer-urls,omitempty" etcd:"initial-advertise-peer-urls"`
	InitialCluster      string `json:"initial-cluster,omitempty" etcd:"initial-cluster"`
	InitialClusterState string `json:"initial-cluster-state,omitempty" etcd:"initial-cluster-state"`

	InitialClusterToken string `json:"initial-cluster-token" etcd:"initial-cluster-token"`
	SnapshotCount       int    `json:"snapshot-count" etcd:"snapshot-count"`
	HeartbeatMS         int    `json:"heartbeat-ms" etcd:"heartbeat-interval"`
	ElectionTimeoutMS   int    `json:"election-timeout-ms" etcd:"election-timeout"`
	QuotaBackendGB      int    `json:"quota-backend-gb" etcd:"quota-backend-bytes"`
	EnablePprof         bool   `json:"enable-pprof" etcd:"enable-pprof"`

	InitialElectionTickAdvance bool `json:"initial-election-tick-advance"`
	// contains filtered or unexported fields
}

ETCD defines etcd-specific configuration. TODO: support TLS

func (*ETCD) Flags

func (e *ETCD) Flags() (flags []string, err error)

Flags returns the list of etcd flags. Make sure to validate the configuration with "ValidateAndSetDefaults".

func (*ETCD) Service

func (e *ETCD) Service() (s string, err error)

Service returns the service file setup script.

func (*ETCD) ValidateAndSetDefaults

func (e *ETCD) ValidateAndSetDefaults() (err error)

ValidateAndSetDefaults returns an error for invalid configurations. And updates empty fields with default values. At the end, it writes populated YAML to aws-k8s-tester config path.

Directories

Path Synopsis
Package plugins implements etcd plugins.
Package plugins implements etcd plugins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL