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

do not always error out while checking for existence of resources #151

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leelavg
Copy link
Contributor

@leelavg leelavg commented Oct 4, 2024

controllers also get reconciles for deletion events and it may happen that resource at api server be deleted first before it being purged from cache and during that time if we error out the reconciliation will never be successful in standard conditions.

fixes: #78

@leelavg
Copy link
Contributor Author

leelavg commented Oct 4, 2024

I'm a bit divided b/n where the handling should happen, like, err returned from the load function can't always be same as returned by api server.

To be moved inside the function it needs to copied at a couple of places, pls review.

internal/controller/clientprofile_controller.go Outdated Show resolved Hide resolved
internal/controller/driver_controller.go Outdated Show resolved Hide resolved
internal/controller/clientprofile_controller.go Outdated Show resolved Hide resolved
internal/controller/driver_controller.go Outdated Show resolved Hide resolved
internal/controller/driver_controller.go Outdated Show resolved Hide resolved
Comment on lines 229 to 232
if k8serrors.IsNotFound(err) {
r.log.Info("Driver resource does not exist anymore, skipping reconcile")
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is should not be here because it is returning nil for all the not found errors, like if the imageset configmap not found we will get here and we return nil to stop the reconcile which is not correct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree.
The inner function needs to return a different custom error so the top-most function can make a decision based on that concrete error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, done.

controllers also get reconciles for deletion events and it may happen
that resource at api server be deleted first before it being purged from
cache and during that time if we error out the reconciliation will never
be successful in standard conditions.

Signed-off-by: Leela Venkaiah G <[email protected]>
@@ -130,6 +131,10 @@ func (r *ClientProfileReconciler) Reconcile(ctx context.Context, req ctrl.Reques

func (r *ClientProfileReconcile) reconcile() error {
if err := r.loadAndValidate(); err != nil {
if k8serrors.IsNotFound(err) && r.clientProfile.UID == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@leelavg wouldn't it make more sense to investigate the error object to see the target of the not found error?

@@ -226,6 +226,10 @@ func (r *DriverReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
func (r *driverReconcile) reconcile() error {
// Load the driver desired state based on driver resource, operator config resource and default values.
if err := r.LoadAndValidateDesiredState(); err != nil {
if k8serrors.IsNotFound(err) && r.driver.UID == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as last comment

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.

Fix CR not found after delete operation
3 participants