Skip to content

Commit 630674e

Browse files
author
Abby Deng
committed
debug feature flag
1 parent 49c5ef4 commit 630674e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

internal/crusoe/nfs_flag.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"fmt"
88
"io"
99
"net/http"
10+
11+
"k8s.io/klog/v2"
1012
)
1113

1214
const (
@@ -27,6 +29,8 @@ type NfsFlagResponse struct {
2729

2830
// getFlag is a helper function to fetch a boolean flag from the API.
2931
func getFlag(ctx context.Context, crusoeHTTPClient *http.Client, flagRoute string) (bool, error) {
32+
klog.Infof("Fetching flag from URL: %s", flagRoute)
33+
3034
req, err := http.NewRequestWithContext(ctx, http.MethodGet, flagRoute, http.NoBody)
3135
if err != nil {
3236
return false, fmt.Errorf("%w: %w", errCreateFlagRequest, err)
@@ -45,6 +49,10 @@ func getFlag(ctx context.Context, crusoeHTTPClient *http.Client, flagRoute strin
4549
return false, fmt.Errorf("%w: %w", errReadFlagResponse, err)
4650
}
4751

52+
klog.Infof("Flag API response - Status: %d, Content-Type: %s, Body length: %d bytes",
53+
resp.StatusCode, resp.Header.Get("Content-Type"), len(bodyBytes))
54+
klog.Infof("Flag API raw response body: %q", string(bodyBytes))
55+
4856
// Check HTTP status code before unmarshaling
4957
if resp.StatusCode != http.StatusOK {
5058
return false, fmt.Errorf("%w: HTTP %d: %s", errGetFlag, resp.StatusCode, string(bodyBytes))
@@ -54,7 +62,7 @@ func getFlag(ctx context.Context, crusoeHTTPClient *http.Client, flagRoute strin
5462

5563
unmarshalErr := json.Unmarshal(bodyBytes, &flagResponse)
5664
if unmarshalErr != nil {
57-
return false, fmt.Errorf("%w: %w (response body: %s)", errUnmarshalFlag, unmarshalErr, string(bodyBytes))
65+
return false, fmt.Errorf("%w: %w (response body: %q)", errUnmarshalFlag, unmarshalErr, string(bodyBytes))
5866
}
5967

6068
return flagResponse.Status, nil

0 commit comments

Comments
 (0)