Skip to content

Commit

Permalink
Print K8s Resolver Event for Agent Grpc request debugging (#6146)
Browse files Browse the repository at this point in the history
* Print K8s Resolver Event for Agent Grpc request debugging

Signed-off-by: Future-Outlier <eric901201@gmail.com>

* update

Signed-off-by: Future-Outlier <eric901201@gmail.com>

---------

Signed-off-by: Future-Outlier <eric901201@gmail.com>
  • Loading branch information
Future-Outlier authored Jan 11, 2025
1 parent b010747 commit 4dd64d8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion flytestdlib/resolver/k8s_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/resolver"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -154,9 +155,21 @@ func (k *kResolver) resolve(e *v1.Endpoints) {
func (k *kResolver) run() {
k.wg.Add(1)
defer k.wg.Done()
logger.Infof(k.ctx, "Starting k8s resolver for target: %s", k.target)

logger.Infof(k.ctx, "Starting k8s resolver for target: [%s], service namespace: [%s], service name: [%s]", k.target, k.target.serviceNamespace, k.target.serviceName)

watcher, err := k.k8sClient.CoreV1().Endpoints(k.target.serviceNamespace).Watch(k.ctx, metav1.ListOptions{FieldSelector: "metadata.name=" + k.target.serviceName})
if err != nil {
logger.Errorf(
k.ctx,
"k8s resolver: failed to create watcher for target [%s]: service namespace: [%s], service name: [%s], "+"error [%v]",
k.target, k.target.serviceNamespace, k.target.serviceName, err,
)
if statusErr, ok := err.(*errors.StatusError); ok {
logger.Errorf(k.ctx, "k8s resolver: status error details: %v", statusErr.ErrStatus)
}

logger.Infof(k.ctx, "k8s resolver: failed to create watcher: [%v]", err)
grpclog.Errorf("k8s resolver: failed to create watcher: %v", err)
return
}
Expand All @@ -166,6 +179,7 @@ func (k *kResolver) run() {
case <-k.ctx.Done():
return
case event, ok := <-watcher.ResultChan():
logger.Info(k.ctx, "k8s resolver watcher event response: [%v]", event)
if !ok {
logger.Debugf(k.ctx, "k8s resolver: watcher closed")
return
Expand Down

0 comments on commit 4dd64d8

Please sign in to comment.