Skip to content

Commit

Permalink
Merge branch 'master' into lcharkiewicz/helm-chart-jamf-service-support
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharkiewicz authored Jun 7, 2024
2 parents 8a1a2ad + 76187e4 commit 98f2d0e
Show file tree
Hide file tree
Showing 144 changed files with 4,242 additions and 1,757 deletions.
2 changes: 1 addition & 1 deletion .github/vale-styles/messaging/edition-names.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extends: existence
scope:
# Using the raw scope so we can catch instances in TabItem labels.
- raw
message: '"%s" is no longer a recognized Teleport edition. Use "Teleport Enterprise" instead, and clarify the hosting type in parentheses rather than including it in the name of the product, e.g., "Teleport Enterprise (self-hosted)" or "Teleport Enterprise (cloud-hosted)".'
message: '"%s" is no longer a recognized Teleport edition. Use "Teleport Enterprise" instead, and clarify the hosting type rather than including it in the name of the product. For example, you could say, "For managed Teleport Enterprise...", "Teleport Enterprise (managed)", "self-hosted Teleport Enterprise," etc., as long as the implication is that Teleport Enterprise is a single product that users can host in two ways. If the hosting type is not important in a given sentence, there is no need to specify it.'
level: error
ignorecase: false
tokens:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ derive:
derive-up-to-date: must-start-clean/host derive
@if ! git diff --quiet; then \
echo 'Please run make derive.'; \
git diff; \
exit 1; \
fi

Expand Down Expand Up @@ -1423,13 +1424,15 @@ endif
protos-up-to-date/host: must-start-clean/host grpc/host
@if ! git diff --quiet; then \
echo 'Please run make grpc.'; \
git diff; \
exit 1; \
fi

.PHONY: must-start-clean/host
must-start-clean/host:
@if ! git diff --quiet; then \
echo 'This must be run from a repo with no unstaged commits.'; \
git diff; \
exit 1; \
fi

Expand All @@ -1439,6 +1442,7 @@ crds-up-to-date: must-start-clean/host
$(MAKE) -C integrations/operator manifests
@if ! git diff --quiet; then \
echo 'Please run make -C integrations/operator manifests.'; \
git diff; \
exit 1; \
fi

Expand Down
84 changes: 1 addition & 83 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2507,38 +2507,14 @@ func (c *Client) StreamUnstructuredSessionEvents(ctx context.Context, sessionID

stream, err := c.grpc.StreamUnstructuredSessionEvents(ctx, request)
if err != nil {
if trace.IsNotImplemented(trace.Wrap(err)) {
// If the server does not support the unstructured events API,
// fallback to the legacy API.
// This code patch shouldn't be triggered because the server
// returns the error only if the client calls Recv() on the stream.
// However, we keep this code patch here just in case there is a bug
// on the client grpc side.
c.streamUnstructuredSessionEventsFallback(ctx, sessionID, startIndex, ch, e)
} else {
e <- trace.Wrap(err)
}
e <- trace.Wrap(err)
return ch, e
}
go func() {
for {
event, err := stream.Recv()
if err != nil {
if !errors.Is(err, io.EOF) {
// If the server does not support the unstructured events API, it will
// return an error with code Unimplemented. This error is received
// the first time the client calls Recv() on the stream.
// If the client receives this error, it should fallback to the legacy
// API that spins another goroutine to convert the events to the
// unstructured format and sends them to the channel ch.
// Once we decide to spin the goroutine, we can leave this loop without
// reporting any error to the caller.
if trace.IsNotImplemented(trace.Wrap(err)) {
// If the server does not support the unstructured events API,
// fallback to the legacy API.
go c.streamUnstructuredSessionEventsFallback(ctx, sessionID, startIndex, ch, e)
return
}
e <- trace.Wrap(err)
} else {
close(ch)
Expand All @@ -2558,64 +2534,6 @@ func (c *Client) StreamUnstructuredSessionEvents(ctx context.Context, sessionID
return ch, e
}

// streamUnstructuredSessionEventsFallback is a fallback implementation of the
// StreamUnstructuredSessionEvents method that is used when the server does not
// support the unstructured events API. This method uses the old API to stream
// events from the server and converts them to the unstructured format. This
// method converts the events at event handler plugin side, which can cause
// the plugin to miss some events if the plugin is not updated to the latest
// version.
// NOTE(tigrato): This code was reintroduced in 15.0.0 because the gRPC method was renamed
// incorrectly in 13.1-14.3 which caused the server to return Unimplemented
// error to the client and the client to fallback to the legacy API.
// TODO(tigrato): DELETE IN 16.0.0
func (c *Client) streamUnstructuredSessionEventsFallback(ctx context.Context, sessionID string, startIndex int64, ch chan *auditlogpb.EventUnstructured, e chan error) {
request := &proto.StreamSessionEventsRequest{
SessionID: sessionID,
StartIndex: int32(startIndex),
}

stream, err := c.grpc.StreamSessionEvents(ctx, request)
if err != nil {
e <- trace.Wrap(err)
return
}

go func() {
for {
oneOf, err := stream.Recv()
if err != nil {
if !errors.Is(err, io.EOF) {
e <- trace.Wrap(err)
} else {
close(ch)
}

return
}

event, err := events.FromOneOf(*oneOf)
if err != nil {
e <- trace.Wrap(err)
return
}

unstructedEvent, err := events.ToUnstructured(event)
if err != nil {
e <- trace.Wrap(err)
return
}

select {
case ch <- unstructedEvent:
case <-ctx.Done():
e <- trace.Wrap(ctx.Err())
return
}
}
}()
}

// SearchSessionEvents allows searching for session events with a full pagination support.
func (c *Client) SearchSessionEvents(ctx context.Context, fromUTC time.Time, toUTC time.Time, limit int, order types.EventOrder, startKey string) ([]events.AuditEvent, string, error) {
request := &proto.GetSessionEventsRequest{
Expand Down
11 changes: 8 additions & 3 deletions api/client/joinservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ func TestJoinServiceClient_RegisterUsingTPMMethod(t *testing.T) {
cancel()
}()

c, err := grpc.NewClient("unused.com", grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return lis.DialContext(ctx)
}), grpc.WithTransportCredentials(insecure.NewCredentials()))
// grpc.NewClient attempts to DNS resolve addr, whereas grpc.Dial doesn't.
c, err := grpc.Dial(
"bufconn",
grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return lis.DialContext(ctx)
}),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
require.NoError(t, err)

joinClient := NewJoinServiceClient(proto.NewJoinServiceClient(c))
Expand Down
41 changes: 29 additions & 12 deletions api/gen/proto/go/assist/v1/assist_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 98f2d0e

Please sign in to comment.