Skip to content

Commit

Permalink
Fix rack update to same version
Browse files Browse the repository at this point in the history
  • Loading branch information
nightfury1204 committed Aug 23, 2024
1 parent b89d969 commit 317a496
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions provider/aws/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ func (p *Provider) Sync(name string) error {

func (p *Provider) SystemUpdate(opts structs.SystemUpdateOptions) error {
changes := map[string]string{}
hasOtherChange := false

// carry forward values from original custom topic resources
params := map[string]string{
Expand All @@ -646,21 +647,25 @@ func (p *Provider) SystemUpdate(opts structs.SystemUpdateOptions) error {
for k, v := range opts.Parameters {
params[k] = v
}
hasOtherChange = true
}

if v, has := params["WhiteList"]; has {
p.WhiteListSpecified = len(v) > 0
p.SyncInstancesIpInSecurityGroup()
hasOtherChange = true
}

if opts.Count != nil {
params["InstanceCount"] = strconv.Itoa(*opts.Count)
changes["count"] = strconv.Itoa(*opts.Count)
hasOtherChange = true
}

if opts.Type != nil {
params["InstanceType"] = *opts.Type
changes["type"] = *opts.Type
hasOtherChange = true
}

var template []byte
Expand Down Expand Up @@ -695,6 +700,17 @@ func (p *Provider) SystemUpdate(opts structs.SystemUpdateOptions) error {

// if there is a version update then record it
if v, ok := changes["version"]; ok {
if !hasOtherChange {
rDetails, err := p.SystemGet()
if err != nil {
return err
}

// check rack already in that version or not
if rDetails.Version == v {
return nil
}
}
_, err := p.dynamodb().PutItem(&dynamodb.PutItemInput{
Item: map[string]*dynamodb.AttributeValue{
"id": {S: aws.String(v)},
Expand Down

0 comments on commit 317a496

Please sign in to comment.