Skip to content

Assist: mark individual nodes as finished#28477

Merged
jakule merged 10 commits intomasterfrom
justinas/assist-mark-nodes-finished
Jul 7, 2023
Merged

Assist: mark individual nodes as finished#28477
jakule merged 10 commits intomasterfrom
justinas/assist-mark-nodes-finished

Conversation

@justinas
Copy link
Copy Markdown
Contributor

@justinas justinas commented Jun 29, 2023

Fixes https://github.com/gravitational/teleport.e/issues/1741 .

Makes sure that server ID is sent in the individual close messages. We do this in a quite naive way by sending the same sessionData that is sent when the session is established. This means that we possibly have some stale data (such as last_active), but for us only server_id is important. We could fix this by sending a leaner custom structure in this case.

Justinas Stankevicius added 5 commits June 30, 2023 15:04
`Envelope` is the outer layer used (in protobuf format)
for execution / terminal sessions.

Meanwhile `outEnvelope` is the inner layer
used (in JSON) spefically with assist (execution),
when outer envelope is of "raw" type

Using `Envelope` where decoding `outEnvelope` in tests
previously worked "by accident" due to matching field names
@justinas justinas changed the title Justinas/assist mark nodes finished Assist: mark individual nodes as finished Jun 30, 2023
@justinas justinas marked this pull request as ready for review June 30, 2023 13:31
@github-actions github-actions Bot requested review from gzdunek and ryanclark June 30, 2023 13:31
@jakule jakule self-assigned this Jun 30, 2023
Comment thread web/packages/teleport/src/Assist/context/AssistContext.tsx Outdated
Comment thread lib/web/command.go Outdated
jakule added 2 commits July 6, 2023 14:01
This commit changes how command execution and WebSocket handling are performed in the code. Instead of manually managing session close signals and command execution notifications via WebSocket, we have wrapped it into more easily manageable form.

Changed parts: assist and websocket libraries, test and several components of 'teleport'.

Why:
This allows cleaner command management and error handling, leading to more reliable and maintainable application. Also made code more readable and easy to understand. Made WebSocket more precise with its handling to prevent cases where stale or incorrect data might interrupt the session.

Details:
Instead of sending a close signal after all commands have been executed, we now send individual session end updates for each command. Sessions no longer remain active unnecessarily.

Message handling in command execution has been refactored for better error propagation.

All these changes were also adjusted and reflected in the associated test cases.
Also, names and types of various data structures are edited to reflect their actual usage.
@jakule
Copy link
Copy Markdown
Contributor

jakule commented Jul 6, 2023

@ryanclark Can you take a look at this?

Copy link
Copy Markdown
Member

@ryanclark ryanclark left a comment

Choose a reason for hiding this comment

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

Approving with @jakule changing server_id to node_id for consistency across message types

This commit replaces occurrences of `ServerID` with `NodeID` across several files.
`ServerID` was misleading and causing confusion as it was serving as an identifier for nodes, so to improve comprehension and consistency in the codebase, all instances of `ServerID` have been replaced with `NodeID`. Tests have also been updated to reflect this change.
@jakule jakule added this pull request to the merge queue Jul 7, 2023
Merged via the queue into master with commit f71c248 Jul 7, 2023
@jakule jakule deleted the justinas/assist-mark-nodes-finished branch July 7, 2023 16:42
@public-teleport-github-review-bot
Copy link
Copy Markdown

@justinas See the table below for backport results.

Branch Result
branch/v13 Failed

ravicious pushed a commit that referenced this pull request Jul 11, 2023
* Mark nodes as done when command finishes in Assist

* Split Close/CloseWithPayload

* Expect a close message before the summary in test

* Remediate confusing type usage in test

`Envelope` is the outer layer used (in protobuf format)
for execution / terminal sessions.

Meanwhile `outEnvelope` is the inner layer
used (in JSON) spefically with assist (execution),
when outer envelope is of "raw" type

Using `Envelope` where decoding `outEnvelope` in tests
previously worked "by accident" due to matching field names

* Assert that server ID is set in the close message

* Refactor command execution logic and adjust WebSocket handling

This commit changes how command execution and WebSocket handling are performed in the code. Instead of manually managing session close signals and command execution notifications via WebSocket, we have wrapped it into more easily manageable form.

Changed parts: assist and websocket libraries, test and several components of 'teleport'.

Why:
This allows cleaner command management and error handling, leading to more reliable and maintainable application. Also made code more readable and easy to understand. Made WebSocket more precise with its handling to prevent cases where stale or incorrect data might interrupt the session.

