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

Retry failed namespace informer creation in promOperator CRD watcher #3244

Conversation

davidhaja
Copy link
Contributor

@davidhaja davidhaja commented Aug 29, 2024

Description:
Added retry mechanism for namespace informer creation in promOperator CRD watcher.
In case of the namespace informer creation still fails, then exit the target allocator with error.

Link to tracking Issue(s): 3216

Testing:
Done some manual testing
If I changed the context to have timeout, and configured the timeout to 1 nanosecond:

$ go run cmd/otel-allocator/main.go
{"level":"info","ts":"2024-08-29T23:17:08+02:00","msg":"Starting the Target Allocator"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup.prometheus-cr-watcher","msg":"Retrying namespace informer creation in promOperator CRD watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher.func1\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:111\nk8s.io/client-go/util/retry.OnError.func1\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:55\nk8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtection\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:145\nk8s.io/apimachinery/pkg/util/wait.ExponentialBackoff\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:461\nk8s.io/client-go/util/retry.OnError\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:50\ngithub.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:109\nmain.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:119\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup.prometheus-cr-watcher","msg":"Retrying namespace informer creation in promOperator CRD watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher.func1\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:111\nk8s.io/client-go/util/retry.OnError.func1\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:55\nk8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtection\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:145\nk8s.io/apimachinery/pkg/util/wait.ExponentialBackoff\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:461\nk8s.io/client-go/util/retry.OnError\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:50\ngithub.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:109\nmain.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:119\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup.prometheus-cr-watcher","msg":"Retrying namespace informer creation in promOperator CRD watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher.func1\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:111\nk8s.io/client-go/util/retry.OnError.func1\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:55\nk8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtection\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:145\nk8s.io/apimachinery/pkg/util/wait.ExponentialBackoff\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:461\nk8s.io/client-go/util/retry.OnError\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:50\ngithub.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:109\nmain.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:119\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup.prometheus-cr-watcher","msg":"Retrying namespace informer creation in promOperator CRD watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher.func1\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:111\nk8s.io/client-go/util/retry.OnError.func1\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:55\nk8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtection\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:145\nk8s.io/apimachinery/pkg/util/wait.ExponentialBackoff\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:461\nk8s.io/client-go/util/retry.OnError\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:50\ngithub.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:109\nmain.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:119\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup.prometheus-cr-watcher","msg":"Retrying namespace informer creation in promOperator CRD watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher.func1\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:111\nk8s.io/client-go/util/retry.OnError.func1\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:55\nk8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtection\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:145\nk8s.io/apimachinery/pkg/util/wait.ExponentialBackoff\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:461\nk8s.io/client-go/util/retry.OnError\n\t/Users/dhaja/go/pkg/mod/k8s.io/[email protected]/util/retry/util.go:50\ngithub.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:109\nmain.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:119\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup.prometheus-cr-watcher","msg":"Failed to create namespace informer in promOperator CRD watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator/watcher.NewPrometheusCRWatcher\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/watcher/promOperator.go:118\nmain.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:119\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
{"level":"error","ts":"2024-08-29T23:17:08+02:00","logger":"setup","msg":"Can't start the prometheus watcher","error":"client rate limiter Wait returned an error: context deadline exceeded","stacktrace":"main.main\n\t/Users/dhaja/Projects/external/forked/opentelemetry-operator/cmd/otel-allocator/main.go:121\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.0/libexec/src/runtime/proc.go:272"}
exit status 1

Without any "network issue"/failure:

$ go run cmd/otel-allocator/main.go
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Starting the Target Allocator"}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","logger":"allocator","msg":"Starting server..."}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Waiting for caches to sync for namespace"}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Caches are synced for namespace"}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Waiting for caches to sync for servicemonitors"}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Caches are synced for servicemonitors"}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Waiting for caches to sync for podmonitors"}
{"level":"info","ts":"2024-08-29T23:12:54+02:00","msg":"Caches are synced for podmonitors"}

Documentation:
N/A

@davidhaja davidhaja marked this pull request as ready for review August 29, 2024 21:18
@davidhaja davidhaja requested review from a team August 29, 2024 21:18
@jaronoff97 jaronoff97 requested a review from swiatekm August 30, 2024 15:06
@swiatekm swiatekm merged commit 629aed5 into open-telemetry:main Sep 3, 2024
33 checks passed
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.

Temporary network issue causes Target Allocator to stuck
3 participants