Skip to content

Commit

Permalink
Update tags and sync time
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome authored and renovate[bot] committed Aug 20, 2024
1 parent 8b91d11 commit 13474fa
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ This also works when an instance is being terminated: the asg-sync will remove t
> Because the asg-sync works on a polling-based model, there will be a delay between the instance going to a
> terminating state and the asg-sync removing its IP from NGINX Plus. To guarantee that NGINX Plus doesn't send any
> requests to a terminated instance, make sure the instance goes to the `Terminating:Wait` state for a period greater
> than the interval `sync_interval_in_seconds`.
> than the interval `sync_interval`.
## Configuration for Cloud Providers

Expand Down
4 changes: 2 additions & 2 deletions build/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# cloud_provider: AWS
# region: us-west-2
# api_endpoint: http://127.0.0.1:8080/api
# sync_interval_in_seconds: 5
# sync_interval: 5s
# upstreams:
# - name: backend1
# autoscaling_group: backend-group-1
Expand All @@ -24,7 +24,7 @@
# subscription_id: my_subscription_id
# resource_group_name: my_resource_group
# api_endpoint: http://127.0.0.1:8080/api
# sync_interval_in_seconds: 5
# sync_interval: 5s
# upstreams:
# - name: backend1
# virtual_machine_scale_set: backend-group-1
Expand Down
16 changes: 8 additions & 8 deletions cmd/sync/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,20 @@ func prepareBatches(maxItems int, items []string) [][]string {
// Configuration for AWS Cloud Provider

type awsConfig struct {
Region string
Upstreams []awsUpstream
Region string `yaml:"region"`
Upstreams []awsUpstream `yaml:"upstreams"`
}

type awsUpstream struct {
Name string
Name string `yaml:"name"`
AutoscalingGroup string `yaml:"autoscaling_group"`
Kind string
Kind string `yaml:"kind"`
FailTimeout string `yaml:"fail_timeout"`
SlowStart string `yaml:"slow_start"`
Port int
MaxConns int `yaml:"max_conns"`
MaxFails int `yaml:"max_fails"`
InService bool `yaml:"in_service"`
Port int `yaml:"port"`
MaxConns int `yaml:"max_conns"`
MaxFails int `yaml:"max_fails"`
InService bool `yaml:"in_service"`
}

func validateAWSConfig(cfg *awsConfig) error {
Expand Down
16 changes: 8 additions & 8 deletions cmd/sync/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,20 @@ func (client *AzureClient) GetUpstreams() []Upstream {
}

type azureConfig struct {
SubscriptionID string `yaml:"subscription_id"`
ResourceGroupName string `yaml:"resource_group_name"`
Upstreams []azureUpstream
SubscriptionID string `yaml:"subscription_id"`
ResourceGroupName string `yaml:"resource_group_name"`
Upstreams []azureUpstream `yaml:"upstreams"`
}

type azureUpstream struct {
Name string
Name string `yaml:"name"`
VMScaleSet string `yaml:"virtual_machine_scale_set"`
Kind string
Kind string `yaml:"kind"`
FailTimeout string `yaml:"fail_timeout"`
SlowStart string `yaml:"slow_start"`
Port int
MaxConns int `yaml:"max_conns"`
MaxFails int `yaml:"max_fails"`
Port int `yaml:"port"`
MaxConns int `yaml:"max_conns"`
MaxFails int `yaml:"max_fails"`
}

func validateAzureConfig(cfg *azureConfig) error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/sync/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type commonConfig struct {
APIEndpoint string `yaml:"api_endpoint"`
CloudProvider string `yaml:"cloud_provider"`
SyncInterval time.Duration `yaml:"sync_interval_in_seconds"`
SyncInterval time.Duration `yaml:"sync_interval"`
}

func parseCommonConfig(data []byte) (*commonConfig, error) {
Expand All @@ -35,7 +35,7 @@ func validateCommonConfig(cfg *commonConfig) error {
return fmt.Errorf(errorMsgFormat, "api_endpoint")
}

if cfg.SyncInterval == 0 {
if cfg.SyncInterval <= 0 {
return errors.New(intervalErrorMsg)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/sync/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "testing"
var validYaml = []byte(`
cloud_provider: AWS
api_endpoint: http://127.0.0.1:8080/api
sync_interval_in_seconds: 5
sync_interval: 5s
`)

type testInputCommon struct {
Expand All @@ -29,7 +29,7 @@ func getInvalidCommonConfigInput() []*testInputCommon {

invalidSyncIntervalCfg := getValidCommonConfig()
invalidSyncIntervalCfg.SyncInterval = 0
input = append(input, &testInputCommon{invalidSyncIntervalCfg, "invalid sync_interval_in_seconds"})
input = append(input, &testInputCommon{invalidSyncIntervalCfg, "invalid sync_interval"})

return input
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/sync/errormessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

const (
errorMsgFormat = "the mandatory field %v is either empty or missing in the config file"
intervalErrorMsg = "the mandatory field sync_interval_in_seconds is either 0 or missing in the config file"
intervalErrorMsg = "the mandatory field sync_interval is either 0, negative or missing in the config file"
cloudProviderErrorMsg = "the field cloud_provider has invalid value %v in the config file"
defaultCloudProvider = "AWS"
upstreamNameErrorMsg = "the mandatory field name is either empty or missing for an upstream in the config file"
Expand Down
2 changes: 1 addition & 1 deletion cmd/sync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func main() {
}

select {
case <-time.After(commonConfig.SyncInterval * time.Second): //nolint:durationcheck
case <-time.After(commonConfig.SyncInterval):
case <-sigterm:
log.Println("Terminating...")
return
Expand Down
6 changes: 3 additions & 3 deletions examples/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ nginx-asg-sync is configured in **/etc/nginx/config.yaml**.
```yaml
region: us-west-2
api_endpoint: http://127.0.0.1:8080/api
sync_interval_in_seconds: 5
sync_interval: 5s
cloud_provider: AWS
upstreams:
- name: backend-one
Expand All @@ -48,8 +48,8 @@ upstreams:
```
- The `api_endpoint` key defines the NGINX Plus API endpoint.
- The `sync_interval_in_seconds` key defines the synchronization interval: nginx-asg-sync checks for scaling updates
every 5 seconds.
- The `sync_interval` key defines the synchronization interval: nginx-asg-sync checks for scaling updates
every 5 seconds. The value is a string that represents a duration (e.g., `5s`). The maximum unit is hours.
- The `cloud_provider` key defines a cloud provider that will be used. The default is `AWS`. This means the key can be
empty if using AWS. Possible values are: `AWS`, `Azure`.
- The `region` key defines the AWS region where we deploy NGINX Plus and the Auto Scaling groups. Setting `region` to
Expand Down
6 changes: 3 additions & 3 deletions examples/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ nginx-asg-sync is configured in **/etc/nginx/config.yaml**.

```yaml
api_endpoint: http://127.0.0.1:8080/api
sync_interval_in_seconds: 5
sync_interval: 5s
cloud_provider: Azure
subscription_id: my_subscription_id
resource_group_name: my_resource_group
Expand All @@ -50,8 +50,8 @@ upstreams:
```
- The `api_endpoint` key defines the NGINX Plus API endpoint.
- The `sync_interval_in_seconds` key defines the synchronization interval: nginx-asg-sync checks for scaling updates
every 5 seconds.
- The `sync_interval` key defines the synchronization interval: nginx-asg-sync checks for scaling updates
every 5 seconds. The value is a string that represents a duration (e.g., `5s`). The maximum unit is hours.
- The `cloud_provider` key defines a Cloud Provider that will be used. The default is `AWS`. This means the key can be
empty if using AWS. Possible values are: `AWS`, `Azure`.
- The `subscription_id` key defines the Azure unique subscription id that identifies your Azure subscription.
Expand Down

0 comments on commit 13474fa

Please sign in to comment.