@@ -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.
5556func (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