Skip to content

Commit

Permalink
Merge pull request #104 from ThomasObenaus/f/103_clean_deprecated_falgs
Browse files Browse the repository at this point in the history
Removed deprecated parameter sca.nomad.mode
  • Loading branch information
ThomasObenaus authored Oct 13, 2019
2 parents 53d5715 + 56c3ffa commit 0cdb98f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 77 deletions.
29 changes: 8 additions & 21 deletions config/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ The order they are applied is:

### Mode

| | |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name | mode |
| usage | Scaling target mode is either job based, aws Ec2 or data-center (worker/ instance) based scaling. In data-center (dc) mode the nomad workers will be scaled. In job mode the number of allocations for this job will be adjusted. |
| type | string (enum: nomad-job \| nomad-dc \| aws-ec2 ) - **the values job and dc are deprecated** |
| default | job |
| flag | --sca.mode |
| env | SK_SCA_MODE |
| | |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| name | mode |
| usage | Scaling target mode is either nomad-job based, aws EC2 or nomad data-center (worker/ instance) based scaling. In data-center (`noamd-dc`) mode the nomad workers will be scaled. In `nomad-job` mode the number of allocations for this job will be adjusted. In `aws-ec2` mode AWS instances will be scaled adjusting the according AutoScalingGroup. |
| type | string (enum: nomad-job \| nomad-dc \| aws-ec2 ) |
| default | job |
| flag | --sca.mode |
| env | SK_SCA_MODE |

### AWS EC2

Expand Down Expand Up @@ -108,19 +108,6 @@ The order they are applied is:

- This section contains the configuration parameters for nomad based scalers (i.e. job or data-center on AWS).

#### [DEPRECATED] Mode

- The parameter `sca.nomad.mode` will be replaced by `sca.mode`

| | |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| name | mode |
| usage | Scaling target mode is either job based or data-center (worker/ instance) based scaling. In data-center (dc) mode the nomad workers will be scaled. In job mode the number of allocations for this job will be adjusted. |
| type | string (enum: job \| dc ) |
| default | job |
| flag | --sca.nomad.mode |
| env | SK_SCA_NOMAD_MODE |

#### Server-Address

| | |
Expand Down
10 changes: 0 additions & 10 deletions config/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ var port = configEntry{
}

// ###################### Context: scaler ####################################################
// TODO: DEPRECATED, remove it
var scaNomadMode = configEntry{
name: "sca.nomad.mode",
bindEnv: true,
bindFlag: true,
defaultValue: "",
usage: "Scaling target mode is either job based or data-center (worker/ instance) based scaling. In data-center (dc) mode the nomad workers will be scaled. In job mode the number of allocations for this job will be adjusted.",
}

var scaMode = configEntry{
name: "sca.mode",
bindEnv: true,
Expand Down Expand Up @@ -294,7 +285,6 @@ var configEntries = []configEntry{
scaAWSEC2ASGTagKey,
scaNomadDataCenterAWSProfile,
scaNomadDataCenterAWSRegion,
scaNomadMode,
scaNomadModeServerAddress,
capConstantModeEnable,
capConstantModeOffset,
Expand Down
10 changes: 0 additions & 10 deletions config/fillCfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ func (cfg *Config) fillScaler() error {
}
cfg.Scaler.Mode = scaMode

// TODO: DEPRECATED, Remove it
scaNomadModeStr := cfg.viper.GetString(scaNomadMode.name)
if len(scaNomadModeStr) > 0 {
scaMode, err = strToScalerMode(scaNomadModeStr)
if err != nil {
return err
}
cfg.Scaler.Mode = scaMode
}

// Context: Scaler - AWS EC2
cfg.Scaler.AwsEc2.Profile = cfg.viper.GetString(scaAWSEC2Profile.name)
cfg.Scaler.AwsEc2.Region = cfg.viper.GetString(scaAWSEC2Region.name)
Expand Down
36 changes: 0 additions & 36 deletions config/fillCfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,42 +300,6 @@ func Test_StrToScalerMode(t *testing.T) {
assert.Equal(t, ScalerModeAwsEc2, mode)
}

// TODO: Remove as soon as the sca.nomad.mode flag has been removed
func Test_FillCfg_SupportDeprecatedFlags(t *testing.T) {

cfg := NewDefaultConfig()
args := []string{
"--sca.nomad.mode=aws-ec2",
"--sca.mode=job",
}

err := cfg.ReadConfig(args)
assert.NoError(t, err)
assert.Equal(t, ScalerModeAwsEc2, cfg.Scaler.Mode)

// old job
cfg = NewDefaultConfig()
args = []string{
"--sca.mode=job",
"--sca.nomad.server-address=http://1.2.3.4",
}

err = cfg.ReadConfig(args)
assert.NoError(t, err)
assert.Equal(t, ScalerModeNomadJob, cfg.Scaler.Mode)

// old dc
cfg = NewDefaultConfig()
args = []string{
"--sca.mode=dc",
"--sca.nomad.server-address=http://1.2.3.4",
}

err = cfg.ReadConfig(args)
assert.NoError(t, err)
assert.Equal(t, ScalerModeNomadDataCenter, cfg.Scaler.Mode)
}

func Test_ValidateCapacityPlanner(t *testing.T) {
capacityPlanner := CapacityPlanner{}
err := validateCapacityPlanner(capacityPlanner)
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/spf13/viper/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0cdb98f

Please sign in to comment.