Skip to content

Commit 3a489db

Browse files
Merge pull request #133335 from bart0sh/PR190-pluginmanager-fix-handling-registration-failures
pluginmanager: fix handling registration failures Kubernetes-commit: 4c221cdc56dbbc7894a8e887ace55adc59ba01ba
2 parents 62d6f98 + d46d4d0 commit 3a489db

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
google.golang.org/grpc v1.78.0
1818
k8s.io/api v0.0.0-20260121173914-4f90c5e5fa65
1919
k8s.io/apimachinery v0.0.0-20260116132332-7daad7080a68
20-
k8s.io/apiserver v0.0.0-20260122215736-528201103034
20+
k8s.io/apiserver v0.0.0-20260123015717-e0f83e2d57c6
2121
k8s.io/client-go v0.0.0-20260122054906-c5e14be2544b
2222
k8s.io/component-helpers v0.0.0-20260121215637-bbdf51ab47cf
2323
k8s.io/klog/v2 v2.130.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ k8s.io/api v0.0.0-20260121173914-4f90c5e5fa65 h1:sQVbR3zcjPhnrkpWG5M6Qh6uQsBNvz7
180180
k8s.io/api v0.0.0-20260121173914-4f90c5e5fa65/go.mod h1:lmMnF2Ji6ZiKusBzdQOW0tLYy+bzNudofBpUXjn0Wm4=
181181
k8s.io/apimachinery v0.0.0-20260116132332-7daad7080a68 h1:Bu0nqDkpfRZ7fngY4VoyqtKhbqD4lnOU6ybw5SVGIEY=
182182
k8s.io/apimachinery v0.0.0-20260116132332-7daad7080a68/go.mod h1:wAmXZO6lPjbtt+U0gil0pnpZcEaspEmhvj1KBBRrJpI=
183-
k8s.io/apiserver v0.0.0-20260122215736-528201103034 h1:xK2/ZU3B1MeeAEOZ/1I9rQLXZfDo3x3enJ4JMzq7I3I=
184-
k8s.io/apiserver v0.0.0-20260122215736-528201103034/go.mod h1:4hYEf/eOX1avD6gJTpSKUs9IBMDQXlunybU2sRr1jkg=
183+
k8s.io/apiserver v0.0.0-20260123015717-e0f83e2d57c6 h1:ANsuBM621U8/OTMX23uBqu2369BQk4rKSXd5wK6She8=
184+
k8s.io/apiserver v0.0.0-20260123015717-e0f83e2d57c6/go.mod h1:4hYEf/eOX1avD6gJTpSKUs9IBMDQXlunybU2sRr1jkg=
185185
k8s.io/client-go v0.0.0-20260122054906-c5e14be2544b h1:zI4ODWEtDFt8+ZnssokmcC3dFjLWOkBAIqpQAj7mHXY=
186186
k8s.io/client-go v0.0.0-20260122054906-c5e14be2544b/go.mod h1:pdvr6B9BEfiVeGrGa2kMFrDb4ZT3WDge8/VdoAwqk8E=
187187
k8s.io/component-base v0.0.0-20260121215457-64859b30d921 h1:AbwLfiPxZH5XIH+iLUFwjM4HaNlW8HOx0hJkaYaHV9w=

kubeletplugin/draplugin.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,13 @@ func (d *Helper) SetGetInfoError(err error) {
815815
d.registrar.setGetInfoError(err)
816816
}
817817

818+
// SetNotifyRegistrationStatusError configures the registration server
819+
// to make NotifyRegistrationStatus calls return the specified error.
820+
// To restore normal behavior, call SetNotifyRegistrationStatusError(nil).
821+
func (d *Helper) SetNotifyRegistrationStatusError(err error) {
822+
d.registrar.setNotifyRegistrationStatusError(err)
823+
}
824+
818825
// serializeGRPCIfEnabled locks a mutex if serialization is enabled.
819826
// Either way it returns a method that the caller must invoke
820827
// via defer.

kubeletplugin/registrationserver.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ type registrationServer struct {
3131
supportedVersions []string
3232
status *registerapi.RegistrationStatus
3333

34-
getInfoError atomic.Pointer[error]
34+
getInfoError atomic.Pointer[error]
35+
notifyRegistrationStatusError atomic.Pointer[error]
3536

3637
registerapi.UnsafeRegistrationServer
3738
}
@@ -53,6 +54,9 @@ func (e *registrationServer) GetInfo(ctx context.Context, req *registerapi.InfoR
5354

5455
// NotifyRegistrationStatus is the RPC invoked by plugin watcher.
5556
func (e *registrationServer) NotifyRegistrationStatus(ctx context.Context, status *registerapi.RegistrationStatus) (*registerapi.RegistrationStatusResponse, error) {
57+
if err := e.getNotifyRegistrationStatusError(); err != nil {
58+
return nil, err
59+
}
5660
e.status = status
5761
if !status.PluginRegistered {
5862
return nil, fmt.Errorf("failed registration process: %+v", status.Error)
@@ -69,6 +73,14 @@ func (e *registrationServer) getGetInfoError() error {
6973
return *errPtr
7074
}
7175

76+
func (e *registrationServer) getNotifyRegistrationStatusError() error {
77+
errPtr := e.notifyRegistrationStatusError.Load()
78+
if errPtr == nil {
79+
return nil
80+
}
81+
return *errPtr
82+
}
83+
7284
// setGetInfoError sets the error to be returned by the GetInfo handler of the registration server.
7385
// If a non-nil error is provided, subsequent GetInfo calls will return this error.
7486
// Passing nil as the err argument will clear any previously set error, effectively disabling erroring.
@@ -79,3 +91,15 @@ func (e *registrationServer) setGetInfoError(err error) {
7991
}
8092
e.getInfoError.Store(&err)
8193
}
94+
95+
// setNotifyRegistrationStatusError sets the error to be returned by the NotifyRegistrationStatus handler
96+
// of the registration server.
97+
// If a non-nil error is provided, subsequent NotifyRegistrationStatus calls will return this error.
98+
// Passing nil as the err argument will clear any previously set error, effectively disabling erroring.
99+
func (e *registrationServer) setNotifyRegistrationStatusError(err error) {
100+
if err == nil {
101+
e.notifyRegistrationStatusError.Store(nil)
102+
return
103+
}
104+
e.notifyRegistrationStatusError.Store(&err)
105+
}

0 commit comments

Comments
 (0)