@@ -60,6 +60,7 @@ import (
60
60
"github.com/avast/retry-go/v4"
61
61
"github.com/pkg/errors"
62
62
"go.uber.org/zap"
63
+ "go.uber.org/zap/zapcore"
63
64
corev1 "k8s.io/api/core/v1"
64
65
apierrors "k8s.io/apimachinery/pkg/api/errors"
65
66
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -579,9 +580,24 @@ func main() {
579
580
}
580
581
}
581
582
582
- // start the health server
583
- z , _ := zap .NewProduction ()
584
- go healthserver .Start (z , cnsconfig .MetricsBindAddress )
583
+ // configure zap logger
584
+ zconfig := zap .NewProductionConfig ()
585
+ zconfig .EncoderConfig .EncodeTime = zapcore .ISO8601TimeEncoder
586
+ z , _ := zconfig .Build ()
587
+
588
+ // start the healthz/readyz/metrics server
589
+ readyCh := make (chan interface {})
590
+ readyChecker := healthz.CheckHandler {
591
+ Checker : healthz .Checker (func (* http.Request ) error {
592
+ select {
593
+ default :
594
+ return errors .New ("not ready" )
595
+ case <- readyCh :
596
+ }
597
+ return nil
598
+ }),
599
+ }
600
+ go healthserver .Start (z , cnsconfig .MetricsBindAddress , & healthz.Handler {}, readyChecker )
585
601
586
602
nmaConfig , err := nmagent .NewConfig (cnsconfig .WireserverIP )
587
603
if err != nil {
@@ -953,6 +969,8 @@ func main() {
953
969
}
954
970
}
955
971
972
+ // mark the service as "ready"
973
+ close (readyCh )
956
974
// block until process exiting
957
975
<- rootCtx .Done ()
958
976
@@ -1353,13 +1371,6 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn
1353
1371
httpRestService .AttachSWIFTv2Middleware (& swiftV2Middleware )
1354
1372
}
1355
1373
1356
- // adding some routes to the root service mux
1357
- mux := httpRestServiceImplementation .Listener .GetMux ()
1358
- mux .Handle ("/readyz" , http .StripPrefix ("/readyz" , & healthz.Handler {}))
1359
- if cnsconfig .EnablePprof {
1360
- httpRestServiceImplementation .RegisterPProfEndpoints ()
1361
- }
1362
-
1363
1374
// start the pool Monitor before the Reconciler, since it needs to be ready to receive an
1364
1375
// NodeNetworkConfig update by the time the Reconciler tries to send it.
1365
1376
go func () {
0 commit comments