File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
pkg/kubelet/cm/devicemanager/plugin/v1beta1 Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -57,8 +57,8 @@ type server struct {
5757 chandler ClientHandler
5858 clients map [string ]Client
5959
60- // isStarted indicates whether the service has started successfully .
61- isStarted bool
60+ // lastError records the last runtime error. A server is considered healthy till an actual error occurs .
61+ lastError error
6262}
6363
6464// NewServer returns an initialized device plugin registration server.
@@ -117,7 +117,7 @@ func (s *server) Start() error {
117117 defer s .wg .Done ()
118118 s .setHealthy ()
119119 if err = s .grpc .Serve (ln ); err != nil {
120- s .setUnhealthy ()
120+ s .setUnhealthy (err )
121121 klog .ErrorS (err , "Error while serving device plugin registration grpc server" )
122122 }
123123 }()
@@ -208,18 +208,19 @@ func (s *server) Name() string {
208208}
209209
210210func (s * server ) Check (_ * http.Request ) error {
211- if s .isStarted {
212- return nil
213- }
214- return fmt .Errorf ("device plugin registration gRPC server failed and no device plugins can register" )
211+ return s .lastError
215212}
216213
217214// setHealthy sets the health status of the gRPC server.
218215func (s * server ) setHealthy () {
219- s .isStarted = true
216+ s .lastError = nil
220217}
221218
222219// setUnhealthy sets the health status of the gRPC server to unhealthy.
223- func (s * server ) setUnhealthy () {
224- s .isStarted = false
220+ func (s * server ) setUnhealthy (err error ) {
221+ if err == nil {
222+ s .lastError = fmt .Errorf ("device registration error: device plugin registration gRPC server failed and no device plugins can register" )
223+ return
224+ }
225+ s .lastError = fmt .Errorf ("device registration error: device plugin registration gRPC server failed and no device plugins can register: %w" , err )
225226}
You can’t perform that action at this time.
0 commit comments