-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement TapByResource in Tap Service #827
Conversation
7fb98db
to
c28d1c7
Compare
controller/tap/server.go
Outdated
// TODO: for now assume it's always a single, flat `All` match list | ||
seq := match.GetAll() | ||
if seq == nil { | ||
return nil, errors.New("no match specified") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are these errors manifested? We should be returning errors that gRPC can turn into semantic status codes. For instance, in this case I'd expect us to return Unimplemented
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I've modified all return sites in TapByResource
to return gRPC errors. If functions lower in the stack return errors that need propagation, we now first check if it's a gRPC error. If it is, we propagate, if not, we wrap it in a gRPC error.
controller/tap/server.go
Outdated
}, | ||
} | ||
default: | ||
return nil, fmt.Errorf("unknown HTTP match type: %v", httpTyped) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error type?
controller/tap/server.go
Outdated
}) | ||
|
||
default: | ||
return nil, fmt.Errorf("unknown match type: %v", typed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error type?
return []string{deployment}, nil | ||
} | ||
|
||
pods, err := k8s.NewPodIndex(clientSet, deploymentIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to confirm, all of this was refactored out of NewServer
and is not changed. and this is required to support the Tap
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct this code was moved out of server.go
into main.go
. The motivation was to enable testing via dependency injection in server_test.go
. Now, NewServer
accepts fully initialized clients, rather than a Kubernetes config file.
@@ -26,7 +26,7 @@ type podIndex struct { | |||
stopCh chan struct{} | |||
} | |||
|
|||
func NewPodIndex(clientset *kubernetes.Clientset, index cache.IndexFunc) (PodIndex, error) { | |||
func NewPodIndex(clientset kubernetes.Interface, index cache.IndexFunc) (PodIndex, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary to support a refactor or just housekeeping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular change was not necessary, but an analogous one was required in replicasets.go
to enable passing in a fake k8s client, so err'd on the side of consistency.
controller/tap/server.go
Outdated
} | ||
|
||
if len(pods) == 0 { | ||
return fmt.Errorf("No pods found for ResourceSelection: %+v", *req.Target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, how are these various errors turned into gRPC statuses?
controller/tap/server.go
Outdated
|
||
match, err := makeByResourceMatch(req.Match) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this correct? What is this condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, this is a bug. I've added a test to catch this in case it regresses. Looks like we've had a similar bug in the original Tap
, that is fixed as well, but no tests added as we'll be removing soon.
controller/tap/server.go
Outdated
for event := range events { | ||
err := stream.Send(event) | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error type?
@@ -746,6 +746,6 @@ | |||
[solve-meta] | |||
analyzer-name = "dep" | |||
analyzer-version = 1 | |||
inputs-digest = "f5ff9662192d238efdb260226a886088d05da0924292833660466258fd80c8c0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what changed in gopkg.lock that requires a go-deps change? afaict this bump looks unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this change the go vet ./...
in ci failed:
https://travis-ci.org/runconduit/conduit/jobs/370317684
i suspect it may be changes to various imports, but no dependencies have been added/removed from the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found it by diff'ing the output of bin/dep hash-inputs
in master and this branch, new dependency:
k8s.io/apimachinery/pkg/api/errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for addressing my concerns!
c5ea33c
to
efed0be
Compare
The TapByResource endpoint was previously a stub.
Implement end-to-end tapByResource functionality, with support for
specifying any kubernetes resource(s) as target and destination.
Fixes #803, #49
Signed-off-by: Andrew Seigner siggy@buoyant.io
Note that much of the Kubernetes Informer integration is copied from public-api. Once stabilized, this code will get factored out in a subsequent PR. This PR focuses on end-to-end functionality.