Skip to content

Limit HPA emergency mode to repeated failures#453

Draft
djahandarie wants to merge 1 commit intomercari:mainfrom
djahandarie:djahandarie-20250702-224811
Draft

Limit HPA emergency mode to repeated failures#453
djahandarie wants to merge 1 commit intomercari:mainfrom
djahandarie:djahandarie-20250702-224811

Conversation

@djahandarie
Copy link
Copy Markdown
Contributor

Enhance the Horizontal Pod Autoscaler (HPA) logic to switch to emergency mode only after multiple failures to retrieve resource metrics within a specified timeframe. This change prevents unnecessary transitions to emergency mode due to transient issues.

Comment thread pkg/hpa/service.go
}

if err := c.c.List(ctx, &evList, opts); err != nil {
logger.Info("Failed to get events for HPA to check for FailedGetResourceMetric, switch to emergency mode", "hpa", currenthpa.Name)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This discards the err object, should probably log it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also maybe this should be Warn or Err instead of Info

Comment thread pkg/hpa/service.go
}

// count number of FailedGetResourceMetric events that occured in the last 5 minutes
fiveMinutesAgo := time.Now().Add(-5 * time.Minute)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should probably at least move this into a constant

Comment thread pkg/hpa/service.go
}
}

if count > 5 {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also this

Comment thread pkg/hpa/service.go
}

if count > 5 {
logger.Info("HPA failed to get resource metrics over 5 times in the last 5 minutes, switch to emergency mode", "hpa", currenthpa.Name, "failCount", count)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe this can be a Warn

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.

1 participant