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 minor bugs #334

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ vet:
go vet ./...

# Generate code
generate: clean controller-gen
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build the docker image
Expand Down
21 changes: 12 additions & 9 deletions controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (r *RollingUpgradeContext) ReplaceNodeBatch(batch []*autoscaling.Instance)
func (r *RollingUpgradeContext) SelectTargets(scalingGroup *autoscaling.Group) []*autoscaling.Instance {
var (
batchSize = r.RollingUpgrade.MaxUnavailable()
totalNodes = len(scalingGroup.Instances)
totalNodes = int(aws.Int64Value(scalingGroup.DesiredCapacity))
targets = make([]*autoscaling.Instance, 0)
)
unavailableInt := CalculateMaxUnavailable(batchSize, totalNodes)
Expand Down Expand Up @@ -645,14 +645,17 @@ func CalculateMaxUnavailable(batchSize intstr.IntOrString, totalNodes int) int {
}

func (r *RollingUpgradeContext) SetProgress(nodesProcessed int, totalNodes int) {
completePercentage := int(math.Round(float64(nodesProcessed) / float64(totalNodes) * 100))
r.RollingUpgrade.SetTotalNodes(totalNodes)
r.RollingUpgrade.SetNodesProcessed(nodesProcessed)
r.RollingUpgrade.SetCompletePercentage(completePercentage)

// expose total nodes and nodes processed to prometheus
common.SetTotalNodesMetric(r.RollingUpgrade.ScalingGroupName(), totalNodes)
common.SetNodesProcessedMetric(r.RollingUpgrade.ScalingGroupName(), nodesProcessed)
if totalNodes > 0 && nodesProcessed >= 0 {
r.RollingUpgrade.SetTotalNodes(totalNodes)
r.RollingUpgrade.SetNodesProcessed(nodesProcessed)

completePercentage := int(math.Round(float64(nodesProcessed) / float64(totalNodes) * 100))
r.RollingUpgrade.SetCompletePercentage(completePercentage)

// expose total nodes and nodes processed to prometheus
common.SetTotalNodesMetric(r.RollingUpgrade.ScalingGroupName(), totalNodes)
common.SetNodesProcessedMetric(r.RollingUpgrade.ScalingGroupName(), nodesProcessed)
}

}

Expand Down