diff --git a/internal/manifests/collector/adapters/config_to_probe.go b/internal/manifests/collector/adapters/config_to_probe.go index 897b7db068..26fa99a4d9 100644 --- a/internal/manifests/collector/adapters/config_to_probe.go +++ b/internal/manifests/collector/adapters/config_to_probe.go @@ -44,6 +44,7 @@ type probeConfiguration struct { const ( defaultHealthCheckPath = "/" + defaultHealthCheckV2Path = "/health/status" defaultHealthCheckPort = 13133 ) @@ -70,7 +71,7 @@ func ConfigToContainerProbe(config map[interface{}]interface{}) (*corev1.Probe, healthCheckServiceExtensions := make([]string, 0) for _, ext := range serviceExtensions { parsedExt, ok := ext.(string) - if ok && strings.HasPrefix(parsedExt, "health_check") { + if ok && (strings.HasPrefix(parsedExt, "health_check") || strings.HasPrefix(parsedExt, "healthcheckv2")) { healthCheckServiceExtensions = append(healthCheckServiceExtensions, parsedExt) } } @@ -91,15 +92,15 @@ func ConfigToContainerProbe(config map[interface{}]interface{}) (*corev1.Probe, for _, healthCheckForProbe := range healthCheckServiceExtensions { healthCheckExtension, ok := extensions[healthCheckForProbe] if ok { - return createProbeFromExtension(healthCheckExtension) + return createProbeFromExtension(healthCheckForProbe, healthCheckExtension) } } return nil, errNoExtensionHealthCheck } -func createProbeFromExtension(extension interface{}) (*corev1.Probe, error) { - probeCfg := extractProbeConfigurationFromExtension(extension) +func createProbeFromExtension(name string, extension interface{}) (*corev1.Probe, error) { + probeCfg := extractProbeConfigurationFromExtension(name, extension) return &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ @@ -110,38 +111,70 @@ func createProbeFromExtension(extension interface{}) (*corev1.Probe, error) { }, nil } -func extractProbeConfigurationFromExtension(ext interface{}) probeConfiguration { +func extractProbeConfigurationFromExtension(name string, ext interface{}) probeConfiguration { extensionCfg, ok := ext.(map[interface{}]interface{}) if !ok { - return defaultProbeConfiguration() + return defaultProbeConfiguration(name) } return probeConfiguration{ - path: extractPathFromExtensionConfig(extensionCfg), - port: extractPortFromExtensionConfig(extensionCfg), + path: extractPathFromExtensionConfig(name, extensionCfg), + port: extractPortFromExtensionConfig(name, extensionCfg), } } -func defaultProbeConfiguration() probeConfiguration { +func defaultProbeConfiguration(name string) probeConfiguration { + var path string + if strings.HasPrefix(name, "healthcheckv2") { + path = defaultHealthCheckV2Path + } else { + path = defaultHealthCheckPath + } return probeConfiguration{ - path: defaultHealthCheckPath, + path: path, port: intstr.FromInt(defaultHealthCheckPort), } } -func extractPathFromExtensionConfig(cfg map[interface{}]interface{}) string { - if path, ok := cfg["path"]; ok { - if parsedPath, ok := path.(string); ok { - return parsedPath +func extractPathFromExtensionConfig(name string, cfg map[interface{}]interface{}) string { + if strings.HasPrefix(name, "healthcheckv2") { + if http, ok := cfg["http"].(map[interface{}]interface{}); ok { + if status, ok := http["status"].(map[interface{}]interface{}); ok { + if path, ok := status["path"]; ok { + if parsedPath, ok := path.(string); ok { + return parsedPath + } + } + } + } + return defaultHealthCheckV2Path + } else { + if path, ok := cfg["path"]; ok { + if parsedPath, ok := path.(string); ok { + return parsedPath + } } + return defaultHealthCheckPath } - return defaultHealthCheckPath } -func extractPortFromExtensionConfig(cfg map[interface{}]interface{}) intstr.IntOrString { - endpoint, ok := cfg["endpoint"] - if !ok { - return defaultHealthCheckEndpoint() +func extractPortFromExtensionConfig(name string, cfg map[interface{}]interface{}) intstr.IntOrString { + var endpoint interface{} + if strings.HasPrefix(name, "healthcheckv2") { + if http, ok := cfg["http"].(map[interface{}]interface{}); ok { + ep, ok := http["endpoint"] + if !ok { + return defaultHealthCheckEndpoint() + } + endpoint = ep + } + } else { + ep, ok := cfg["endpoint"] + if !ok { + return defaultHealthCheckEndpoint() + } + endpoint = ep } + parsedEndpoint, ok := endpoint.(string) if !ok { return defaultHealthCheckEndpoint() diff --git a/tests/e2e/high-availability-rollout/00-install-collector.yaml b/tests/e2e/high-availability-rollout/00-install-collector.yaml index d893ffe9ad..c422065ece 100644 --- a/tests/e2e/high-availability-rollout/00-install-collector.yaml +++ b/tests/e2e/high-availability-rollout/00-install-collector.yaml @@ -5,17 +5,34 @@ metadata: spec: mode: ($mode) replicas: 2 + #image: :healthcheckv2 # lifecycle: # preStop: # exec: # command: # - sleep -# - '3' # - '1' config: | extensions: - health_check: - endpoint: ${POD_IP}:13133 + #health_check: + # endpoint: ${POD_IP}:13133 + healthcheckv2: + use_v2: true + component_health: + include_permanent_errors: false + include_recoverable_errors: true + recovery_duration: 5m + http: + endpoint: "${POD_IP}:13133" + status: + enabled: true + path: "/health/status" + config: + enabled: true + path: "/health/config" + grpc: + endpoint: "${POD_IP}:13132" + transport: "tcp" receivers: otlp: protocols: @@ -28,7 +45,8 @@ spec: service: extensions: - - health_check + #- health_check + - healthcheckv2 pipelines: traces: receivers: [otlp]