project-akri / akri-docs

Documentation for Akri
https://docs.akri.sh/
Apache License 2.0
8 stars 22 forks source link

Missing information in "running locally" from developer guide #47

Closed leoluKL closed 2 years ago

leoluKL commented 2 years ago
  1. Since running akri agent and controller locally is mainly for code development work, it may be better to assume there is no currently installed Akri by helm. That is to say, there is no akri config and akri instance CRD in cluster yet. The document can help developer with instruction step by step, such as setting up CRD, creating akri config instance, then build and run agent or controller.
  2. Before running Akri agent, since it will create a UDS in path as environment variable DISCOVERY_HANDLERS_DIRECTORY, which is set as ~/tmp/akri in document, it will be a helpful note to request reader mkdir the path before running agent locally.
kate-goldenring commented 2 years ago

Hi @leolumicrosoft! Good point that this section is missing steps to install the CRDs and create the discovery handler directory. Would you be interested in adding that?

leoluKL commented 2 years ago

PR is created. Please check

leoluKL commented 2 years ago

I am running in some issue to setup the local running dev environment. Any insight is appreciated. I setup as below steps.

Issue: locally running debug echo discovery handler can not register with also locally running Akri agent, though fully installed Akri by helm runs debug echo discovery correctly.

My steps of setup (in an empty microk8s cluster):

  1. Create config and instance CRD.
  2. Create a debug echo config and apply to cluster:
    helm template akri akri-helm-charts/akri \
    --set debugEcho.configuration.enabled=true \
    --set debugEcho.configuration.brokerPod.image.repository=nginx \
    --set debugEcho.configuration.shared=false \
    --set rbac.enabled=false \
    --set controller.enabled=false \
    --set agent.enabled=false > debugechoconfiguration.yaml
  3. Run Akri agent locally
    cd akri/agent
    sudo -E DEBUG_ECHO_INSTANCES_SHARED=false ENABLE_DEBUG_ECHO=1 RUST_LOG=info METRICS_PORT=8082 KUBECONFIG=~/.kube/config DISCOVERY_HANDLERS_DIRECTORY=~/tmp/akri AGENT_NODE_NAME=vm20 HOST_CRICTL_PATH=/usr/bin/crictl HOST_RUNTIME_ENDPOINT=/var/snap/microk8s/common/run/containerd.sock HOST_IMAGE_ENDPOINT=/var/snap/microk8s/common/run/containerd.sock ~/.cargo/bin/cargo run
  4. Run debug echo discovery handler locally
    cd akri/discovery-handler-modules/debug-echo-discovery-handler
    RUST_LOG=info DEBUG_ECHO_INSTANCES_SHARED=false DISCOVERY_HANDLERS_DIRECTORY=~/tmp/akri AGENT_NODE_NAME=vm20 ~/.cargo/bin/cargo run

    When I noticed that there was no akri instance created as foo1 foo2, I use trace to check. I found that debug echo discovery handler does not really pass registration to Akri agent, though I am sure both is using the same .sock UDS file. I can trace to that in discovery-utils/src/registration_client.rs, register_discovery_handler does not pass below async await so it repeatedly tries registering, what could be the problem for this locally dev environment setup?

    if let Ok(channel) = Endpoint::try_from("dummy://[::]:50051")?
            .connect_with_connector(tower::service_fn(move |_: Uri| {
                tokio::net::UnixStream::connect(super::get_registration_socket())
            }))
            .await
leoluKL commented 2 years ago

Found the reason, it is because the discovery handler is running without sudo permission. I manage to print the tonic error from connect_with_connector as below panicked at 'tonic::transport::Error(Transport, hyper::Error(Connect, Os { code: 13, kind: PermissionDenied, message: "Permission denied" }))'

Then I tried running debug echo discovery handler locally with sudo, and it is successful now and two akri instances were created. I will modify the document as well that discovery handler should be runned using sudo.