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

[#432] Implement CLI iox2-config #468

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ The support levels can be adjusted when required.
<a href="https://github.com/orecham">
<img src="https://avatars.githubusercontent.com/u/8487595" width="120px;" alt="»orecham«"/><br />
<sub><b>»orecham«</b></sub></a></td>
<td align="center" valign="top" width="14.28%">
<a href="https://github.com/brosier01">
<img src="https://avatars.githubusercontent.com/u/71630425?v=4" width="120px;" alt="Bruce »brosier01« Rosier"/><br />
<sub><b>Bruce »brosier01« Rosier</b></sub></a></td>
</tr>
</tbody>
</table>
Expand Down
58 changes: 12 additions & 46 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,23 @@

### Features

<!--
NOTE: Add new entries sorted by issue number to minimize the possibility of
conflicts when merging.
-->
Create a new CLI for iceoryx2 `iox2-config`

* Add `PeriodicTimer` into POSIX building blocks [#425](https://github.com/eclipse-iceoryx/iceoryx2/issues/425)
`iox2-config` can `show` the configuration currently in use and `generate` a new
brosier01 marked this conversation as resolved.
Show resolved Hide resolved
configuration file at the default location iceoryx2 is looking for.

### Bugfixes

<!--
NOTE: Add new entries sorted by issue number to minimize the possibility of
conflicts when merging.
-->

* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
* Add CLI to display complete system configuration [#432](https://github.com/eclipse-iceoryx/iceoryx2/issues/432)

### Refactoring

<!--
NOTE: Add new entries sorted by issue number to minimize the possibility of
conflicts when merging.
-->

* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### Workflow

<!--
NOTE: Add new entries sorted by issue number to minimize the possibility of
conflicts when merging.
-->

* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### New API features

<!--
NOTE: Add new entries sorted by issue number to minimize the possibility of
conflicts when merging.
-->

* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)

### API Breaking Changes
Remove the `print_system_configuration()` function in
`iceoryx2-bb/posix/src/system_configuration.rs` file and move it into the CLI `iox2-config`
[#432](https://github.com/eclipse-iceoryx/iceoryx2/issues/432)

1. Example
### New CLI features

```rust
// old
let fuu = hello().is_it_me_you_re_looking_for()
```bash
cargo run --bin iox2-config show
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cargo run --bin iox2-config show
iox2 config show


// new
let fuu = hypnotoad().all_glory_to_the_hypnotoad()
```
cargo run --bin iox2-config generate
brosier01 marked this conversation as resolved.
Show resolved Hide resolved
```
84 changes: 0 additions & 84 deletions iceoryx2-bb/posix/src/system_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,87 +294,3 @@ impl ProcessResourceLimit {
true
}
}

/// Prints the whole system configuration with all limits, features and details to the console.
pub fn print_system_configuration() {
const HEADER_COLOR: &str = "\x1b[4;92m";
const VALUE_COLOR: &str = "\x1b[0;94m";
const DISABLED_VALUE_COLOR: &str = "\x1b[0;90m";
const ENTRY_COLOR: &str = "\x1b[0;37m";
const DISABLED_ENTRY_COLOR: &str = "\x1b[0;90m";
const COLOR_RESET: &str = "\x1b[0m";

println!("{}posix system configuration{}", HEADER_COLOR, COLOR_RESET);
println!();
println!(" {}system info{}", HEADER_COLOR, COLOR_RESET);
for i in all::<SystemInfo>().collect::<Vec<_>>() {
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.value(),
);
}

println!();
println!(" {}limits{}", HEADER_COLOR, COLOR_RESET);
for i in all::<Limit>().collect::<Vec<_>>() {
let limit = i.value();
let limit = if limit == 0 {
"[ unlimited ]".to_string()
} else {
limit.to_string()
};
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
limit,
);
}

println!();
println!(" {}options{}", HEADER_COLOR, COLOR_RESET);
for i in all::<SysOption>().collect::<Vec<_>>() {
if i.is_available() {
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
} else {
println!(
" {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
}
}

println!();
println!(" {}features{}", HEADER_COLOR, COLOR_RESET);
for i in all::<Feature>().collect::<Vec<_>>() {
if i.is_available() {
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
} else {
println!(
" {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
}
}

println!();
println!(" {}process resource limits{}", HEADER_COLOR, COLOR_RESET);
for i in all::<ProcessResourceLimit>().collect::<Vec<_>>() {
println!(
" {ENTRY_COLOR}{:<43}{COLOR_RESET} soft: {VALUE_COLOR}{:<24}{COLOR_RESET} hard: {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.soft_limit(),
i.hard_limit()
);
}
}
9 changes: 9 additions & 0 deletions iceoryx2-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ path = "iox2-node/src/main.rs"
name = "iox2-service"
path = "iox2-service/src/main.rs"

[[bin]]
name = "iox2-config"
path = "iox2-config/src/main.rs"

[lib]
name = "iceoryx2_cli"
path = "lib/src/lib.rs"
Expand All @@ -34,17 +38,22 @@ path = "lib/src/lib.rs"
iceoryx2 = { workspace = true }
iceoryx2-bb-log = { workspace = true }
iceoryx2-pal-posix = {workspace = true}
iceoryx2-bb-posix = {workspace = true}
iceoryx2-bb-system-types = { workspace = true }
iceoryx2-bb-container ={ workspace = true }

anyhow = { workspace = true }
better-panic = { workspace = true }
cargo_metadata = { workspace = true }
clap = { workspace = true }
colored = { workspace = true }
enum-iterator = { workspace = true }
human-panic = { workspace = true }
serde = { workspace = true }
serde_yaml = { workspace = true }
serde_json = { workspace = true }
ron = { workspace = true }
toml = { workspace = true }

[dev-dependencies]
iceoryx2-bb-testing = { workspace = true }
Expand Down
39 changes: 39 additions & 0 deletions iceoryx2-cli/iox2-config/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2024 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache Software License 2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
// which is available at https://opensource.org/licenses/MIT.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

use clap::Parser;
use clap::Subcommand;

use iceoryx2_cli::help_template;

#[derive(Parser)]
#[command(
name = "iox2-config",
about = "Query information about iceoryx2 configuration",
long_about = None,
version = env!("CARGO_PKG_VERSION"),
disable_help_subcommand = true,
arg_required_else_help = false,
help_template = help_template("iox2 config", false),
)]
pub struct Cli {
#[clap(subcommand)]
pub action: Option<Action>,
}

