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

LeaderElector does not write logs or exceptions during failure #1390

Closed
vrnmthr opened this issue Sep 3, 2023 · 3 comments
Closed

LeaderElector does not write logs or exceptions during failure #1390

vrnmthr opened this issue Sep 3, 2023 · 3 comments

Comments

@vrnmthr
Copy link

vrnmthr commented Sep 3, 2023

Describe the bug
I was using the LeaderElector with a LeaseLock, but failed to set RBAC on my app to create/read leases (this is not present in the default service account). This means that this piece of code was failing, probably with a different HttpStatusCode. The end result is that the LeaderElector basically "does nothing" infinitely, with no logs and no exception thrown.

LeaderElectionRecord oldLeaderElectionRecord = null;
            try
            {
                oldLeaderElectionRecord = await l.GetAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (HttpOperationException e)
            {
                if (e.Response.StatusCode != HttpStatusCode.NotFound)
                {
                    return false;
                }
            }

This is not intuitive behavior, and since there is no documentation for this that includes how to setup RBAC, it makes debugging issues difficult.

Kubernetes C# SDK Client Version
11.0.44

Server Kubernetes Version
e.g. 1.21

Dotnet Runtime Version
net6

To Reproduce
Start leader elector without required RBAC in a cluster

Expected behavior
Either log error, or throw exception

KubeConfig
If applicable, add a KubeConfig file with secrets redacted.

Where do you run your app with Kubernetes SDK (please complete the following information):

  • OS: Linux
  • Environment: Container
  • Cloud: Azure

Additional context
Add any other context about the problem here.

@tg123
Copy link
Member

tg123 commented Sep 4, 2023

throw for other 4xx error?

@mmihalikcs
Copy link

mmihalikcs commented Sep 11, 2023

I believe im running into the same issue and attempting to use the following RBAC, but doesnt seem to be working:

`Name: expense-dev-leases
Labels: app=expense
app.kubernetes.io/instance=-dev
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=
app.kubernetes.io/version=1.0.0
helm.sh/chart=expense-0.1.1
Annotations: meta.helm.sh/release-name: -dev
meta.helm.sh/release-namespace:
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs


leases.coordination.k8s.io [] [] [*]`

@tg123
Copy link
Member

tg123 commented Sep 11, 2023

hope onerr callback helps
currently, no logger defined in sdk

@tg123 tg123 closed this as completed Sep 14, 2023
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

No branches or pull requests

3 participants