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

Added a new helm parameter controllers.vdbMaxBackoffDuration #978

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

cchen-vertica
Copy link
Collaborator

This PR introduces a new Helm parameter, controllers.vdbMaxBackoffDuration, to address the requeue-hang issue in revive_db. This parameter allows us to set a maximum requeue duration for the VDB controller, providing more control over the requeue behavior.

// GetVdbMaxBackoffDuration returns maximum backoff requeue duration in milliseconds for vdb controller
func GetVdbMaxBackoffDuration() int {
duration := lookupIntEnvVar("VDB_MAX_BACKOFF_DURATION", envCanNotExist)
if duration == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we set the value VDB_MAX_BACKOFF_DURATION=0, should we expect 0ms duration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we do expect 0ms duration. I will change this one to "<0".

// GetVdbMaxBackoffDuration returns maximum backoff requeue duration in milliseconds for vdb controller
func GetVdbMaxBackoffDuration() int {
duration := lookupIntEnvVar("VDB_MAX_BACKOFF_DURATION", envCanNotExist)
if duration == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if duration == 0 {
if duration <= 0 {

Comment on lines 79 to 80
rateLimiter := workqueue.NewItemExponentialFailureRateLimiter(1*time.Millisecond,
time.Duration(opcfg.GetVdbMaxBackoffDuration())*time.Millisecond)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not use opcfg here. Let' set the rate limiter in main.go and pass it to SetupWithManager:

main.go

rateLimiter := workqueue.NewItemExponentialFailureRateLimiter(....)

// Create the controller with custom options, including the rate limiter
options := controller.Options{
     RateLimiter: rateLimiter,
}

}).SetupWithManager(mgr, options)



verticadb_controller.go

return ctrl.NewControllerManagedBy(mgr).
		WithOptions(options).
		For(&vapi.VerticaDB{}).
		Owns(&corev1.ServiceAccount{}).
		Owns(&rbacv1.Role{}).

duration := lookupIntEnvVar("VDB_MAX_BACKOFF_DURATION", envCanNotExist)
if duration == 0 {
const envName = "VDB_MAX_BACKOFF_DURATION"
duration := lookupStringEnvVar(envName, envCanNotExist)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use lookupIntEnvVar? If the issue is the default value, maybe we can change this to lookupStringEnvVar(envName string, mustExist bool, defaultValue int)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lookupIntEnvVar returns 0 when it cannot find the env var which cannot differentiate the case with user input 0. I don't want to update lookupIntEnvVar too much since it's called in many other places.

}
valInt, err := strconv.Atoi(duration)
if err != nil || valInt < 0 {
dieIfNotValid(envName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should return the default value in this case too. see lookupIntEnvVar. Also use a constant for the default value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lookupIntEnvVar doesn't return any value when err != nil (dieIfNotValid() will exit the process). I think if the user provided the wrong value, the operator should exit and tell them their value isn't acceptable. We shouldn't replace their wrong value with a default value.

If the default value occurred more than once in the code, I will use a constant value, but it didn't so I just use a literal constant.

@cchen-vertica cchen-vertica merged commit 08ae373 into main Nov 14, 2024
40 checks passed
@cchen-vertica cchen-vertica deleted the cchen/fix-revive branch November 14, 2024 14:17
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.

3 participants