-
Notifications
You must be signed in to change notification settings - Fork 28
Limit HPA emergency mode to repeated failures #453
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
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
} | ||
|
||
// count number of FailedGetResourceMetric events that occured in the last 5 minutes | ||
fiveMinutesAgo := time.Now().Add(-5 * time.Minute) |
There was a problem hiding this comment.
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
} | ||
} | ||
|
||
if count > 5 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this
} | ||
|
||
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) |
There was a problem hiding this comment.
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
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.