Details:
Instead of sending a close signal after all commands have been executed, we now send individual session end updates for each command. Sessions no longer remain active unnecessarily.

Message handling in command execution has been refactored for better error propagation.

All these changes were also adjusted and reflected in the associated test cases.
Also, names and types of various data structures are edited to reflect their actual usage.

* Change ServerID to NodeID to improve code consistency

This commit replaces occurrences of `ServerID` with `NodeID` across several files.
`ServerID` was misleading and causing confusion as it was serving as an identifier for nodes, so to improve comprehension and consistency in the codebase, all instances of `ServerID` have been replaced with `NodeID`. Tests have also been updated to reflect this change.

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
jakule added a commit that referenced this pull request Jul 14, 2023
* Mark nodes as done when command finishes in Assist

* Split Close/CloseWithPayload

* Expect a close message before the summary in test

* Remediate confusing type usage in test

`Envelope` is the outer layer used (in protobuf format)
for execution / terminal sessions.

Meanwhile `outEnvelope` is the inner layer
used (in JSON) spefically with assist (execution),
when outer envelope is of "raw" type

Using `Envelope` where decoding `outEnvelope` in tests
previously worked "by accident" due to matching field names

* Assert that server ID is set in the close message

* Refactor command execution logic and adjust WebSocket handling

This commit changes how command execution and WebSocket handling are performed in the code. Instead of manually managing session close signals and command execution notifications via WebSocket, we have wrapped it into more easily manageable form.

Changed parts: assist and websocket libraries, test and several components of 'teleport'.

Why:
This allows cleaner command management and error handling, leading to more reliable and maintainable application. Also made code more readable and easy to understand. Made WebSocket more precise with its handling to prevent cases where stale or incorrect data might interrupt the session.

Details:
Instead of sending a close signal after all commands have been executed, we now send individual session end updates for each command. Sessions no longer remain active unnecessarily.

Message handling in command execution has been refactored for better error propagation.

All these changes were also adjusted and reflected in the associated test cases.
Also, names and types of various data structures are edited to reflect their actual usage.

* Change ServerID to NodeID to improve code consistency

This commit replaces occurrences of `ServerID` with `NodeID` across several files.
`ServerID` was misleading and causing confusion as it was serving as an identifier for nodes, so to improve comprehension and consistency in the codebase, all instances of `ServerID` have been replaced with `NodeID`. Tests have also been updated to reflect this change.

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
github-merge-queue Bot pushed a commit that referenced this pull request Jul 14, 2023
* [Assist] Clear the refresh websocket timeout when closing Assist (#28610)

* Clear the refresh websocket timeout when closing Assist

* Missing semicolon to please prettier

* Add comment to remove once the new session implementation is done

* fix: Decode JSON directly from stream in `waitForCommandOutput` (#28040)

* Assist: mark individual nodes as finished (#28477)

* Mark nodes as done when command finishes in Assist

* Split Close/CloseWithPayload

* Expect a close message before the summary in test

* Remediate confusing type usage in test

`Envelope` is the outer layer used (in protobuf format)
for execution / terminal sessions.

Meanwhile `outEnvelope` is the inner layer
used (in JSON) spefically with assist (execution),
when outer envelope is of "raw" type

Using `Envelope` where decoding `outEnvelope` in tests
previously worked "by accident" due to matching field names

* Assert that server ID is set in the close message

* Refactor command execution logic and adjust WebSocket handling

This commit changes how command execution and WebSocket handling are performed in the code. Instead of manually managing session close signals and command execution notifications via WebSocket, we have wrapped it into more easily manageable form.

Changed parts: assist and websocket libraries, test and several components of 'teleport'.

Why:
This allows cleaner command management and error handling, leading to more reliable and maintainable application. Also made code more readable and easy to understand. Made WebSocket more precise with its handling to prevent cases where stale or incorrect data might interrupt the session.

Details:
Instead of sending a close signal after all commands have been executed, we now send individual session end updates for each command. Sessions no longer remain active unnecessarily.

Message handling in command execution has been refactored for better error propagation.

All these changes were also adjusted and reflected in the associated test cases.
Also, names and types of various data structures are edited to reflect their actual usage.

* Change ServerID to NodeID to improve code consistency

This commit replaces occurrences of `ServerID` with `NodeID` across several files.
`ServerID` was misleading and causing confusion as it was serving as an identifier for nodes, so to improve comprehension and consistency in the codebase, all instances of `ServerID` have been replaced with `NodeID`. Tests have also been updated to reflect this change.

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>

---------

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>
Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Co-authored-by: Justinas Stankevičius <justinas@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants