MCPcopy Create free account
hub / github.com/coldbrewcloud/coldbrew-cli / scaleOut

Method scaleOut

commands/clusterscale/command.go:89–118  ·  view source on GitHub ↗
(autoScalingGroupName string, currentTarget, newTarget uint16)

Source from the content-addressed store, hash-verified

87}
88
89func (c *Command) scaleOut(autoScalingGroupName string, currentTarget, newTarget uint16) error {
90 console.UpdatingResource(fmt.Sprintf("Updating desired capacity to %d", newTarget), autoScalingGroupName, true)
91
92 err := c.awsClient.AutoScaling().UpdateAutoScalingGroupCapacity(autoScalingGroupName, 0, newTarget, newTarget)
93 if err != nil {
94 return fmt.Errorf("Failed to update capacity of EC2 Auto Scaling Group [%s]: %s", autoScalingGroupName, err.Error())
95 }
96
97 err = utils.Retry(func() (bool, error) {
98 autoScalingGroup, err := c.awsClient.AutoScaling().RetrieveAutoScalingGroup(autoScalingGroupName)
99 if err != nil {
100 return false, fmt.Errorf("Failed to retrieve EC2 Auto Scaling Group [%s]: %s", autoScalingGroupName, err.Error())
101 }
102 if autoScalingGroup == nil {
103 return false, fmt.Errorf("EC2 Auto Scaling Group [%s] was not found.", autoScalingGroupName)
104 }
105 if uint16(len(autoScalingGroup.Instances)) == newTarget {
106 return false, nil
107 }
108 return true, nil
109 }, time.Second, 5*time.Minute)
110 if err != nil {
111 return err
112 }
113
114 console.Blank()
115 //console.Info(fmt.Sprintf("EC2 Auto Scaling Group [%s] now has %d instances.", autoScalingGroupName, newTarget))
116
117 return nil
118}
119
120func (c *Command) scaleIn(autoScalingGroupName string, currentTarget, newTarget uint16) error {
121 console.UpdatingResource(fmt.Sprintf("Updating desired capacity to %d", newTarget), autoScalingGroupName, true)

Callers 1

RunMethod · 0.95

Implementers 8

Commandcommands/clusterstatus/command.go
Commandcommands/deploy/command.go
Commandcommands/clusterdelete/command.go
Commandcommands/delete/command.go
Commandcommands/clustercreate/command.go
Commandcommands/create/command.go
Commandcommands/clusterscale/command.go
Commandcommands/status/command.go

Calls 4

AutoScalingMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected