MCPcopy
hub / github.com/istio/istio / Start

Method Start

pilot/pkg/bootstrap/server.go:468–530  ·  view source on GitHub ↗

Start starts all components of the error serving tap http serverPilot discovery service on the port specified in DiscoveryServerOptions. If Port == 0, a port number is automatically chosen. Content serving is started by this method, but is executed asynchronously. Serving can be canceled at any time

(stop <-chan struct{})

Source from the content-addressed store, hash-verified

466// If Port == 0, a port number is automatically chosen. Content serving is started by this method,
467// but is executed asynchronously. Serving can be canceled at any time by closing the provided stop channel.
468func (s *Server) Start(stop <-chan struct{}) error {
469 log.Infof("Starting Istiod Server with primary cluster %s", s.clusterID)
470
471 if features.UnsafeFeaturesEnabled() {
472 log.Warn("Server is starting with unsafe features enabled")
473 }
474
475 // Now start all of the components.
476 if err := s.server.Start(stop); err != nil {
477 return err
478 }
479 if !s.waitForCacheSync(stop) {
480 return fmt.Errorf("failed to sync cache")
481 }
482 // Inform Discovery Server so that it can start accepting connections.
483 s.XDSServer.CachesSynced()
484
485 // Race condition - if waitForCache is too fast and we run this as a startup function,
486 // the grpc server would be started before CA is registered. Listening should be last.
487 if s.secureGrpcAddress != "" {
488 grpcListener, err := net.Listen("tcp", s.secureGrpcAddress)
489 if err != nil {
490 return err
491 }
492 go func() {
493 log.Infof("starting secure gRPC discovery service at %s", grpcListener.Addr())
494 if err := s.secureGrpcServer.Serve(grpcListener); err != nil {
495 log.Errorf("error serving secure GRPC server: %v", err)
496 }
497 }()
498 }
499
500 if s.grpcAddress != "" {
501 grpcListener, err := net.Listen("tcp", s.grpcAddress)
502 if err != nil {
503 return err
504 }
505 go func() {
506 log.Infof("starting gRPC discovery service at %s", grpcListener.Addr())
507 if err := s.grpcServer.Serve(grpcListener); err != nil {
508 log.Errorf("error serving GRPC server: %v", err)
509 }
510 }()
511 }
512
513 if s.httpsServer != nil {
514 httpsListener, err := net.Listen("tcp", s.httpsServer.Addr)
515 if err != nil {
516 return err
517 }
518 go func() {
519 log.Infof("starting webhook service at %s", httpsListener.Addr())
520 if err := s.httpsServer.ServeTLS(httpsListener, "", ""); network.IsUnexpectedListenerError(err) {
521 log.Errorf("error serving https server: %v", err)
522 }
523 }()
524 s.httpsAddr = httpsListener.Addr().String()
525 }

Callers 7

TestNewServerCertInitFunction · 0.95
TestNewServerFunction · 0.95
TestMultiplexFunction · 0.95
TestIstiodCipherSuitesFunction · 0.95
TestIstiodMinTLSVersionFunction · 0.95
newDiscoveryCommandFunction · 0.95

Calls 13

waitForCacheSyncMethod · 0.95
waitForShutdownMethod · 0.95
InfofFunction · 0.92
UnsafeFeaturesEnabledFunction · 0.92
WarnFunction · 0.92
ErrorfFunction · 0.92
CachesSyncedMethod · 0.80
ListenMethod · 0.80
ServeMethod · 0.80
StartMethod · 0.65
ErrorfMethod · 0.65

Tested by 6

TestNewServerCertInitFunction · 0.76
TestNewServerFunction · 0.76
TestMultiplexFunction · 0.76
TestIstiodCipherSuitesFunction · 0.76
TestIstiodMinTLSVersionFunction · 0.76