Skip to content

Commit

Permalink
Add workload config implementation (#389)
Browse files Browse the repository at this point in the history
* Small draft code to try out handlebars

* Write design decision for handlebars

* Add first swdds and first draft implementation

* Fix reference and swdd tags

* Add swdd for config renderer

* Update rendered workloads only when state is updated

* Implement update logic of expanded workloads

* Rename workload variables

* Skip rendering on no config assignment and introduce error type

* Fix update of config item only

* Remove in-place allocation of ConfigRenderer

* Add comment

* Fix server state utests

* Add config renderer utests

* Add update of configs utest and swdd

* Add configs update utests for server state

* Rename update_state method

* Ignore configs for agent name handling in ank apply

* Fix linkage in utest

* Add completions for configs in object field mask

Issue-Id: #267

* Improve log output in ank cli

* Update only desiredState

* Refactor set_state function and update plantuml

* Write swdd for comparing rendered workloads

* Split state format rendering

* Fix wrong dependencies workload names in test data

* Extract to constant var

* Remove not needed references

* First basic system test

* Rename stest file

* Remove notes file

* Make utest more strict

* Add more stests and link them

* Add utests for config key and alias validation

* Add config key format stest

* Add stests for workload config refs and fix linkage

* Add utests for ank apply

* Remove duplicated utest

* Adapt working with complete state section

* Disable wait in utest

* Merge main into branch and fix utest

* Get rid of conversion in utest

* Adapt quickstart doc

* Adapt startup-configuration user doc

* Extend user tutorial with configs

* Add update and delete config user doc

* Add comment about unrendered get complete state

* Fix rust contol interface example

* Add utest linkage

* Add linkage to utest for config rendering

* Fix missing swdd prefix in linkage

* Wording in comment

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Rename api_format method

* Fix naming convention swdd rationale

* Change swdd for selecting workloads for agents

* Add newline to swdd rationale

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Rename utest

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Use mockall double for import

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Output error message

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Space in utest linkage

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Change comment in utest

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Fix comment in stest documentation

* Fix comments for precondition

* Remove config_key from workload config map and insert utest

* Throw specific error upon not existing config key

* Adapt doc agent field description

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Change linkage to sub chapter

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

* Remove plurar

* Rename update state file in stest

* Revert to normal yaml string

Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>

---------

Co-authored-by: Holger Dormann <holger.dormann@elektrobit.com>
Co-authored-by: Kaloyan <36224699+krucod3@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 29, 2024
1 parent 6dc056c commit f640b80
Show file tree
Hide file tree
Showing 40 changed files with 2,117 additions and 347 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"protobuf",
"Substate",
"swdd",
"templating",
"unrendered",
"utest",
"VecDeque"
],
Expand Down
66 changes: 66 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion agent/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::path::Path;
use crate::control_interface::Directory;
use crate::control_interface::FileSystemError;
use clap::Parser;
use common::objects::state::STR_RE_AGENT;
use common::objects::STR_RE_AGENT;
use common::DEFAULT_SERVER_ADDRESS;

const DEFAULT_RUN_FOLDER: &str = "/tmp/ankaios/";
Expand Down
4 changes: 2 additions & 2 deletions agent/src/runtime_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2054,11 +2054,11 @@ mod tests {
dependencies: Some(ank_base::Dependencies {
dependencies: HashMap::from([
(
"workload A".to_string(),
"workload_A".to_string(),
AddCondition::AddCondRunning as i32,
),
(
"workload C".to_string(),
"workload_C".to_string(),
AddCondition::AddCondSucceeded as i32,
),
]),
Expand Down
7 changes: 7 additions & 0 deletions ank/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn workload_completer(current: &OsStr) -> Vec<CompletionCandidate> {
fn completions_object_field_mask(state: Vec<u8>, current: &OsStr) -> Vec<CompletionCandidate> {
const DESIRED_STATE: &str = "desiredState";
const WORKLOADS: &str = "workloads";
const CONFIGS: &str = "configs";
const WORKLOAD_STATES: &str = "workloadStates";

let mut result = Vec::new();
Expand All @@ -79,6 +80,12 @@ fn completions_object_field_mask(state: Vec<u8>, current: &OsStr) -> Vec<Complet
result.push(format!("{}.{}.{}", DESIRED_STATE, WORKLOADS, workload_name));
}
}
if let Some(configs) = desired_state.configs {
result.push(format!("{}.{}", DESIRED_STATE, CONFIGS));
for config_name in configs.keys() {
result.push(format!("{}.{}.{}", DESIRED_STATE, CONFIGS, config_name));
}
}
}

if let Some(workload_states) = state.workload_states {
Expand Down
2 changes: 1 addition & 1 deletion ank/src/cli_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl CliCommands {
changed_workloads.extend(update_state_success.deleted_workloads.iter().cloned());

if changed_workloads.is_empty() {
output!("No workloads to update");
output!("Apply successful. No workloads updated.");
return Ok(());
} else {
output!("Successfully applied the manifest(s).\nWaiting for workload(s) to reach desired states (press Ctrl+C to interrupt).\n");
Expand Down
Loading

0 comments on commit f640b80

Please sign in to comment.