Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): autoscaling range default value #1469

Merged
merged 2 commits into from
Oct 6, 2020

Conversation

mRoca
Copy link
Contributor

@mRoca mRoca commented Oct 6, 2020

When using the following manifest file and deploying on production env, the range value is set to an empty string :

name: foobar
type: Load Balanced Web Service

image:
  build: Dockerfile
  port: 80

count:
  range: 2-6
  cpu_percentage: 70
  memory_percentage: 80

environments:
  production:
    variables:
      MODE: production

After running the command:

# copilot svc package -n foobar -e production --output-dir /tmp/out

✘ generate stack template: convert the Auto Scaling configuration for service adminapi: invalid range value . Should be in format of ${min}-${max}

This bug comes from this code:

// internal/pkg/manifest/lb_web_svc.go

func (s LoadBalancedWebService) ApplyEnv(envName string) (*LoadBalancedWebService, error) {
	// ...
	err := mergo.Merge(&s, LoadBalancedWebService{
		LoadBalancedWebServiceConfig: *overrideConfig,
	}, mergo.WithOverride, mergo.WithOverwriteWithEmptyValue)

As the mergo.WithOverwriteWithEmptyValue option is used, the Autoscaling.Range value is overrided by the default one, which is an empty string.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mRoca mRoca requested a review from a team as a code owner October 6, 2020 11:03
@mRoca mRoca requested a review from kohidave October 6, 2020 11:03
@mRoca mRoca force-pushed the fix/range-default-value branch from 8704f83 to d818330 Compare October 6, 2020 11:41
@kohidave kohidave requested review from efekarakus and iamhopaul123 and removed request for kohidave October 6, 2020 16:25
Copy link
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome :shipit: Thank you so much for finding and fixing this bug!

@mergify mergify bot merged commit ec25783 into aws:mainline Oct 6, 2020
Copy link
Contributor

@efekarakus efekarakus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heya! thanks for the contribution!

Is there a test case like described in the description that shows that after ApplyEnv is invoked the range remains as expected instead of the empty string ""

@efekarakus
Copy link
Contributor

OK I see it now :) yay thank you!

thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
<!-- Provide summary of changes -->

When using the following manifest file and deploying on `production` env, the `range` value is set to an empty string :

```yaml
name: foobar
type: Load Balanced Web Service

image:
  build: Dockerfile
  port: 80

count:
  range: 2-6
  cpu_percentage: 70
  memory_percentage: 80

environments:
  production:
    variables:
      MODE: production
```

After running the command:
```
# copilot svc package -n foobar -e production --output-dir /tmp/out

✘ generate stack template: convert the Auto Scaling configuration for service adminapi: invalid range value . Should be in format of ${min}-${max}
```

This bug comes from this code:

```go
// internal/pkg/manifest/lb_web_svc.go

func (s LoadBalancedWebService) ApplyEnv(envName string) (*LoadBalancedWebService, error) {
	// ...
	err := mergo.Merge(&s, LoadBalancedWebService{
		LoadBalancedWebServiceConfig: *overrideConfig,
	}, mergo.WithOverride, mergo.WithOverwriteWithEmptyValue)
```

As the `mergo.WithOverwriteWithEmptyValue` option is used, the `Autoscaling.Range` value is overrided by the default one, which is an empty string.



By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants