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

linkd #779

Merged
merged 6 commits into from
Sep 14, 2021
Merged

linkd #779

merged 6 commits into from
Sep 14, 2021

Conversation

xla
Copy link
Contributor

@xla xla commented Sep 1, 2021

First iterative implementation of RFC 0696 focusing on driving the core
peer protocol and establishing the harness for configuration of a running node.
Rite of passage for it was the replacement of the ephemeral peer in the e2e
networkss, as that required a well behaved peers with a set of knobs exposed.

Structurally the majority implementation lives in a library crate linkd-lib -
probably the most horrendous crate name in this repo to date - with a newly
created workspace under bins and a linkd crate in wrapping it lightly in a
main. That strategy allows for a checked-in Cargo.lock for binaries
associated with link project. Beyond that the code is rather Mario-esque as it
is primarily plumbing of code that either existed in other crates backing
binaries or newish code doing the same thing for core pieces.

There are still large pieces missing, which a tracked in #722 and will be
piled on-top as patches to keep this already big delta focused. The declared
initial goal is to get linkd into a state where it can run as bootstrap/seed
node.

@xla xla self-assigned this Sep 1, 2021
@xla xla force-pushed the xla/linkd branch 10 times, most recently from c0eef53 to f3233fe Compare September 7, 2021 07:45
Copy link
Contributor

@FintanH FintanH left a comment

Choose a reason for hiding this comment

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

Just some small things so far, but it's looking like it's coming together :)

clib/src/keys.rs Outdated Show resolved Hide resolved
librad/src/profile.rs Show resolved Hide resolved
bins/Cargo.toml Outdated Show resolved Hide resolved
linkd/src/args.rs Outdated Show resolved Hide resolved
linkd/src/args.rs Outdated Show resolved Hide resolved
linkd/src/cfg/seed.rs Outdated Show resolved Hide resolved
linkd/src/lib.rs Outdated Show resolved Hide resolved
@xla xla force-pushed the xla/linkd branch 3 times, most recently from 21052f1 to 4350741 Compare September 8, 2021 11:31
@xla xla marked this pull request as ready for review September 9, 2021 09:44
@xla xla requested a review from a team as a code owner September 9, 2021 09:44
@xla xla requested review from alexjg, cloudhead and kim September 9, 2021 09:45
linkd-lib/src/cfg.rs Outdated Show resolved Hide resolved
linkd-lib/src/socket_activation/unix.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
linkd-lib/src/node.rs Outdated Show resolved Hide resolved
linkd-lib/Cargo.toml Outdated Show resolved Hide resolved
linkd-lib/Cargo.toml Outdated Show resolved Hide resolved
/// Forces the creation of a temporary root for the local state, sould be
/// used for debug and testing only.
#[structopt(long)]
pub tmp_root: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, setting this to true will render rad_home a no-op. Perhaps fold into one argument?

linkd-lib/src/args.rs Outdated Show resolved Hide resolved
linkd-lib/src/socket_activation/macos.rs Outdated Show resolved Hide resolved
futures = "0.3"
lazy_static = "1.4"
log = "0.4"
nix = "0.22"
Copy link
Contributor

Choose a reason for hiding this comment

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

Knew I'd bring you around to nix sooner or later :trollface:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not your kind of nix, boy!

// This file is part of radicle-link, distributed under the GPLv3 with Radicle
// Linking Exception. For full terms see the included LICENSE file.

// TODO(xla): Expose discovery args.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these all for the follow-up patches of #722?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With our rapid offboarding of this walled garden I'm uncertain where to track follow-up work. Will go over the TODOs and see if they are out-of-sync with the #722.

linkd-lib/src/args.rs Outdated Show resolved Hide resolved
linkd-lib/src/args.rs Outdated Show resolved Hide resolved
impl Default for MetricsArgs {
fn default() -> Self {
Self {
provider: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

If the above says required_if("metrics-provider", "graphite"), wouldn't it make sense that this should be Some(MetricsProvider::Graphite) since the address is provided below? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I haven't found a way to enforce a heuristic a la: only expect X when Y is set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, I meant the way one would usually do this is by packing it as an enum variant, right?

enum Provider {
   Graphite { address: String }
}

but that doesn't fly if we want flattened args, so I guess we're between a rock and a hard place :) I wonder would it make sense to have the graphite_addr as Option as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be I'm holding the Structops wrong but that would conflict with the need to default to the local graphite instance if graphite is set as a metric provider.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking is that if metrics-provider is set to "graphite" then you'll end up with Some(MetricsProvider::Graphite) and then the address will be Some("localhost:8080") (or whatever the port is). And on the flip-side, if metrics-provider is None then graphite_addr is also, rightfully, None.

That being said this is not a big deal, and should not be a blocker :) Just musing about what's the best way to represent the data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow how you'd express that with the structopt primitives.

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion is:

#[derive(Debug, Eq, PartialEq, StructOpt)]
pub struct MetricsArgs {
    /// Provider for metrics collection.
    #[structopt(long = "metrics-provider", name = "metrics-provider")]
    pub provider: Option<MetricsProvider>,

    /// Address of the graphite collector to send stats to.
    #[structopt(
        long,
        required_if("metrics-provider", "graphite")
    )]
    pub graphite_addr: Option<String>,
}

/* then the conversion here */
        let metrics = match args.metrics.provider {
            Some(args::MetricsProvider::Graphite) => Some(Metrics::Graphite(
                args.metrics
                    .graphite_addr
                    .unwrap_or("localhost:2003")
                    .to_socket_addrs()?
                    .next()
                    .unwrap(),
            )),
            None => None,
        };

Which is a minor improvement if any. It's just unfortunate that we can't express this better in structopt.

linkd-lib/src/metrics.rs Outdated Show resolved Hide resolved
linkd-lib/src/logging.rs Outdated Show resolved Hide resolved
linkd-lib/src/args.rs Outdated Show resolved Hide resolved
linkd-lib/src/cfg.rs Outdated Show resolved Hide resolved
linkd-lib/src/cfg/seed.rs Outdated Show resolved Hide resolved
linkd-lib/src/cfg/seed.rs Outdated Show resolved Hide resolved
linkd-lib/src/logging.rs Outdated Show resolved Hide resolved
linkd-lib/src/protocol.rs Outdated Show resolved Hide resolved
FintanH
FintanH previously approved these changes Sep 10, 2021
Copy link
Contributor

@FintanH FintanH 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 =] Looking forward to the new age of daemons

FintanH
FintanH previously approved these changes Sep 13, 2021
kim
kim previously approved these changes Sep 13, 2021
@kim
Copy link
Contributor

kim commented Sep 13, 2021

I would, however, appreciate a slightly more condensed commit history.

@xla
Copy link
Contributor Author

xla commented Sep 13, 2021

I would, however, appreciate a slightly more condensed commit history.

I always squash before merge but leave that to the latest point to account for commits addressing feedback.

This comes in handy in places where `Network` is used as input for
parameterisation and therefore needs to be displayed or otherwise
stringly represented.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
It expresses the behaviour more correctly as the implementation of new
is really about finding a sensible default in the presenece of env vars
and other factors.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
Will give callers more control over the handling of that error case, the
author expects this to be an oversight of the original implementation.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
First iterative implementation of RFC 0696 focusing on driving the core
peer protocol and establishing the harness for configuration of a running node.
Rite of passage for it will be replacement of the ephemeral peer in the e2e
networkss, as that requires a well behaved peer with a set of knobs exposed.

Structurally the majority of the implementation lives in a library crate
node-lib. The code is rather Mario-esque as it is primarily plumbing of code
that either existed in other crates backing binaries or newish code doing the
same thing for core pieces.

There are still large pieces missing, which a tracked in #722 and will be
piled on-top as patches to keep this already big delta focused. The declared
initial goal is to get linkd into a state where it can run as bootstrap/seed
node.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
A very thin and light wrapper around the `node::run` exposed from the
node lib crate, so `linkd` exists as a deploy target.

Bootstrapping a whole new workspace which is excluded from root, allows
for a checked in `Cargo.lock` without affecting the lib crates.
Historically this used to be the role of radicle-bins.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
Now that a binary exists which drives the core protocol and has all the
knobs exposed that the e2e network tests want to turn there is no need
anymore for the ad-hocish epehmeral peer implementation.

This concludes the first chapter of linkd's development as the declared
goal of gaining some confidence through at the integration layer for it
succeeded.

Signed-off-by: Alexander Simmerl <a.simmerl@gmail.com>
@xla xla dismissed stale reviews from kim and FintanH via d98fa79 September 14, 2021 13:39
@xla xla force-pushed the xla/linkd branch 2 times, most recently from d98fa79 to 05164e4 Compare September 14, 2021 13:40
@xla xla merged commit 05164e4 into master Sep 14, 2021
@xla xla deleted the xla/linkd branch September 14, 2021 13:55
@github-pages github-pages bot temporarily deployed to github-pages September 14, 2021 13:55 Inactive
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.

None yet

5 participants