#[derive(Subcommand)]
pub enum Action {
#[clap(about = "Show the currently used configuration")]
Show,
#[clap(about = "Generate a default configuration file")]
Generate,
}
127 changes: 127 additions & 0 deletions iceoryx2-cli/iox2-config/src/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Copyright (c) 2024 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache Software License 2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
// which is available at https://opensource.org/licenses/MIT.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

use anyhow::Result;
use enum_iterator::all;
use iceoryx2::config::Config;
use iceoryx2_bb_posix::system_configuration::*;
use std::fs::File;
use std::io::Write;
use std::path::Path;

/// Prints the whole system configuration with all limits, features and details to the console.
pub fn print_system_configuration() {
orecham marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@orecham orecham Oct 16, 2024

Choose a reason for hiding this comment

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

This function has an error on macOS:

        0 [F] "ProcessResourceLimit::soft_limit"
              | This should never happen! Unable to acquire soft limit for MaxSizeOfTotalMemory due to an unknown error (errno { name = "EINVAL", value = 22, details = "Invalid argument" }).

We should make it possible for the CI to catch stuff like this. Could you add a test that executes this function?

As for the reason, it's not immediately obvious to me. For this PR, one workaround could be to update the code to catch errors from the calls it uses to get the information it prints. The function could then continue even if a call has an error, and print a message to the user explaining which information was not retrievable.

cc @elfenpiff

Copy link
Contributor

@orecham orecham Oct 16, 2024

Choose a reason for hiding this comment

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

FYI the bug is probably due to: #473

Not for this PR though - handling the error as described above would be sufficient.

const HEADER_COLOR: &str = "\x1b[4;92m";
Copy link
Contributor

Choose a reason for hiding this comment

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

In PowerShell on Windows, these codes don't seem to be parsed correctly:

PS C:\Users\orecham> iox2 config show
←[4;92mposix system configuration←[0m

 ←[4;92msystem info←[0m
  ←[0;37mPosixVersion                                      ←[0m ←[0;94m200809←[0m
  ←[0;37mPageSize                                          ←[0m ←[0;94m4096←[0m
  ←[0;37mNumberOfClockTicksPerSecond                       ←[0m ←[0;94m0←[0m
  ←[0;37mNumberOfCpuCores                                  ←[0m ←[0;94m16←[0m

 ←[4;92mlimits←[0m
  ←[0;37mMaxLengthOfHostname                               ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxLengthOfLoginName                              ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfSupplementaryGroupIds                  ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfOpenFiles                              ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfSimultaneousProcessesPerUser           ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxLengthOfArguments                              ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfOpenStreams                            ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfSymbolicLinks                          ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxLengthOfTerminalDeviceName                     ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfBytesInATimezone                       ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfSemaphores                             ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxSemaphoreValue                                 ←[0m ←[0;94m2147483646←[0m
  ←[0;37mMaxNumberOfOpenMessageQueues                      ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxMessageQueuePriority                           ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxNumberOfThreads                                ←[0m ←[0;94m1024←[0m
  ←[0;37mMaxSizeOfPasswordBuffer                           ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxSizeOfGroupBuffer                              ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxPathLength                                     ←[0m ←[0;94m260←[0m
  ←[0;37mMaxFileNameLength                                 ←[0m ←[0;94m[ unlimited ]←[0m
  ←[0;37mMaxUnixDomainSocketNameLength                     ←[0m ←[0;94m108←[0m
  ←[0;37mMinStackSizeOfThread                              ←[0m ←[0;94m1048576←[0m

 ←[4;92moptions←[0m
  ←[0;90mAdvisoryInfo                                      ←[0m ←[0;90mfalse←[0m
  ←[0;90mCpuTime                                           ←[0m ←[0;90mfalse←[0m
  ←[0;90mFsync                                             ←[0m ←[0;90mfalse←[0m
  ←[0;90mIpv6                                              ←[0m ←[0;90mfalse←[0m
  ←[0;90mMemLock                                           ←[0m ←[0;90mfalse←[0m
  ←[0;90mMemLockRange                                      ←[0m ←[0;90mfalse←[0m
  ←[0;90mMessagePassing                                    ←[0m ←[0;90mfalse←[0m
  ←[0;90mPrioritizedIo                                     ←[0m ←[0;90mfalse←[0m
  ←[0;90mPriorityScheduling                                ←[0m ←[0;90mfalse←[0m
  ←[0;90mRegularExpressions                                ←[0m ←[0;90mfalse←[0m
  ←[0;90mSpawn                                             ←[0m ←[0;90mfalse←[0m
  ←[0;90mProcessSporadicServer                             ←[0m ←[0;90mfalse←[0m
  ←[0;90mSynchronizedIo                                    ←[0m ←[0;90mfalse←[0m
  ←[0;90mThreadStackAddress                                ←[0m ←[0;90mfalse←[0m
  ←[0;90mThreadStackSize                                   ←[0m ←[0;90mfalse←[0m
  ←[0;90mThreadCpuTimeClock                                ←[0m ←[0;90mfalse←[0m
  ←[0;90mThreadExecutionScheduling                         ←[0m ←[0;90mfalse←[0m
  ←[0;90mThreadProcessSharedSynchronization                ←[0m ←[0;90mfalse←[0m
  ←[0;90mMutexPriorityInheritance                          ←[0m ←[0;90mfalse←[0m
  ←[0;90mMutexPriorityProtection                           ←[0m ←[0;90mfalse←[0m
  ←[0;90mRobustMutexPriorityInhertiance                    ←[0m ←[0;90mfalse←[0m
  ←[0;90mRobustMutexPriorityProtection                     ←[0m ←[0;90mfalse←[0m
  ←[0;90mThreadSporadicServer                              ←[0m ←[0;90mfalse←[0m
  ←[0;90mTrace                                             ←[0m ←[0;90mfalse←[0m
  ←[0;90mTraceEventFilter                                  ←[0m ←[0;90mfalse←[0m
  ←[0;90mTraceInherit                                      ←[0m ←[0;90mfalse←[0m
  ←[0;90mTraceLog                                          ←[0m ←[0;90mfalse←[0m
  ←[0;90mTypedMemoryObjects                                ←[0m ←[0;90mfalse←[0m

 ←[4;92mfeatures←[0m
  ←[0;37mBarriers                                          ←[0m ←[0;94mtrue←[0m
  ←[0;90mAsynchronousIo                                    ←[0m ←[0;90mfalse←[0m
  ←[0;90mClockSelection                                    ←[0m ←[0;90mfalse←[0m
  ←[0;90mJobControl                                        ←[0m ←[0;90mfalse←[0m
  ←[0;37mMappedFiles                                       ←[0m ←[0;94mtrue←[0m
  ←[0;90mMemoryProtection                                  ←[0m ←[0;90mfalse←[0m
  ←[0;90mMonotonicClock                                    ←[0m ←[0;90mfalse←[0m
  ←[0;90mRawSockets                                        ←[0m ←[0;90mfalse←[0m
  ←[0;37mReaderWriterLocks                                 ←[0m ←[0;94mtrue←[0m
  ←[0;90mRealtimeSignals                                   ←[0m ←[0;90mfalse←[0m
  ←[0;90mSavedUserAndGroupIds                              ←[0m ←[0;90mfalse←[0m
  ←[0;37mSemaphores                                        ←[0m ←[0;94mtrue←[0m
  ←[0;37mSharedMemoryObjects                               ←[0m ←[0;94mtrue←[0m
  ←[0;90mShell                                             ←[0m ←[0;90mfalse←[0m
  ←[0;37mSpinLocks                                         ←[0m ←[0;94mtrue←[0m
  ←[0;37mThreadSafeFunctions                               ←[0m ←[0;94mtrue←[0m
  ←[0;90mThreads                                           ←[0m ←[0;90mfalse←[0m
  ←[0;37mTimeouts                                          ←[0m ←[0;94mtrue←[0m
  ←[0;37mTimers                                            ←[0m ←[0;94mtrue←[0m
  ←[0;90mOpenRealtimeOptionGroup                           ←[0m ←[0;90mfalse←[0m
  ←[0;90mOpenRealtimeThreadsOptionGroup                    ←[0m ←[0;90mfalse←[0m

 ←[4;92mprocess resource limits←[0m
  ←[0;37mMaxCoreFileSize                            ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m
  ←[0;37mMaxConsumableCpuTime                       ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m
  ←[0;37mMaxDataSegmentSize                         ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m
  ←[0;37mMaxFileSize                                ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m
  ←[0;37mMaxNumberOfOpenFileDescriptors             ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m
  ←[0;37mMaxStackSize                               ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m
  ←[0;37mMaxSizeOfTotalMemory                       ←[0m soft:  ←[0;94m0                       ←[0m hard:  ←[0;94m0←[0m

A crate like colored, like used in the rest of the CLI, should be used for cross-platform coloring.

I know this is not your code, but this would need to be updated for UX purposes on Windows.

const VALUE_COLOR: &str = "\x1b[0;94m";
const DISABLED_VALUE_COLOR: &str = "\x1b[0;90m";
const ENTRY_COLOR: &str = "\x1b[0;37m";
const DISABLED_ENTRY_COLOR: &str = "\x1b[0;90m";
const COLOR_RESET: &str = "\x1b[0m";

println!("{}posix system configuration{}", HEADER_COLOR, COLOR_RESET);
println!();
println!(" {}system info{}", HEADER_COLOR, COLOR_RESET);
for i in all::<SystemInfo>().collect::<Vec<_>>() {
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.value(),
);
}

println!();
println!(" {}limits{}", HEADER_COLOR, COLOR_RESET);
for i in all::<Limit>().collect::<Vec<_>>() {
let limit = i.value();
let limit = if limit == 0 {
"[ unlimited ]".to_string()
} else {
limit.to_string()
};
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
limit,
);
}

println!();
println!(" {}options{}", HEADER_COLOR, COLOR_RESET);
for i in all::<SysOption>().collect::<Vec<_>>() {
if i.is_available() {
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
} else {
println!(
" {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
}
}

println!();
println!(" {}features{}", HEADER_COLOR, COLOR_RESET);
for i in all::<Feature>().collect::<Vec<_>>() {
if i.is_available() {
println!(
" {ENTRY_COLOR}{:<50}{COLOR_RESET} {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
} else {
println!(
" {DISABLED_ENTRY_COLOR}{:<50}{COLOR_RESET} {DISABLED_VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.is_available(),
);
}
}

println!();
println!(" {}process resource limits{}", HEADER_COLOR, COLOR_RESET);
for i in all::<ProcessResourceLimit>().collect::<Vec<_>>() {
println!(
" {ENTRY_COLOR}{:<43}{COLOR_RESET} soft: {VALUE_COLOR}{:<24}{COLOR_RESET} hard: {VALUE_COLOR}{}{COLOR_RESET}",
format!("{:?}", i),
i.soft_limit(),
i.hard_limit()
);
}
}

pub fn show() -> Result<()> {
print_system_configuration();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this print the default in-built config if there is no config file being loaded from file?

Copy link
Author

Choose a reason for hiding this comment

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

print_system_configuration() displays the whole system configuration with all limits, features and details to the console. It does not print the built-in config but the system configuration. print_system_configuration() function is independent of the config file.

Copy link
Contributor

Choose a reason for hiding this comment

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

@elfenpiff Should the defaults be added to the output of iox2 config show, under a different sub-heading ? I would think yes, but what did you have in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

@elfenpiff Will need your feedback on this. What was your intention for this command?

Copy link
Contributor

@elfenpiff elfenpiff Oct 30, 2024

Choose a reason for hiding this comment

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

@elfenpiff I implemented this to provide me with some debug output of the configuration of the POSIX system, meaning the POSIX configuration that states like how many semaphores can be created or what the maximum value of a semaphore could be.

Windows, Mac Os, FreeBSD, and Linux have different values here, and in the early days of iceoryx2, it was very helpful when analyzing bugs. Now, everything is abstracted away with the iceoryx2_pal and iceoryx2_cal layer but this still makes sense for mission-critical environments where we define the minimum requirements we have for the system (somewhere) and then this would print out the systems requirement and would also highlight the things which would violate our requirements.

A practical example is the iceoryx2_bb_threadsafe::trigger_queue. It uses two semaphores to trigger the producer/consumer when changes happen. But when the semaphores max value is 1024 it means the trigger queue can have a capacity of at most 1024 elements, otherwise the underlying semaphore would overflow and break the queue.

Another example is a gateway. When this subscribes to thousands of services it must be able to memory map thousands of shared memories and also hold thousands of fd's. By default the max number of fd's is 1024 so here it may makes sense to print a warning on gateway startup when the config does not fit.

Copy link
Contributor

Choose a reason for hiding this comment

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

@elfenpiff Apologies, what is your advice here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@orecham My apologies!

Should the defaults be added to the output of iox2 config show, under a different sub-heading ?

Yes, this would make sense.

Copy link
Author

Choose a reason for hiding this comment

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

@elfenpiff My apologies, did you say I had to set up a new subtitle? Like “iox2 config show default” which shows the default configuration? Am I right ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@brosier01 Yeah, if you could additionally print the contents of the config file under another subtitle, this would be perfect.

Let us know if you hit problems or it turns out more difficult than it seems.


Ok(())
}

pub fn generate() -> Result<()> {
orecham marked this conversation as resolved.
Show resolved Hide resolved
let default_file_path = Path::new("config/iceoryx2.toml");
orecham marked this conversation as resolved.
Show resolved Hide resolved

let default_config = Config::default();

let toml_string = toml::to_string_pretty(&default_config)?;

let mut file = File::create(&default_file_path)?;
brosier01 marked this conversation as resolved.
Show resolved Hide resolved
file.write_all(toml_string.as_bytes())?;

println!(
"Default configuration is generated at {}",
default_file_path.display()
);

Ok(())
}
Loading