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

Noisy errors in leader election lease type registration in scheme #2378

Closed
ahmetb opened this issue Jun 13, 2023 · 5 comments · Fixed by #2461
Closed

Noisy errors in leader election lease type registration in scheme #2378

ahmetb opened this issue Jun 13, 2023 · 5 comments · Fixed by #2461
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@ahmetb
Copy link
Member

ahmetb commented Jun 13, 2023

Version: v0.7.2.

I have a controller where I don't have corev1 (ConfigMap) or coordinationv1 (Lease) packages registered to the scheme. When the controller starts up with leader election enabled with fairly standard settings, it:

  1. successfully chooses a leader (ConfigMap and Lease are written)
  2. logs two errors saying no kind is registered for the type v1.ConfigMap in scheme (or ...v1.Lease...)

Assuming these errors are rather harmless as the program functions, and adding this fixes the problem:

utilruntime.Must(corev1.AddToScheme(scheme))         // for leader election
utilruntime.Must(coordinationv1.AddToScheme(scheme)) // for leader election

I wonder if enabling the leader election should automatically add these types to the scheme?


Manager configuration

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: "0", SyncPeriod: flResyncPeriod, LeaderElection: *flEnableLeaderElection, LeaderElectionNamespace: *flLeaderElectionLockNamespace, LeaderElectionID: *flLeaderElectionLockName, })

Full error:

E0612 21:30:48.450282   47012 event.go:329] Could not construct reference to:
'&v1.ConfigMap{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""},
ObjectMeta:v1.ObjectMeta{Name:"k8s-compute-broker-controller-leader-lock",
GenerateName:"", Namespace:"default", SelfLink:"",
UID:"c0727f74-a2e1-47c0-8a27-fbb465d88d4e", ResourceVersion:"801935",
Generation:0, CreationTimestamp:time.Date(2023, time.June, 12, 21, 29, 42, 0,
time.Local), DeletionTimestamp:<nil>, DeletionGracePeriodSeconds:(*int64)(nil),
Labels:map[string]string(nil),
Annotations:map[string]string{"control-plane.alpha.kubernetes.io/leader":"{\"holderIdentity\":\"abalkan-mn1.linkedin.biz_df1eb292-8854-4561-a387-92299cad42aa\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2023-06-13T04:30:48Z\",\"renewTime\":\"2023-06-13T04:30:48Z\",\"leaderTransitions\":1}"},
OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil),
ClusterName:"",
ManagedFields:[]v1.ManagedFieldsEntry{v1.ManagedFieldsEntry{Manager:"cmd",
Operation:"Update", APIVersion:"v1", Time:time.Date(2023, time.June, 12, 21, 30,
48, 0, time.Local), FieldsType:"FieldsV1",
FieldsV1:(*v1.FieldsV1)(0xc00035c468)}}}, Immutable:(*bool)(nil),
Data:map[string]string(nil), BinaryData:map[string][]uint8(nil)}' due to: 'no
kind is registered for the type v1.ConfigMap in scheme
"pkg/runtime/scheme.go:101"'. Will not report event: 'Normal' 'LeaderElection'
'abalkan-mn1.linkedin.biz_df1eb292-8854-4561-a387-92299cad42aa became leader'

E0612 21:30:48.451094   47012 event.go:329] Could not construct reference to:
'&v1.Lease{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""},
ObjectMeta:v1.ObjectMeta{Name:"k8s-compute-broker-controller-leader-lock",
GenerateName:"", Namespace:"default", SelfLink:"",
UID:"d565c0f3-33cc-4c4f-90af-6b932a99136a", ResourceVersion:"801936",
Generation:0, CreationTimestamp:time.Date(2023, time.June, 12, 21, 29, 42, 0,
time.Local), DeletionTimestamp:<nil>, DeletionGracePeriodSeconds:(*int64)(nil),
Labels:map[string]string(nil), Annotations:map[string]string(nil),
OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil),
ClusterName:"",
ManagedFields:[]v1.ManagedFieldsEntry{v1.ManagedFieldsEntry{Manager:"cmd",
Operation:"Update", APIVersion:"coordination.k8s.io/v1", Time:time.Date(2023,
time.June, 12, 21, 30, 48, 0, time.Local), FieldsType:"FieldsV1",
FieldsV1:(*v1.FieldsV1)(0xc00035c9f0)}}},
Spec:v1.LeaseSpec{HolderIdentity:(*string)(nil),
LeaseDurationSeconds:(*int32)(nil), AcquireTime:<nil>, RenewTime:<nil>,
LeaseTransitions:(*int32)(nil)}}' due to: 'no kind is registered for the type
v1.Lease in scheme "pkg/runtime/scheme.go:101"'. Will not report event: 'Normal'
'LeaderElection' 'abalkan-mn1.linkedin.biz_df1eb292-8854-4561-a387-92299cad42aa
became leader'
@vincepri
Copy link
Member

Adding the types by default sounds like a good improvement?

wdyt @alvaroaleman

@alvaroaleman
Copy link
Member

Yeah, adding these when leader election is enabled or using a distinct leader election scheme with these two makes sense

@sbueringer
Copy link
Member

Sounds fine

@troy0820
Copy link
Member

/kind feature

Has this been added by default? Are we planning on registering k8s.io/client-go/kubernetes/scheme on all cases or leave this up to the user?

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 25, 2023
@sbueringer
Copy link
Member

Hasn't been done yet. I think Alvaro's suggestion sounds fine. Especially now that the leader election lib we use only supports leases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
6 participants