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

Basic clobberd functionality #8

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

ethanf108
Copy link

No description provided.

Copy link
Owner

@WillNilges WillNilges left a comment

Choose a reason for hiding this comment

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

Sleek, crispy, nice.

@WillNilges
Copy link
Owner

Needed to install openssl-devel to fix this error when I was compiling

  run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit status: 1\nerror: could not find system library 'openssl' required by the 'openssl-sys' crate\n\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc'\nto the PKG_CONFIG_PATH environment variable\nPackage 'openssl', required by 'virtual:world', not found\n"

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.80

  ', /users/u26/wilnil/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.80/build/find_normal.rs:191:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@WillNilges
Copy link
Owner

Quite a lot of unused function warnings on compilation. Guessing that's stubbed/TODO? Mind marking it as such to make the compiler stop whining?

Copy link
Owner

@WillNilges WillNilges left a comment

Choose a reason for hiding this comment

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

Nice work. I have some questions and a few nitpicks. Next time I would suggest implementing the base application, and getting that reviewed and merged before adding additional features like pings. It's unclear what exactly is being added beyond what we've already discussed.

In addition to my comments, I also noticed there's no documentation. Can you amend the README with a user guide, maybe do some comments, and make sure the --help command has useful info?

The general philosophy I follow while working on house services, especially brand new ones, is generalizing it enough to be useful to anybody, not just a CSH'er.

src/clobber.rs Outdated Show resolved Hide resolved
src/clobberd.rs Outdated
);
Success
}
#[allow(unreachable_patterns)] //Fallback
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this macro is necessary.

Suggested change
#[allow(unreachable_patterns)] //Fallback

Copy link
Author

Choose a reason for hiding this comment

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

It's to prevent a warning, but fair enough

Copy link
Owner

Choose a reason for hiding this comment

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

I didn't see a specific warning for this when I removed that line and compiled it. Might have to take another look.

src/pod.rs Show resolved Hide resolved
}

pub fn get_config() -> Result<ClobberConfig, String> {
let file = match std::fs::read_to_string("/etc/clobber/config.json") {
Copy link
Owner

Choose a reason for hiding this comment

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

Not a huge fan of hardcoded paths. Make sure you document whatever this file is supposed to be. Better yet, provide an example.

Copy link
Author

Choose a reason for hiding this comment

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

Fair, me neither, but I don't see how we would have a config file without a hardcoded path.

Copy link
Owner

@WillNilges WillNilges Feb 22, 2023

Choose a reason for hiding this comment

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

'spose I'm used to container land where everything is in the same directory :P

Still, please do provide some documentation about this.

Comment on lines +27 to +29
JobCancelled { .. } => "97f166a0-d9f9-4888-b8ad-b09656f19330",
JobStarted { .. } => "f810410a-0dcd-4271-8b75-b6e6ce5ead7e",
JobFinished { .. } => "aab2a0c6-001c-455a-956f-10c8b685fb87",
Copy link
Owner

@WillNilges WillNilges Feb 21, 2023

Choose a reason for hiding this comment

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

I'm extremely wary of hardcoding magic numbers into applications. What is this, and can it be broken out into a config file in a way that is human readable?

Copy link
Author

Choose a reason for hiding this comment

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

I agree, but this is a temporary measure until I find a not terrible way to put this in a config file.

Copy link
Owner

Choose a reason for hiding this comment

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

There's another JSON file in the app somewhere, right? Could you use that?

Alternatively: https://crates.io/crates/config

let client = reqwest::blocking::Client::new();
if let Err(e) = client
.post(format!(
"https://pings.csh.rit.edu/service/route/{}/ping",
Copy link
Owner

Choose a reason for hiding this comment

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

You should break this URL out into a config file as well.

src/pings.rs Outdated Show resolved Hide resolved
@ethanf108
Copy link
Author

This code isn't in a fully finished state. At this point, I'm more developing for myself rather than a PR. While this code is (as far as I'm aware) completely functional, it still needs to be tested and it needs to have more CLI operations implemented.

@WillNilges
Copy link
Owner

This code isn't in a fully finished state. At this point, I'm more developing for myself rather than a PR. While this code is (as far as I'm aware) completely functional, it still needs to be tested and it needs to have more CLI operations implemented.

It'd be easier to review, test, and vet if you split this up into multiple PRs. If you're planning on putting this into production, I'd feel more comfortable if this was done incrementally.

If you'd like, I can pull from your branch and take a crack at pairing it down into more review-able PRs.

@WillNilges
Copy link
Owner

The default command, clobber, currently does nothing. It probably ought to print the help, or perhaps a status.

@WillNilges
Copy link
Owner

Actually, a lot of helps are missing. I don't even know what half of these options do. Please write some docs.

jet:~:% clobber kill --help
Usage: clobber kill

Options:
  -h, --help  Print help
jet:~:% clobber watch --help
Usage: clobber watch --device <DEVICE>

Options:
  -d, --device <DEVICE>
  -h, --help             Print help
jet:~:% clobber watch -d
error: a value is required for '--device <DEVICE>' but none was supplied

@@ -3,5 +3,6 @@
set -e

cargo build --release
sudo install target/release/clobber /usr/local/sbin; echo "Installed clobber."
sudo install target/release/clobber /usr/local/sbin && chmod u+s /usr/local/sbin/clobber && echo "Installed clobber."
Copy link
Owner

Choose a reason for hiding this comment

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

clobber should probably go in /usr/local/bin

@WillNilges
Copy link
Owner

Notes for later, we need to find an elegant way to read and pass data around info from a config file: https://docs.rs/serde_yaml/latest/serde_yaml/

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