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 1 commit
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: 16 additions & 0 deletions 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 @@ -157,6 +158,16 @@
logger.Infof(k.ctx, "Starting k8s resolver for target: %s", k.target)
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]: namespace [%s], service [%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 168 in flytestdlib/resolver/k8s_resolver.go

View check run for this annotation

Codecov / codecov/patch

flytestdlib/resolver/k8s_resolver.go#L161-L168

Added lines #L161 - L168 were not covered by tests

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

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#L170

Added line #L170 was not covered by tests
grpclog.Errorf("k8s resolver: failed to create watcher: %v", err)
return
}
Expand All @@ -166,6 +177,11 @@
case <-k.ctx.Done():
return
case event, ok := <-watcher.ResultChan():
logger.Info(k.ctx, "k8s resolver watchet event response: [%v]", event)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it print the event.Object? If so, I think we can remove line 181 and 182

logger.Info(k.ctx, "k8s resolver watchet event Object response: [%v]", event.Object)
if event.Object != nil {
logger.Info(k.ctx, "k8s resolver watchet event Object Kind: [%v]", event.Object.GetObjectKind())
}
if !ok {
logger.Debugf(k.ctx, "k8s resolver: watcher closed")
return
Expand Down
Loading