Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@JustinBacher
Copy link
Contributor

@JustinBacher JustinBacher commented Jan 27, 2025

I'm submitting a

  • bug fix
  • feature
  • documentation addition

What is the current behavior?

Comtrya currently executes manifests sequentially, running each one in order of their dependencies. This leads to slower execution times when manifests could safely run concurrently.

What is the expected behavior?

Manifests should execute concurrently when they have no dependents.

What is the motivation / use case for changing the behavior?

Faster manifest execution using concurrent processing where possible.

Details:

  • Restructured apply command.
    • Moved DAG to it's own module named dependency_manager
    • Used barriers to stall manifests until dependencies complete
    • Moved manifest exec logic to the manifest struct itself
  • Added single password prompt at beginning to handle child password prompts
    • Since child password prompts get lost in the output it's unclear that a child is waiting on input
  • Added dependencies:
    • rpassword
    • zeroize
    • async-trait

Known Issues / TODO:

  • Need review of any functions still needing to be made async
  • Looking for testing assistance for functionality verification
  • Exec atom currently hangs during execution
    • Currently reading child stdin/stdout eternally
    • Still sends child password prompts to terminal (shouldn't since i have it ask for password up front)

Please tell us about your environment:

Version (comtrya --version): v0.9.1
Operating system: CachyOS

@JustinBacher JustinBacher changed the title Feat: Feat: Concurrent manifest execution Jan 27, 2025
if should_ask_for_pass {
let mut password_manager =
PasswordManager::new(get_privilege_provider(contexts).as_deref())?;
password_manager.prompt("Please enter password:").await?;
Copy link
Member

Choose a reason for hiding this comment

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

This is a problem since the implementation in password_manager.rs is for linux only. Is this due to just testing and development on linux or can this functionality not work on windows/macOS/BSD(s)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to testing on linux only. I'll need to first get linux working then I can work on windows/macOS/BSD. I just don't know how I'm gonna get it to stop asking for password while running elevated commands.

@JustinBacher JustinBacher marked this pull request as draft January 28, 2025 17:33
String::from("--noconfirm"),
String::from("--noprogressbar"),
String::from("--skipreview"),
String::from("--sudoloop"),
Copy link
Contributor Author

@JustinBacher JustinBacher Jan 31, 2025

Choose a reason for hiding this comment

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

So the issue with it asking for password during any package manager operations even though I'm using the PasswordManager is here. Both Paru and Yay use sudo under the hood and since sudo defaults to /dev/tty, it's overriding the piped stdin in exec.

That said the only fix I have been able to come up with (that's worked so far) is this:

...
atom: Box::new(Exec {
    command: String::from("echo"),
    arguments: [
            command: String::from(secret),
            command: String::from("|"),
            command: String::from("paru"),
            ...

I tried immediately writing the secret in exec instead of echoing like this but for some reason sudo isn't picking it up.

This may need similar workarounds for other package managers unless someone can come up with a better way of doing this

@JustinBacher JustinBacher force-pushed the async branch 6 times, most recently from 45e504f to decdbf2 Compare February 7, 2025 09:49
JustinBacher and others added 2 commits February 7, 2025 04:54
Just need to get elevations working correctly and clean things up
@JustinBacher JustinBacher force-pushed the async branch 3 times, most recently from c3deb1c to 2884eeb Compare February 7, 2025 10:52
@martintc
Copy link
Member

martintc commented Feb 8, 2025

Pulled the branch to run it. With just some initial running, I came across this being spit out in the comtrya output.

thread 'tokio-runtime-worker' panicked at /Users/toddmartin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at /Users/toddmartin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.
thread 'tokio-runtime-worker' panicked at /Users/toddmartin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/blocking/shutdown.rs:51:21:
Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.

This looks like it may be a good reference.
https://stackoverflow.com/questions/65426683/why-does-tokio-return-the-error-cannot-drop-a-runtime-in-a-context-where-blocki

This occurs when running

cargo run --bin comtrya -- -vv -d examples/file apply -m file-chown,file-download-chown,file-download,file-unarchive,fileremove,walk

lib/Cargo.toml Outdated
file-owner = "0.1.2"
gix = { version = "0.68.0", features = ["blocking-http-transport-reqwest-rust-tls", "blocking-network-client"] }
gix = { version = "0.68.0", features = [
"blocking-http-transport-reqwest-rust-tls",
Copy link
Contributor Author

@JustinBacher JustinBacher Feb 14, 2025

Choose a reason for hiding this comment

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

Pulled the branch to run it. With just some initial running, I came across this being spit out in the comtrya output.

Just saw this, without testing; it's likely just because of the use of blocking calls from the main branch, I didn't test file downloads or git clones when I was developing. They weren't on my radar. Looks like here and above a couple lines in reqwest both use the blocking protocol and that won't work with async. Probably just changing these will fix it, I'll take a look and correct when I get a chance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gix works with async_std not regular async

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants