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

Add new Ankaios cli command ank get agents #343

Merged
merged 80 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
6bfaf76
Add first stest for list agents
inf17101 Aug 6, 2024
adecf9f
Change assert keyword in stest
inf17101 Aug 6, 2024
c37762f
Add agent map to the CompleteState
inf17101 Aug 6, 2024
d1c1d1c
Fix utests
inf17101 Aug 7, 2024
d50d19e
Write swdd reqs for the server
inf17101 Aug 7, 2024
eb059db
Implement storing and removing connected agents
inf17101 Aug 7, 2024
d1b12ac
Revert to string for agent name and add basic utests
inf17101 Aug 7, 2024
292ed51
Remove pub from workload_states_map entry
inf17101 Aug 7, 2024
0274358
Fix markdown newlines
inf17101 Aug 7, 2024
7b526b1
Remove unused from in workload states map
inf17101 Aug 8, 2024
7be4c1f
Remove uncomment code
inf17101 Aug 8, 2024
d7fba2d
Add connected agent utests in server
inf17101 Aug 8, 2024
741bbfa
Replace default with real agents values in utests
inf17101 Aug 8, 2024
e2778e6
Make the AgentAttributes proto message empty
inf17101 Aug 8, 2024
ffca16f
Fix rust analyzer warnings of previous PRs
inf17101 Aug 8, 2024
ae029bc
Fix linkage in server utest
inf17101 Aug 8, 2024
a14c8f7
Revert agent_name.rs
inf17101 Aug 8, 2024
d048428
Swdd and linkage for agent map
inf17101 Aug 8, 2024
a776f60
Remove duplicated hashmap entry tests
inf17101 Aug 8, 2024
858f03c
Change server state reqs
inf17101 Aug 8, 2024
1ba7eb5
Add agent map to cli filtered complete state
inf17101 Aug 8, 2024
40f9c30
Implemented get agents logic in cli
inf17101 Aug 8, 2024
3e64468
Flatten agents map
inf17101 Aug 8, 2024
a2cb8f9
Change to into_keys
inf17101 Aug 8, 2024
78b1df1
Refactored to table builder and refactor get_agents
inf17101 Aug 9, 2024
89c7f72
Remove agent name clone
inf17101 Aug 12, 2024
6e1522c
Remove row trait impls
inf17101 Aug 12, 2024
b80acce
Remove table builder complexity and fix utests
inf17101 Aug 16, 2024
8f86cac
Rename constant
inf17101 Aug 16, 2024
9768f58
Rename TableBuilder to AnkTable to not indicate builder pattern
inf17101 Aug 16, 2024
0a83ac7
Merge branch 'main' into 155_list_agents
inf17101 Aug 16, 2024
1ff21bb
Fix RustAnalyzer warnings of untouched files
inf17101 Aug 16, 2024
b1b4de1
Fix list agents stest
inf17101 Aug 16, 2024
022c1ad
Add swdds for CLI and linkage to impl
inf17101 Aug 16, 2024
d95b2eb
Make table builder utests independent of row type
inf17101 Aug 19, 2024
81c8dda
Remove workload table linkage and rename utests
inf17101 Aug 19, 2024
763afb8
Add utests to get_agents.rs
inf17101 Aug 19, 2024
925ab70
Move use statement after license header
inf17101 Aug 19, 2024
fa030f4
Link utests and rename table_builder.rs to ank_table.rs
inf17101 Aug 19, 2024
445d17a
Small swdd updates
inf17101 Aug 19, 2024
ae457c1
Rename swdd
inf17101 Aug 19, 2024
f85dcbb
Change agent table req
inf17101 Aug 19, 2024
1757795
Fix table layout in agent table swdd
inf17101 Aug 19, 2024
bfc75fb
Make get_agents functions free
inf17101 Aug 19, 2024
ce57162
Put utest for empty agent names and make filter mask const
inf17101 Aug 20, 2024
b31cf46
Make default table test more precise
inf17101 Aug 20, 2024
bebea82
Use unreachable instead of index acess
inf17101 Aug 20, 2024
aafcbcf
Remove the AgentName::from
inf17101 Aug 20, 2024
1ffc313
Add sequence diagram for get agents
inf17101 Aug 20, 2024
33b1029
Link get agents stest
inf17101 Aug 20, 2024
bfa696d
Add swdd reqs for AnkTable
inf17101 Aug 21, 2024
c178a8d
Merge branch 'main' into 155_list_agents
inf17101 Aug 22, 2024
570462d
Rename AnkTable to CliTable
inf17101 Aug 22, 2024
234bbdb
Flatten the AgentsMap
inf17101 Aug 22, 2024
8f0105d
Remove println in utest
inf17101 Aug 22, 2024
56c8a30
Count workload states instead of assigned workloads
inf17101 Aug 26, 2024
c0e610c
Rename to workload_states_count
inf17101 Aug 26, 2024
e65b709
Add list agents to user tutorial and adapt desired state doc output
inf17101 Aug 26, 2024
775c529
Shorten requirement
inf17101 Aug 26, 2024
4d6d70a
Adapt workload count part of sequence diagram
inf17101 Aug 26, 2024
4bb13da
Fix main conflicts
inf17101 Aug 29, 2024
eb84716
Change agent proto field comment
inf17101 Aug 29, 2024
6ce1b25
Remove duplicated swdd prefix
inf17101 Aug 29, 2024
421729b
Remove duplicated swdd prefix
inf17101 Aug 29, 2024
7848dab
Increment req id of complete state content
inf17101 Aug 29, 2024
029eff5
Remove 'part' word of req
inf17101 Aug 29, 2024
f5a1b65
Exclude agent_map from test coverage
inf17101 Aug 29, 2024
03bb0e0
Remove 'part' word of req
inf17101 Aug 29, 2024
d215a5e
Change comment in stest
inf17101 Aug 29, 2024
f3273f8
Add commas to req
inf17101 Aug 29, 2024
50af9e2
Change req wording
inf17101 Aug 29, 2024
72099d4
Switch to one liner
inf17101 Aug 29, 2024
53330e4
Move table_width call
inf17101 Aug 29, 2024
00b9045
Rename function name
inf17101 Aug 29, 2024
48b6960
Update description in diagram
inf17101 Aug 29, 2024
2ff909a
Change reply arrow
inf17101 Aug 29, 2024
3dcff0c
Change main exit arrow
inf17101 Aug 29, 2024
5a68d5f
Allow comments on top of excluded coverage files
inf17101 Aug 30, 2024
b8833e3
Remove swdd duplicated prefix
inf17101 Aug 30, 2024
75352f4
Switch to unchecked addition
inf17101 Aug 30, 2024
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
435 changes: 246 additions & 189 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions agent/src/runtime_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,11 @@ mod tests {
},
)]),
});

complete_state.agents = Some(ank_base::AgentMap {
agents: HashMap::from([(AGENT_NAME.to_owned(), Default::default())]),
});

let expected_response = ank_base::Response {
request_id,
response_content: Some(ResponseContent::CompleteState(complete_state)),
Expand Down
133 changes: 133 additions & 0 deletions ank/doc/swdesign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ This also includes error handling when the user enters unsupported command or fo
The CliCommands implements the commands.
It uses FromServer Channel and ToServer Channel to interact with the server.

### CliTable

The CliTable provides an interface for creating different table output formats.
It unifies the creation of table layouts in different places in the Ankaios CLI by abstracting the table row types through generalization.

### External Libraries

#### Communication Middleware
Expand Down Expand Up @@ -871,6 +876,63 @@ Needs:
- utest
- stest

### `ank get agents`

![Get agents](plantuml/seq_get_agent.svg)

#### CLI provides the list of connected agents
`swdd~cli-provides-list-of-agents~1`

Status: approved

The Ankaios CLI shall provide a function to get the list of Ankaios agents connected to the Ankaios server.

Tags:
- Cli
- CliCommands

Needs:
- impl
- utest
- stest

#### CLI shall present connected agents as table
`swdd~cli-presents-connected-agents-as-table~1`

Status: approved

When the Ankaios CLI presents connected Ankaios agents to the user, the Ankaios CLI shall present the agents as rows in a table with the following content:

| NAME | WORKLOADS |
| ------------------------ | -------------------------------- |
| `<agent_name>` as text | `<assigned_workloads>` as number |

Tags:
- CliCommands

Needs:
- impl
- utest

#### CLI processes CompleteState to provide connected Ankaios agents
`swdd~cli-processes-complete-state-to-provide-connected-agents~1`

Status: approved

When the user invokes the CLI with a request to provide the list of connected Ankaios agents, the Ankaios CLI shall:
* request the whole CompleteState of Ankaios server
* create a table row for each Ankaios agent listed inside the CompleteState's `agents` field with the agent name and the amount of workload states of its managed workloads

Rationale:
Counting the workload states, rather than the assigned workloads in the desired state for each agent, ensures the correct number of workloads, even if a workload has been deleted from the desired state, but the actual deletion has not yet been scheduled.

Tags:
- CliCommands

Needs:
- impl
- utest

### Handling other message while waiting for response

![Store unexpected messages](plantuml/seq_store_missed_messages.svg)
Expand All @@ -893,6 +955,77 @@ Needs:
- impl
- utest

### CliTable allows creation of different table output formats

#### CliTable provides default table output
`swdd~cli-table-provides-default-table-output~1`

Status: approved

The CliTable shall provide a function to create a table output with the following table layout:
* table style blank
* no padding on the left and right side of the table

Tags:
- CliTable

Needs:
- impl
- utest

#### CliTable provides table output with a wrapped column
`swdd~cli-table-provides-table-output-with-wrapped-column~1`

Status: approved

The CliTable shall provide a function to create a table output with wrapping a specific column to the remaining terminal width with the following table layout:
* table style blank
* no padding on the left and right side of the table

Tags:
- CliTable

Needs:
- impl
- utest

#### CliTable provides table output with a truncated column
`swdd~cli-table-provides-table-output-with-truncated-column~1`

Status: approved

The CliTable shall provide a function to create a table output with truncating a specific column to the remaining terminal width with the following table layout:
* table style blank
* no padding on the left and right side of the table
* truncated column content suffixed by `...`

Tags:
- CliTable

Needs:
- impl
- utest

#### CliTable calculates wrapped/truncated column width according to terminal width
`swdd~cli-table-wrapped-truncated-column-width-depends-on-terminal-width~1`

Status: approved

When the CliTable is requested to create a table with a wrapped or truncated column, the CliTable shall:
* determine the column name length of this column
* determine the length of the longest content of this column otherwise zero as the longest length if the whole column is empty
* calculate the maximum between the longest content length and the column name length
* calculate the total table width of all other columns by subtracting the calculated maximum length from the total table width
* check if the remaining terminal width is reasonable by comparing if the difference between the current terminal width and column name length is greater or equal to the total table width of the other columns
* return the available column width by subtracting the total table width of all other columns from the terminal width if the terminal width is reasonable otherwise an error

Tags:
- CliTable

Needs:
- impl
- utest

## Data view

![Data view](plantuml/class_data-structures.svg)
Expand Down
47 changes: 47 additions & 0 deletions ank/doc/swdesign/plantuml/seq_get_agent.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@startuml seq_get_agent
!include ../../../../resources/doc/plantuml/clean.skin

box "Ankaios Ank"
actor "user" as user
participant Main as main
participant "CliCommands" as cli_commands
participant "ServerConnection" as server_connection
participant "<<task>>\nCommunicationsClient" as communications_client
end box

box "Ankaios Server"
participant "Ankaios Server" as server
end box

-> main ++ : get agents

== startup ==

... initialization ...

krucod3 marked this conversation as resolved.
Show resolved Hide resolved
== command ==

main -> cli_commands ++ : get agents

cli_commands -> server_connection ++: request complete state
server_connection ->> communications_client++: request complete state
communications_client ->> server --++ : request complete state

server_connection -> server_connection ++: wait for the response
communications_client <<- server --++: complete state
server_connection <<- communications_client --: complete state
deactivate server_connection
cli_commands <<-- server_connection --: complete state

cli_commands -> cli_commands ++: count workloads per agent\nin complete state
cli_commands -> cli_commands ++: for each connected agent\nassign number of workloads\n calculated from workload states
cli_commands -> cli_commands ++: format output text
main <<-- cli_commands -- : output text
deactivate cli_commands
deactivate cli_commands
deactivate cli_commands

main -> main: print text
user <<-- main -- : exit

@enduml
1 change: 1 addition & 0 deletions ank/doc/swdesign/plantuml/seq_get_agent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions ank/doc/swdesign/plantuml/seq_get_state.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ server_connection -> server_connection ++: wait for the response
communications_client <<- server --++: complete state
server_connection <<- communications_client --: complete state
deactivate server_connection
cli_commands <<- server_connection --: complete state
cli_commands <<-- server_connection --: complete state

main <- cli_commands -- : output text
deactivate cli_commands
deactivate cli_commands

main -> main ++: print text
user <- main -- : exit
deactivate main
user <<-- main -- : exit

@enduml
Loading