Skip to content

Commit

Permalink
[registry-facade] Split off port for readiness probe
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel committed May 3, 2022
1 parent 2037329 commit 9b105e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/blobserve/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ var runCmd = &cobra.Command{
// Ensure we can resolve DNS queries, and can access the registry host
health := healthcheck.NewHandler()
health.AddReadinessCheck("dns", kubernetes.DNSCanResolveProbe(staticLayerHost, 1*time.Second))
health.AddReadinessCheck("registry", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("http://%v", repository)))
health.AddReadinessCheck("registry", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("https://%v", repository)))

go func() {
if err := http.ListenAndServe(cfg.ReadinessProbeAddr, health); err != nil && err != http.ErrServerClosed {
Expand Down
4 changes: 4 additions & 0 deletions components/common-go/kubernetes/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"net"
"net/http"
"strings"
"time"

"github.com/gitpod-io/gitpod/common-go/log"
Expand Down Expand Up @@ -49,6 +50,9 @@ func NetworkIsReachableProbe(url string) func() error {
func DNSCanResolveProbe(host string, timeout time.Duration) func() error {
log.Infof("creating DNS check for host %v", host)

// remove port if there is one
host = strings.Split(host, ":")[0]

resolver := net.Resolver{}
return func() error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
Expand Down
4 changes: 2 additions & 2 deletions components/registry-facade/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ var runCmd = &cobra.Command{
// Ensure we can resolve DNS queries, and can access the registry host
health := healthcheck.NewHandler()
health.AddReadinessCheck("dns", kubernetes.DNSCanResolveProbe(staticLayerHost, 1*time.Second))
health.AddReadinessCheck("registry", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("http://%v", staticLayerRef)))
health.AddReadinessCheck("registry", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("https://%v", staticLayerRef)))
health.AddReadinessCheck("registry-facade", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("https://127.0.0.1:%v/%v/base/", cfg.Registry.Port, cfg.Registry.Prefix)))

health.AddLivenessCheck("dns", kubernetes.DNSCanResolveProbe(staticLayerHost, 1*time.Second))
health.AddLivenessCheck("registry", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("http://%v", staticLayerRef)))
health.AddLivenessCheck("registry", kubernetes.NetworkIsReachableProbe(fmt.Sprintf("https://%v", staticLayerRef)))

go func() {
if err := http.ListenAndServe(cfg.ReadinessProbeAddr, health); err != nil && err != http.ErrServerClosed {
Expand Down

0 comments on commit 9b105e0

Please sign in to comment.