Skip to content

Commit

Permalink
fix(operator): payments health checks (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag authored Feb 7, 2024
1 parent 2d190ba commit 3ca0ded
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type GatewayHTTPAPISpec struct {
Name string `json:"name"`
// Rules
Rules []GatewayHTTPAPIRule `json:"rules"`
// Health check endpoint
HealthCheckEndpoint string `json:"healthCheckEndpoint,omitempty"`
}

// GatewayHTTPAPIStatus defines the observed state of GatewayHTTPAPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
spec:
description: GatewayHTTPAPISpec defines the desired state of GatewayHTTPAPI
properties:
healthCheckEndpoint:
description: Health check endpoint
type: string
name:
description: Name indicates prefix api
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func WithRules(rules ...v1beta1.GatewayHTTPAPIRule) func(httpapi *v1beta1.Gatewa
}
}

func WithHealthCheckEndpoint(v string) func(httpapi *v1beta1.GatewayHTTPAPI) {
return func(httpapi *v1beta1.GatewayHTTPAPI) {
httpapi.Spec.HealthCheckEndpoint = v
}
}

func RuleSecured() v1beta1.GatewayHTTPAPIRule {
return v1beta1.GatewayHTTPAPIRule{}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,17 @@
env "{{ .Platform.Environment }}"
endpoints {
{{- range $i, $service := .Services }}
{{- $healthCheckEndpoint := $service.HealthCheckEndpoint }}
{{- if eq $healthCheckEndpoint "" }}
{{- $healthCheckEndpoint = "_healthcheck" }}
{{- end }}

{{- if or (not (semver_is_valid $values.Gateway.Version)) (gt (semver_compare $values.Gateway.Version "v0.1.7") 0) }}
{{ $service.Name }} {
http://{{ $service.Name }}:8080/_info http://{{ $service.Name }}:8080/_healthcheck
http://{{ $service.Name }}:8080/_info http://{{ $service.Name }}:8080/{{ $service.HealthCheckEndpoint }}
}
{{- else }}
{{ $service.Name }} http://{{ $service.Name }}:8080/_info http://{{ $service.Name }}:8080/_healthcheck
{{ $service.Name }} http://{{ $service.Name }}:8080/_info http://{{ $service.Name }}:8080/{{ $service.HealthCheckEndpoint }}
{{- end }}
{{- end }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func Reconcile(ctx Context, stack *v1beta1.Stack, p *v1beta1.Payments, version s
}

if err := gatewayhttpapis.Create(ctx, p,
gatewayhttpapis.WithHealthCheckEndpoint("_health"),
gatewayhttpapis.WithRules(
v1beta1.GatewayHTTPAPIRule{
Path: "/connectors/webhooks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
env "staging"
endpoints {
ledger {
http://ledger:8080/_info http://ledger:8080/_healthcheck
http://ledger:8080/_info http://ledger:8080/
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
env "staging"
endpoints {
another {
http://another:8080/_info http://another:8080/_healthcheck
http://another:8080/_info http://another:8080/
}
ledger {
http://ledger:8080/_info http://ledger:8080/_healthcheck
http://ledger:8080/_info http://ledger:8080/
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
env "staging"
endpoints {
auth {
http://auth:8080/_info http://auth:8080/_healthcheck
http://auth:8080/_info http://auth:8080/
}
ledger {
http://ledger:8080/_info http://ledger:8080/_healthcheck
http://ledger:8080/_info http://ledger:8080/
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
env "staging"
endpoints {
ledger {
http://ledger:8080/_info http://ledger:8080/_healthcheck
http://ledger:8080/_info http://ledger:8080/
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
env "staging"
endpoints {
ledger {
http://ledger:8080/_info http://ledger:8080/_healthcheck
http://ledger:8080/_info http://ledger:8080/
}

}
Expand Down

0 comments on commit 3ca0ded

Please sign in to comment.