Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print K8s Resolver Event for Agent Grpc request debugging #6146

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"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) 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)
}

Check warning on line 170 in flytestdlib/resolver/k8s_resolver.go

View check run for this annotation

Codecov / codecov/patch

flytestdlib/resolver/k8s_resolver.go#L163-L170

Added lines #L163 - L170 were not covered by tests

logger.Infof(k.ctx, "k8s resolver: failed to create watcher: [%v]", err)

Check warning on line 172 in flytestdlib/resolver/k8s_resolver.go

View check run for this annotation

Codecov / codecov/patch

flytestdlib/resolver/k8s_resolver.go#L172

Added line #L172 was not covered by tests
grpclog.Errorf("k8s resolver: failed to create watcher: %v", err)
return
}
Expand All @@ -166,6 +179,7 @@
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
Loading