This repository was archived by the owner on May 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
This repository was archived by the owner on May 14, 2025. It is now read-only.
Custom en-queue logic #13
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestselectusecaseCan/Does Metac solve this usecaseCan/Does Metac solve this usecase
Description
As a developer, I would like Metac to support custom logic before en-queuing a watch resource.
For example, I want below en-queue condition to be supported by Metac
import (
"k8s.io/apimachinery/pkg/api/equality"
)
// shouldEnqueueVAChange checks if a changed VolumeAttachment should be enqueued.
//
// It filters out changes in Status.Attach/DetachError - these were posted by the
// controller just few moments ago. If they were enqueued, Attach()/Detach() would
// be called again, breaking exponential backoff.
func shouldEnqueueVAChange(old, new *storage.VolumeAttachment) bool {
if old.ResourceVersion == new.ResourceVersion {
// This is most probably periodic sync, enqueue it
return true
}
if new.Status.AttachError == nil &&
new.Status.DetachError == nil &&
old.Status.AttachError == nil &&
old.Status.DetachError == nil {
// The difference between old and new must be elsewhere than
// Status.Attach/DetachError
return true
}
sanitized := new.DeepCopy()
sanitized.ResourceVersion = old.ResourceVersion
sanitized.Status.AttachError = old.Status.AttachError
sanitized.Status.DetachError = old.Status.DetachError
if equality.Semantic.DeepEqual(old, sanitized) {
// The objects are the same except Status.Attach/DetachError.
// Don't enqueue them now. Let them be enqueued due to resync
// i.e. after sync interval
return false
}
return true
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestselectusecaseCan/Does Metac solve this usecaseCan/Does Metac solve this usecase