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] Compilation errors #71

Merged
merged 10 commits into from
Oct 29, 2020

Conversation

DazWilkin
Copy link
Contributor

@DazWilkin DazWilkin commented Oct 26, 2020

What this PR does / why we need it:

I'm encountering some issues building Nessie and suspect the majority are my noob errors.

However, I suspect nessie_url should be (a) public field

Special notes for your reviewer:

error[E0616]: field `nessie_url` of struct `akri_shared::akri::configuration::NessieDiscoveryHandlerConfig` is private
  --> agent/src/protocols/nessie/discovery_handler.rs:24:14
   |
24 |             .nessie_url
   |              ^^^^^^^^^^ private field

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> agent/src/protocols/nessie/discovery_handler.rs:27:28
   |
27 |         if let Ok(_body) = hyper::Client::new().get(url).compat().await {
   |                            ^^^^^^^^^^^^^^^^^^-- supplied 0 arguments
   |                            |
   |                            expected 1 argument

error[E0599]: no method named `compat` found for struct `hyper::client::FutureResponse` in the current scope
  --> agent/src/protocols/nessie/discovery_handler.rs:27:58
   |
27 |         if let Ok(_body) = hyper::Client::new().get(url).compat().await {
   |                                                          ^^^^^^ method not found in `hyper::client::FutureResponse`

error[E0616]: field `nessie_url` of struct `akri_shared::akri::configuration::NessieDiscoveryHandlerConfig` is private
  --> agent/src/protocols/nessie/discovery_handler.rs:31:47
   |
31 |                 self.discovery_handler_config.nessie_url.clone(),
   |                                               ^^^^^^^^^^ private field

error[E0616]: field `nessie_url` of struct `akri_shared::akri::configuration::NessieDiscoveryHandlerConfig` is private
  --> agent/src/protocols/nessie/discovery_handler.rs:34:48
   |
34 |                 &self.discovery_handler_config.nessie_url,
   |                                                ^^^^^^^^^^ private field

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)

@DazWilkin
Copy link
Contributor Author

DazWilkin commented Oct 26, 2020

And, when used here, DiscoveryResult::new parameter id_to_digest is &str:

  --> agent/src/protocols/nessie/discovery_handler.rs:35:17
   |
35 |                 self.discovery_handler_config.nessie_url,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                 |
   |                 expected `&str`, found struct `std::string::String`
   |                 help: consider borrowing here: `&self.discovery_handler_config.nessie_url`

Fixes? d7567b5

@DazWilkin DazWilkin changed the title public struct && public field? [Extensibility] Compilation errors Oct 26, 2020
@DazWilkin
Copy link
Contributor Author

HashMap::new() has a type of <&str, String> resulting in:

  --> agent/src/protocols/nessie/discovery_handler.rs:36:17
   |
36 |                 props,
   |                 ^^^^^ expected struct `std::string::String`, found `&str`
   |
   = note: expected struct `std::collections::HashMap<std::string::String, _>`
              found struct `std::collections::HashMap<&str, _>`

Fixes? 76ddab1

@DazWilkin
Copy link
Contributor Author

samples/brokers/nessie should be added to the project's Cargo.toml so that protobuf generates nessie.rs via build.rs

Fixed: f818015

Cargo.toml Outdated
members = ["shared", "controller", "agent", "samples/brokers/udev-video-broker", "samples/brokers/nessie" ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think it would be helpful to include actual Nessie code? We have resisted and kept it as a doc sample up to now, but it would be interesting to hear the other side of that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we aren't including the Nessie source code, this probably shouldn't be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One advantage in having the example as code is that you can run it through the CI tool and ensure it builds.

The disadvantage is in needing to chop it up to form the documentation.

There must (!?) be something akin to a Jupyter notebook that can comprise build/run-able code and Markdown as comments that can be rendered on-the-fly as a tutorial.

In this case, the documentation omits this change and, as a result, nessie.rs does not get auto-generated from the proto.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Totally agree with everything you said. 100%.

If we are going to keep this as an md-based how-to, we need to find a way to validate the code changes (and keep them in sync).

Copy link
Contributor

Choose a reason for hiding this comment

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

Validating the changes easily would be a really nice to have.
Since this addition is needed to auto-generate the code, @DazWilkin, could you add a step to the extensibility doc to add nessie to the Cargo.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kate-goldenring I realized that your Dockerfile adds ./samples/brokers/nessie to members for the build to succeed.

So, the developer could either add the project to Cargo.toml?

Or they could cd ./samples/brokers/nessie && cargo build to generate it (while developing).

Do you have a preference? I'll then add.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since anyone doing this will have to build a new agent as well, it seems like adding nessie to the /Cargo.toml's member list makes the most sense.

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 27, 2020

Another issue with extensibility.md: This line:

First, we need to leverage the generated gRPC code by creating `samples/brokers/nessie/src/util/nessie.rs`:

should read (tonic will generate nessie.rs based on the proto file and build.rs):

First, we need to leverage the generated gRPC code by creating `samples/brokers/nessie/src/util/nessie_service.rs`:

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 27, 2020

Another issue: nessie needs to be added to the list of oneOf items in deployment/helm/crds/akri-configuration-crd.yaml:

                   oneOf:
                     - required: ["nessie"]                # <--- add this line
                     - required: ["debugEcho"]
                     - required: ["onvif"]```

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 27, 2020

There is probably a more kuberentes-appropriate way to do this, but for the broker pod to have access to an external site, I had to add hostNetwork: true to the brokerPodSpec:

  brokerPodSpec:
    hostNetwork: true    # <---- 
    containers:
    - name: nessie-broker

@DazWilkin
Copy link
Contributor Author

Assuming the developer creates ./samples/brokers/nessie and ./Dockerfile, they will also need to revise ./dockerignore to not ignore:

!samples/brokers/nessie
!shared/

Addressed: 011f3c8

@DazWilkin
Copy link
Contributor Author

DazWilkin commented Oct 27, 2020

The Dockerfile has some issues:

  • An outdated version of Rust (1.41 vs. 1.47)
  • rustfmt required?
  • Corrected --from=build path /nessie/...
  • I think (!?) ENTRYPOINT >> CMD

Propose: b46aa11

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 27, 2020

I made some other changes to enable SSL from our agent and nessie in Dockerfile.nessie and Dockerfile.agent:

main...bfjelds:bfjelds/test-nessie

@DazWilkin
Copy link
Contributor Author

There is probably a more kuberentes-appropriate way to do this, but for the broker pod to have access to an external site, I had to add hostNetwork: true to the brokerPodSpec:

  brokerPodSpec:
    hostNetwork: true    # <---- 
    containers:
    - name: nessie-broker

I did not have to do this (using MicroK8s)... This may be a constraint with K3s?

@DazWilkin
Copy link
Contributor Author

With these changes from @bfjelds, I'm now working.

However, I was receiving image pull errors for private (!) nessie:latest from GHCR (curiously, I don't recall receiving these yesterday?).

The documentation Install akri with newly built containers considers the need to provide imagePullSecrets for agent and controller when deploying the Helm chart but this is not discussed for same-same deploying nessie.

I think the correct location for imagePullSecrets in Configuration (!) is as below and this likely should be added to the doc:

apiVersion: akri.sh/v0
kind: Configuration
metadata:
  name: nessie
spec:
  protocol:
    nessie:
      nessieUrl: https://www.lochness.co.uk/livecam/img/lochness.jpg
  capacity: 5
  brokerPodSpec:
    imagePullSecrets:
    - name: <your-secret-name>
    containers:
      - name: nessie-broker
        image: "ghcr.io/<your-github-alias>/nessie:latest"
        resources:
          limits:
            "{{PLACEHOLDER}}": "1"
  instanceServiceSpec:
    ports:
      - name: grpc
        port: 80
        targetPort: 8083
  configurationServiceSpec:
    ports:
      - name: grpc
        port: 80
        targetPort: 8083

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 28, 2020

There is probably a more kuberentes-appropriate way to do this, but for the broker pod to have access to an external site, I had to add hostNetwork: true to the brokerPodSpec:

  brokerPodSpec:
    hostNetwork: true    # <---- 
    containers:
    - name: nessie-broker

I did not have to do this (using MicroK8s)... This may be a constraint with K3s?

I still seem to need it for MicroK8s. Maybe I have something else going on ... will need to investigate.

@DazWilkin
Copy link
Contributor Author

There is probably a more kuberentes-appropriate way to do this, but for the broker pod to have access to an external site, I had to add hostNetwork: true to the brokerPodSpec:

  brokerPodSpec:
    hostNetwork: true    # <---- 
    containers:
    - name: nessie-broker

I did not have to do this (using MicroK8s)... This may be a constraint with K3s?

I still seem to need it for MicroK8s. Maybe I have something else going on ... will need to investigate.

Perhaps this? If you're using a corporate host, it may be more secure than your average (e.g. my) installation.

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 28, 2020

There is probably a more kuberentes-appropriate way to do this, but for the broker pod to have access to an external site, I had to add hostNetwork: true to the brokerPodSpec:

  brokerPodSpec:
    hostNetwork: true    # <---- 
    containers:
    - name: nessie-broker

I did not have to do this (using MicroK8s)... This may be a constraint with K3s?

I still seem to need it for MicroK8s. Maybe I have something else going on ... will need to investigate.

Perhaps this? If you're using a corporate host, it may be more secure than your average (e.g. my) installation.

Seems a likely cuplrit. Let's get this PR polished off with what works for you, we can add comments later about corporate hosts.

It seems like this PR is almost there as far as getting Nessie as buttoned up as it can be, just need to update the code with what you have working and swap out the changes in .dockerignore and Cargo.toml for md descriptions of those changes, right?

@DazWilkin
Copy link
Contributor Author

Yes, I think almost everything is represented in the PR 😁

While you're looking through it, containerizing the gRPC implementation could be improved; e.g. where should the Dockerfile be created? I put it in the repo root but I think it belongs in deployment?

I had to clone the Helm chart to test the changes on my GCE instance but that should work from your Helm chart once your changes are in.

I'm willing to clean slate and work through it again once you have everything in place.

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 29, 2020

if we were checking in code changes for nessie (rather than it being md-only), i'd say putting the Dockerfile in /build/containers makes sense (and updating akri-containers.mk).

but i think it is simpler to suggest creating the Dockerfile with the nessie broker code (/samples/brokers/nessie).

if you could remove the changes to .dockerignore and Cargo.toml, i think we can merge this PR.

once the PR is merged, i will start working on the next round of fixes for Nessie (which will include adding notes to extensibility.md about the changes needed in .dockerignore and Cargo.toml). sound good?

@DazWilkin
Copy link
Contributor Author

if we were checking in code changes for nessie (rather than it being md-only), i'd say putting the Dockerfile in /build/containers makes sense (and updating akri-containers.mk).

but i think it is simpler to suggest creating the Dockerfile with the nessie broker code (/samples/brokers/nessie).

if you could remove the changes to .dockerignore and Cargo.toml, i think we can merge this PR.

once the PR is merged, i will start working on the next round of fixes for Nessie (which will include adding notes to extensibility.md about the changes needed in .dockerignore and Cargo.toml). sound good?

My naive approach to "remove changes" is to add more changes undoing them; hope OK? 49ce0a8

@bfjelds
Copy link
Collaborator

bfjelds commented Oct 29, 2020

Perfect!

@bfjelds bfjelds merged commit 09dfcb5 into project-akri:main Oct 29, 2020
@DazWilkin DazWilkin deleted the extensibility branch October 30, 2020 20:50
bfjelds pushed a commit that referenced this pull request Nov 11, 2020
* public struct && public field?

* Wants `&str` rather than `String`

* Fix: mismatched types

* Include "Nessie" in  `Cargo.toml' for `build.rs`

* Required for `HashMap`

* Explain gRPC build and correct `nessie_service.rs`

* Dockerfile

* .dockerignore changes for Nessie

* Fix links

* Two writes (sic.) to undo a commit
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

3 participants