@@ -461,7 +461,14 @@ func buildXdsCluster(args *xdsClusterArgs) (*buildClusterResult, error) {
461461 }
462462
463463 if args .healthCheck != nil && args .healthCheck .Active != nil {
464- cluster .HealthChecks = buildXdsHealthCheck (args .healthCheck .Active , args .routeHostname , args .healthCheckLog )
464+ if args .healthCheckLog != nil && args .healthCheck .Active .EventLog == nil {
465+ args .healthCheck .Active .EventLog = args .healthCheckLog
466+ }
467+ hcs , err := buildXdsHealthCheck (args .healthCheck .Active , args .routeHostname )
468+ if err != nil {
469+ return nil , err
470+ }
471+ cluster .HealthChecks = hcs
465472 }
466473
467474 if args .healthCheck != nil && args .healthCheck .Passive != nil {
@@ -581,7 +588,7 @@ func buildZoneAwareLbConfig(preferLocal *ir.PreferLocalZone) *commonv3.LocalityL
581588 return lbConfig
582589}
583590
584- func buildXdsHealthCheck (healthcheck * ir.ActiveHealthCheck , routeHostname string , healthCheckLogging * ir. ProxyHealthCheckLog ) []* corev3.HealthCheck {
591+ func buildXdsHealthCheck (healthcheck * ir.ActiveHealthCheck , routeHostname string ) ( []* corev3.HealthCheck , error ) {
585592 hc := & corev3.HealthCheck {
586593 Timeout : durationpb .New (healthcheck .Timeout .Duration ),
587594 Interval : durationpb .New (healthcheck .Interval .Duration ),
@@ -633,23 +640,24 @@ func buildXdsHealthCheck(healthcheck *ir.ActiveHealthCheck, routeHostname string
633640 }
634641 }
635642
636- if healthCheckLogging != nil {
643+ if healthCheckLogging := healthcheck . EventLog ; healthCheckLogging != nil {
637644 hc .AlwaysLogHealthCheckFailures = healthCheckLogging .AlwaysLogHealthCheckFailures
638645 hc .AlwaysLogHealthCheckSuccess = healthCheckLogging .AlwaysLogHealthCheckSuccess
639646 for _ , fs := range healthCheckLogging .FileSinks {
640647 fileSinkAny , err := proto .ToAnyWithValidation (& hcfilev3.HealthCheckEventFileSink {
641648 EventLogPath : fs .Path ,
642649 })
643- if err == nil {
644- hc .EventLogger = append (hc .EventLogger , & corev3.TypedExtensionConfig {
645- Name : "envoy.health_check.event_sinks.file" ,
646- TypedConfig : fileSinkAny ,
647- })
650+ if err != nil {
651+ return nil , err
648652 }
653+ hc .EventLogger = append (hc .EventLogger , & corev3.TypedExtensionConfig {
654+ Name : "envoy.health_check.event_sinks.file" ,
655+ TypedConfig : fileSinkAny ,
656+ })
649657 }
650658 }
651659
652- return []* corev3.HealthCheck {hc }
660+ return []* corev3.HealthCheck {hc }, nil
653661}
654662
655663func httpHealthCheckHost (healthcheck * ir.HTTPHealthChecker , routeHostname string ) string {
0 commit comments