Skip to content

Commit e513fce

Browse files
committed
add debug folder for maintainers
Supporting review comments in temporalio#149 which I'd like to see over the line.
1 parent 048fba2 commit e513fce

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

debug/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Health Check Debug Tool
2+
3+
This tool tests the gRPC health check endpoint manually to debug authentication issues.
4+
5+
## Usage
6+
7+
1. Get your API key from the secret:
8+
```bash
9+
kubectl get secret hobbes-adminrole-temporal-eap -n temporal-demo-python-worker -o jsonpath='{.data.key}' | base64 -d
10+
```
11+
12+
2. Update the `apiKey` variable in `health_check.go` with the actual key
13+
14+
3. Run the tests:
15+
```bash
16+
cd debug
17+
go mod tidy
18+
go run health_check.go
19+
```
20+
21+
## What it tests
22+
23+
- **Test 1**: Health check without authentication (should fail if auth required)
24+
- **Test 2**: Health check with API key authentication
25+
- **Test 3**: Health check with service name "temporal-frontend"
26+
27+
This will help determine if the issue is:
28+
- Health check requires no auth (Test 1 succeeds)
29+
- Health check requires API key but our implementation is wrong (Test 2 fails)
30+
- Health check requires specific service name (Test 3 succeeds)

debug/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module debug_health_check
2+
3+
go 1.21
4+
5+
require (
6+
go.temporal.io/sdk v1.28.1
7+
)

debug/health_check.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"crypto/tls"
6+
"fmt"
7+
"log"
8+
"os"
9+
"time"
10+
11+
sdkclient "go.temporal.io/sdk/client"
12+
)
13+
14+
func main() {
15+
// Get values from environment variables (fail if not set)
16+
serverAddr := os.Getenv("TEMPORAL_HOST_PORT")
17+
apiKey := os.Getenv("TEMPORAL_API_KEY")
18+
temporalNamespace := os.Getenv("TEMPORAL_NAMESPACE")
19+
20+
if serverAddr == "" {
21+
log.Fatal("TEMPORAL_HOST_PORT environment variable is required")
22+
}
23+
if apiKey == "" {
24+
log.Fatal("TEMPORAL_API_KEY environment variable is required")
25+
}
26+
if temporalNamespace == "" {
27+
log.Fatal("TEMPORAL_NAMESPACE environment variable is required")
28+
}
29+
30+
fmt.Printf("Testing Temporal client health check against: %s\n", serverAddr)
31+
fmt.Printf("Using temporal namespace: %s\n", temporalNamespace)
32+
fmt.Printf("Using API key: %s...\n", apiKey[:min(10, len(apiKey))])
33+
34+
// Test 1: Client without authentication (like original mTLS-only setup)
35+
fmt.Println("\n=== Test 1: Client without authentication ===")
36+
clientOpts1 := sdkclient.Options{
37+
HostPort: serverAddr,
38+
Namespace: temporalNamespace,
39+
ConnectionOptions: sdkclient.ConnectionOptions{
40+
TLS: &tls.Config{}, // Basic TLS, no auth
41+
},
42+
}
43+
44+
c1, err1 := sdkclient.Dial(clientOpts1)
45+
if err1 != nil {
46+
fmt.Printf("❌ Failed to create client: %v\n", err1)
47+
} else {
48+
defer c1.Close()
49+
ctx1, cancel1 := context.WithTimeout(context.Background(), 10*time.Second)
50+
defer cancel1()
51+
52+
_, err1 := c1.CheckHealth(ctx1, &sdkclient.CheckHealthRequest{})
53+
if err1 != nil {
54+
fmt.Printf("❌ Health check failed: %v\n", err1)
55+
} else {
56+
fmt.Printf("✅ Health check succeeded\n")
57+
}
58+
}
59+
60+
// Test 2: Client with API key authentication (matches our controller)
61+
fmt.Println("\n=== Test 2: Client with API key authentication ===")
62+
clientOpts2 := sdkclient.Options{
63+
HostPort: serverAddr,
64+
Namespace: temporalNamespace,
65+
Credentials: sdkclient.NewAPIKeyStaticCredentials(apiKey),
66+
ConnectionOptions: sdkclient.ConnectionOptions{
67+
TLS: &tls.Config{}, // Basic TLS + API key
68+
},
69+
}
70+
71+
c2, err2 := sdkclient.Dial(clientOpts2)
72+
if err2 != nil {
73+
fmt.Printf("❌ Failed to create client: %v\n", err2)
74+
} else {
75+
defer c2.Close()
76+
ctx2, cancel2 := context.WithTimeout(context.Background(), 10*time.Second)
77+
defer cancel2()
78+
79+
_, err2 := c2.CheckHealth(ctx2, &sdkclient.CheckHealthRequest{})
80+
if err2 != nil {
81+
fmt.Printf("❌ Health check failed: %v\n", err2)
82+
} else {
83+
fmt.Printf("✅ Health check succeeded\n")
84+
}
85+
}
86+
87+
// Test 3: Different context for health check
88+
fmt.Println("\n=== Test 3: API key with different context ===")
89+
if c2 != nil {
90+
ctx3 := context.Background()
91+
_, err3 := c2.CheckHealth(ctx3, &sdkclient.CheckHealthRequest{})
92+
if err3 != nil {
93+
fmt.Printf("❌ Health check with background context failed: %v\n", err3)
94+
} else {
95+
fmt.Printf("✅ Health check with background context succeeded\n")
96+
}
97+
}
98+
}
99+
100+
func min(a, b int) int {
101+
if a < b {
102+
return a
103+
}
104+
return b
105+
}

0 commit comments

Comments
 (0)