55 "encoding/json"
66 "fmt"
77 "io"
8- "log/slog"
98 "sort"
109 "strings"
1110 "time"
@@ -14,6 +13,7 @@ import (
1413 "github.com/obot-platform/nah/pkg/apply"
1514 "github.com/obot-platform/nah/pkg/name"
1615 "github.com/obot-platform/obot/apiclient/types"
16+ "github.com/obot-platform/obot/logger"
1717 "github.com/obot-platform/obot/pkg/wait"
1818 appsv1 "k8s.io/api/apps/v1"
1919 corev1 "k8s.io/api/core/v1"
@@ -28,6 +28,8 @@ import (
2828 kclient "sigs.k8s.io/controller-runtime/pkg/client"
2929)
3030
31+ var klog = logger .Package ()
32+
3133type kubernetesBackend struct {
3234 clientset * kubernetes.Clientset
3335 client kclient.WithWatch
@@ -582,12 +584,12 @@ func (k *kubernetesBackend) updatedMCPPodName(ctx context.Context, url, id strin
582584 "app" : id ,
583585 }),
584586 }); listErr != nil {
585- slog . Error ("failed to list MCP pods for status check" , "id " , id , "error" , listErr )
587+ klog . Debugf ("failed to list MCP pods for status check: id=%s error=%v " , id , listErr )
586588 return "" , fmt .Errorf ("failed to list MCP pods: %w" , listErr )
587589 }
588590
589591 if len (pods .Items ) == 0 {
590- slog . Warn ("no pods found for MCP server" , "id " , id , "attempt" , attempt + 1 )
592+ klog . Debugf ("no pods found for MCP server: id=%s attempt=%d " , id , attempt + 1 )
591593 lastReason = "no pods found"
592594 if attempt < maxRetries {
593595 continue
@@ -602,7 +604,7 @@ func (k *kubernetesBackend) updatedMCPPodName(ctx context.Context, url, id strin
602604
603605 if ! shouldRetry {
604606 // Permanent failure - return appropriate error based on reason
605- slog . Error ("pod in non-retryable state" , "id" , id , "reason" , reason , "attempt" , attempt + 1 )
607+ klog . Debugf ("pod in non-retryable state: id=%s reason=%s attempt=%d" , id , reason , attempt + 1 )
606608 if strings .Contains (reason , "CrashLoopBackOff" ) {
607609 return "" , fmt .Errorf ("%w: %s" , ErrPodCrashLoopBackOff , reason )
608610 } else if strings .Contains (reason , "ImagePull" ) || strings .Contains (reason , "InvalidImageName" ) {
@@ -617,12 +619,12 @@ func (k *kubernetesBackend) updatedMCPPodName(ctx context.Context, url, id strin
617619
618620 // Transient issue - retry if we haven't exceeded max retries
619621 if attempt < maxRetries {
620- slog . Info ("pod not ready, will retry" , "id " , id , " reason" , reason , " attempt" , attempt + 1 , "maxRetries" , maxRetries )
622+ klog . Debugf ("pod not ready, will retry: id=%s reason=%s attempt=%d maxRetries=%d " , id , reason , attempt + 1 , maxRetries )
621623 continue
622624 }
623625
624626 // Exceeded max retries
625- slog . Error ("exceeded max retries waiting for pod" , "id" , id , "lastReason" , lastReason , "attempts" , attempt + 1 )
627+ klog . Debugf ("exceeded max retries waiting for pod: id=%s lastReason=%s attempts=%d" , id , lastReason , attempt + 1 )
626628 return "" , fmt .Errorf ("%w after %d retries: %s" , ErrHealthCheckTimeout , maxRetries + 1 , lastReason )
627629 }
628630
0 commit comments