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

Unhandled Error When Deleting SleepInfo Resource #401

Open
abelhoula opened this issue Mar 7, 2024 · 1 comment
Open

Unhandled Error When Deleting SleepInfo Resource #401

abelhoula opened this issue Mar 7, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@abelhoula
Copy link

Description
An unhandled error occurs when deleting a SleepInfo resource. The controller logs show an error related to fetching the SleepInfo resource after it has been deleted, indicating it cannot find the deleted resource.

To Reproduce
Steps to reproduce the behavior:

  1. Create a SleepInfo resource named sleep-test in the namespace sleepme.
  2. Delete the SleepInfo resource.
  3. Observe the error in the controller logs indicating the resource cannot be found.

Logs

2024-03-07T08:14:00Z    INFO    controllers.SleepInfo   last schedule value     {"sleepinfo": "sleepme/sleep-test", "now": "2024-03-07T08:14:00Z", "next run": "2024-03-07T08:20:00Z", "requeue": "5m59.933043022s", "last schedule": "2024-03-07T08:14:00Z", "status": {"lastScheduleTime":"2024-03-07T08:10:00Z","operation":"SLEEP"}}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:235
2024-03-07T08:20:00Z    ERROR   controllers.SleepInfo   unable to fetch sleepInfo       {"sleepinfo": "sleepme/sleep-test", "error": "SleepInfo.kube-green.com \"sleep-test\" not found"}
github.com/kube-green/kube-green/controllers/sleepinfo.(*SleepInfoReconciler).Reconcile
        /workspace/controllers/sleepinfo/sleepinfo_controller.go:80
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:122
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:323
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:274
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:235

@davidebianchi
Copy link
Member

Hi @abelhoula! Thank you for the report!
This error is correctly managed, the log is for debug purposes as seen in the below code:

sleepInfo, err := r.getSleepInfo(ctx, req)
if err != nil {
log.Error(err, "unable to fetch sleepInfo")
// we'll ignore not-found errors, since they can't be fixed by an immediate
// requeue (we'll need to wait for a new notification), and we can get them
// on deleted requests.
if apierrors.IsNotFound(err) {
r.Metrics.CurrentSleepInfo.Delete(prometheus.Labels{
"name": req.Name,
"namespace": req.Namespace,
})
}
return ctrl.Result{}, client.IgnoreNotFound(err)
}

Probably, we should set an higher verbosity level to the log to enable it only if needed to debug purpose.

@davidebianchi davidebianchi added enhancement New feature or request good first issue Good for newcomers labels Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants