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

[Extensibility] Zeroconf #163

Closed
wants to merge 38 commits into from
Closed

[Extensibility] Zeroconf #163

wants to merge 38 commits into from

Conversation

DazWilkin
Copy link
Contributor

Implements: #132

What this PR does / why we need it:

Provides a Linux-only Zeroconf protocol implementation for Akri

Special notes for your reviewer:

I've tried (!) to avoid repeating some of the commitment feedback from http-extensibility.

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • added code adheres to standard Rust formatting (cargo fmt)
  • code builds properly (cargo build)
  • code is free of common mistakes (cargo clippy)
  • all Akri tests succeed (cargo test)
  • inline documentation builds (cargo doc)
  • version has been updated appropriately (./version.sh)

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ZeroconfDiscoveryHandlerConfig {
pub filter: String,
Copy link
Collaborator

@bfjelds bfjelds Dec 9, 2020

Choose a reason for hiding this comment

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

it looks like the zeroconf crate supports several filters and this is leveraging that ... is the crate's filter syntax well known? if not, we might consider using the filter constructs that onvif and udev use (which allow inclusion and exclusion).

could be something like:

pub struct ZeroconfDiscoveryHandlerConfig {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub names: Option<FilterList>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub domains: Option<FilterList>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kinds: Option<FilterList>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ports: Option<FilterList>,
}

the crate search code could run without filter, and the discovery handler could filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I like this. I wish I'd thought of it. It's cleaner and clearer than what I have. I'll incorporate. Thank you.

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 think much better, thank you!

Fixed: ea19332

@@ -0,0 +1,18 @@
apiVersion: akri.sh/v0
Copy link
Collaborator

@bfjelds bfjelds Dec 9, 2020

Choose a reason for hiding this comment

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

we should move this to deployment/helm/templates/zeroconf.yaml and parameterize it like the onvif/udev

@bfjelds
Copy link
Collaborator

bfjelds commented Dec 11, 2020

@DazWilkin, that explanation is super helpful.

Can you quantify the bloat a little? Maybe let us know what the agent footprint is before the change and after the change (maybe for both debug and release, but most importantly for release).

I think if the bloat isn't obscene, we are happy to take it on for the moment.

In the near future, we hope to implement a solution to our monolithic problem :)

@DazWilkin
Copy link
Contributor Author

Before the change is what you have now.

With zeroconf, the agent is running 829MB. It's probably that this could be improved but I'm unfamiliar with these deps.

I think perhaps, more importantly, agent users would get e.g. zeroconf regardless (as p/o the monolith) whether they want it.

And so they get any increased size but they also get its security profile and risk its CVEs.

To be clear, this is a consequence of the monolith not zeroconf but it raises the reasonable (enterprise) customer concern "Why do we need to patch the agent for a zeroconf exploit that we're not using?"

@DazWilkin
Copy link
Contributor Author

I have an old v0.0.38-amd64 of the agent that is 126MB.

@bfjelds
Copy link
Collaborator

bfjelds commented Dec 11, 2020

I just built locally and see that without your changes:

debug (cargo build --bin=agent): 352M
release (cargo build --bin=agent --release): 23M

can you build with --release and report how big it is?

@DazWilkin
Copy link
Contributor Author

I get 21M (!?) but isn't the issue the image size?

@bfjelds
Copy link
Collaborator

bfjelds commented Dec 12, 2020

I get 21M (!?) but isn't the issue the image size?

You are totally right. Sorry, the old app programmer in me hasn't fully given way to this new world yet.

Copy link
Contributor Author

@DazWilkin DazWilkin left a comment

Choose a reason for hiding this comment

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

I get 21M (!?) but isn't the issue the image size?

You are totally right. Sorry, the old app programmer in me hasn't fully given way to this new world yet.

Nothing to apologize for :-)

@bfjelds
Copy link
Collaborator

bfjelds commented Dec 14, 2020

I get 21M (!?) but isn't the issue the image size?

You are totally right. Sorry, the old app programmer in me hasn't fully given way to this new world yet.

Nothing to apologize for :-)

With a bit more time thinking, my gut says that we should hit the pause button on this until we get a different extensibility model that would allow this provider to be more on-demand. But I'll pull more people into this discussion to see if we can get more heads involved.

@kate-goldenring
Copy link
Contributor

I get 21M (!?) but isn't the issue the image size?

You are totally right. Sorry, the old app programmer in me hasn't fully given way to this new world yet.

Nothing to apologize for :-)

With a bit more time thinking, my gut says that we should hit the pause button on this until we get a different extensibility model that would allow this provider to be more on-demand. But I'll pull more people into this discussion to see if we can get more heads involved.

I agree that this might expand the size of the Agent too much. Maybe we can do the following:

  1. Investigate which of the Zeroconf crate dependencies is blowing up the size
  2. Determine whether the astro-dns dependencies are smaller. @DazWilkin did you resolve the issue you were having getting astro-dns to work
  3. If neither of the first 2 are conclusive, wait until we have an extensibility model

@DazWilkin
Copy link
Contributor Author

Comment threading would be useful, nah?

The zeroconf crate stipulates dependencies (link) but, I have been able to tweak these:

  • Build: clang, libavahi-client-dev
  • Run: avahi-daemon, libavahi-client-dev

The agent's Dockerfile does not appear to be multistage but adding:

  • Agent: clang, libavahi-client-dev, avahi-daemon

Reduces the image size to 476MB

For a multi-stage build test, the image size was 206MB but this may be unrealistic.

I've received no response to my issue on astro-dnssd.

The issue is likely to arise with any extensions that are added to the Agent while it's a monolith. Zeroconf is likely just the first.

@bfjelds
Copy link
Collaborator

bfjelds commented Dec 19, 2020

The issue is likely to arise with any extensions that are added to the Agent while it's a monolith. Zeroconf is likely just the first

No doubt. Getting a working gRPC interface into the Agent to allow out-of-proc discovery would be a valuable addition ASAP!!

@kate-goldenring kate-goldenring linked an issue Jan 11, 2021 that may be closed by this pull request
@kate-goldenring kate-goldenring linked an issue Jan 11, 2021 that may be closed by this pull request
@kate-goldenring
Copy link
Contributor

Hi @DazWilkin ! The new DiscoveryHandler model has been merged. Its a big change, so I put together a document with the steps to get this PR into the new mold. Let me know how I can help -- I could put PR's into yours with the nitty stuff like a Helm template for the Configuration. Rebasing is going to be tricky, and I wonder if creating a new PR is better.

@DazWilkin
Copy link
Contributor Author

DazWilkin commented Mar 12, 2021

Awesome work!

As you know I've had a look at your HTTP example and the gRPC-based DiscoveryHandler is great.

I think I/we should close this PR.

I'm working on another project at the moment and it's unclear when I'll get time to rewrite the Zeroconf protocol.

If I do get an opportunity, this will be top of my Akri list.

@kate-goldenring
Copy link
Contributor

kate-goldenring commented Mar 12, 2021

Awesome work!

As you know I've had a look at your HTTP example and the gRPC-based DiscoveryHandler is great.

I think I/we should close this PR.

I'm working on another project at the moment and it's unclear when I'll get time to rewrite the Zeroconf protocol.

If I do get an opportunity, this will be top of my Akri list.

Sounds good to me! I'll let you hit the close button @DazWilkin

@DazWilkin DazWilkin closed this Mar 12, 2021
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.

Modularize Discovery Protocols as Pods [Zeroconf] WebThings are discoverable using mDNS|SD
3 participants