Skip to content

Commit

Permalink
Tweak check id and output (hashicorp#388)
Browse files Browse the repository at this point in the history
* Changed success output from title case "Kubernetes Health Checks
Passing" to sentence case "Kubernetes health checks passing" to match
other built-in check outputs.
* Removed -ttl from end of check id because the type of check doesn't
matter for users and is listed as a separate field in the API responses.
* Changed check id to use namespace/service-id instead of
namespace_service-id to match Consul and Kube's regular formats
* Changed service-id_kubernetes-health-check to
service_id/kubernetes-health-check for purely asthetic reasons: clashing
_ and -'s looks jarring.
  • Loading branch information
lkysow authored Nov 11, 2020
1 parent 2b86fdd commit 25e0484
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions connect-inject/health_check_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
labelInject = "consul.hashicorp.com/connect-inject-status"

// kubernetesSuccessReasonMsg will be passed for passing health check's Reason to Consul.
kubernetesSuccessReasonMsg = "Kubernetes Health Checks Passing"
kubernetesSuccessReasonMsg = "Kubernetes health checks passing"

podPendingReasonMsg = "Pod is pending"
)
Expand Down Expand Up @@ -332,7 +332,7 @@ func (h *HealthCheckResource) shouldProcess(pod *corev1.Pod) bool {
// getConsulHealthCheckID deterministically generates a health check ID that will be unique to the Agent
// where the health check is registered and deregistered.
func (h *HealthCheckResource) getConsulHealthCheckID(pod *corev1.Pod) string {
return fmt.Sprintf("%s_%s_kubernetes-health-check-ttl", pod.Namespace, h.getConsulServiceID(pod))
return fmt.Sprintf("%s/%s/kubernetes-health-check", pod.Namespace, h.getConsulServiceID(pod))
}

// getConsulServiceID returns the serviceID of the connect service.
Expand Down
4 changes: 2 additions & 2 deletions connect-inject/health_check_resource_ent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (

const (
testNamespace = "testnamespace"
testNamespacedHealthCheckID = "testnamespace_test-pod-test-service_kubernetes-health-check-ttl"
testNamespacedHealthCheckID = "testnamespace/test-pod-test-service/kubernetes-health-check"

testAlternateNamespace = "testalternatenamespace"
testAlternateNamespacedHealthCheckID = "testalternatenamespace_test-pod-test-service_kubernetes-health-check-ttl"
testAlternateNamespacedHealthCheckID = "testalternatenamespace/test-pod-test-service/kubernetes-health-check"
)

var ignoredFieldsEnterprise = []string{"Node", "Definition", "ServiceID", "ServiceName"}
Expand Down
4 changes: 2 additions & 2 deletions connect-inject/health_check_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const (
testPodName = "test-pod"
testServiceNameAnnotation = "test-service"
testServiceNameReg = "test-pod-test-service"
testHealthCheckID = "default_test-pod-test-service_kubernetes-health-check-ttl"
testHealthCheckID = "default/test-pod-test-service/kubernetes-health-check"
testFailureMessage = "Kubernetes pod readiness probe failed"
testCheckNotesPassing = "Kubernetes Health Checks Passing"
testCheckNotesPassing = "Kubernetes health checks passing"
ttl = "ttl"
name = "Kubernetes Health Check"
)
Expand Down

0 comments on commit 25e0484

Please sign in to comment.