Troubleshooting at the Edge
local graph
Chapter 15 — Troubleshooting at the Edge
Section titled “Chapter 15 — Troubleshooting at the Edge”By developing a real-world containerized workload at the Edge, you’ve seen what it takes to deploy and manage Edge services. Throughout this book, we have provided you with practical hands-on guidance as you developed an end-to-end conceptual understanding of the unique opportunities and challenges presented by Edge applications. You may have also noticed that while this book provided a comprehensive framework to manage Edge workloads, we leveraged your existing knowledge of Docker to verify the services and applications as they were built and deployed.
In this chapter, we will further supplement many of the previously mentioned techniques with additional input based on our experience and provide several what-ifs and questions that may arise.
In this chapter, we are going to cover the following main topics:
- Answers to not-so-common questions
- Uninstalling AIO Open Horizon Management Hub
- Edge device Agent verification
Between your experiences in developing and debugging software and the topics covered in this chapter, you should be able to handle most of the common issues that may surface in your Edge solution.
Technical requirements
Section titled “Technical requirements”As before, verify the current setup of the AIO Management Hub and the Edge Agent on your Edge node, as per the instructions provided in Chapter 7, in the Technical requirements section.
This chapter relies on your prior experience in building, deploying, and debugging software in production environments in classic enterprise and Cloud architectures – and especially with container-based microservices.
Answers to not-so-common questions
Section titled “Answers to not-so-common questions”Though we have described the various aspects of the Open Horizon framework throughout the book in detail, we have collected a curated list of questions and answers that might further help you while you’re building, testing, or debugging your Open Horizon deployed application workloads. We have grouped them into various sub-sections for easy reference.
Document references
Section titled “Document references”What parameters are allowed in service.json?
To find out what parameters are allowed in various configuration json files, we recommend that you study the following documents:
- Deployment strings: https://open-horizon.github.io/docs/anax/docs/deployment_string
- Service definition: https://open-horizon.github.io/docs/anax/docs/service_def/#service-definition
More information related to the Open Horizon Agent can be found at https://open-horizon.github.io/docs/anax/docs/#anaxdocs
The latest documentation that covers the entirety of Open Horizon can be found at https://open-horizon.github.io/.
Moreover, additional information can be found in the IBM Edge Application Manager commercial distribution of Open Horizon: https://www.ibm.com/docs/en/eam/4.5.
The Open Horizon open source community’s support resources can be found at https://open-horizon.github.io/docs/troubleshoot/support/.
Edge Agent
Section titled “Edge Agent”What is the minimum software requirement to install and run an Edge device Agent?
The minimum requirement to install and run the Edge Agent is to have a Linux-based Edge device with systemd and the Docker runtime environment.
How can I add a new non-root user in Ubuntu?
As we have advocated in this book, we recommend that you operate Open Horizon using a non-root user with sudo privileges. Here are some helpful commands you can use to add a non-root user in Ubuntu. Other variants of Linux will have similar commands, and there may be other ways of achieving this as well:
useradd -s /bin/bash -d /home/<userid> -m -G sudo <userid>usermod -g users <userid>passwd <userid>usermod -aG docker <userid>How do I know if my Linux system is running in init.d or systemd?
While we have emphasized the need for a Linux host machine based on systemd, let’s look at some commands you can use to find out what is supported on your machine. While there may be other methods, we have found the following helpful.
Run the following command to find out if init.d (upstart) is running:
[[ \`/sbin/init --version\` =~ upstart ]] && echo yes || echo noRun the following command to find out if systemd is running:
[[ \`systemctl\` =~ -\.mount ]] && echo yes || echo noA yes or no output quickly confirms the presence or absence of what is running on your system.
Running the agent-install.sh script gives an error on my version of Linux. How can I install the Edge Agent?
Given so many variations of Linux, the Open Horizon team tries to verify many such systems but not all by default. However, they do provide several options that you can use to override the current defaults and try them in your environment. Significant among those are the following options. Many of these can be provided using either the command-line option or by setting up corresponding ENVIRONMENT variables. The following has been taken from the agent-install.sh script:
SUPPORTED_DEBIAN_VARIANTS_APPEND: A Debian variant that should be added to the default list:ubunturaspbian debian.SUPPORTED_DEBIAN_VERSION_APPEND: A Debian version that should be added to the default list:bullseye jammy focal bionic buster xenialstretch bookworm.SUPPORTED_DEBIAN_ARCH_APPEND: A Debian architecture that should be added to the default list:amd64 arm64armhf s390x.SUPPORTED_REDHAT_VARIANTS_APPEND: A Red Hat variant that should be added to the default list:rhel redhatenterprisecentos fedora.SUPPORTED_REDHAT_VERSION_APPEND: A Red Hat version that should be added to the default list:7.6 7.9 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 9.0 9.1 9.2 9.3 8 9 32 35 3637 38.SUPPORTED_REDHAT_ARCH_APPEND: A Red Hat architecture that should be added to the default list:x86_64 aarch64 ppc64les390x riscv64.
See ./agent-install.sh –h in your Open Horizon installation directory for more details.
How can I install just the hzn CLI and not the complete Edge Agent?
Typically, when the Edge Agent is installed, the hzn CLI is also installed as part of the Agent installation process. It is possible that you may want to just install the hzn CLI and not the Edge Agent. To accomplish this, perform the following steps:
- Access the installable package at https://github.com/open-horizon/anax/releases.
- Locate the architecture, the version number, and the Linux variant that you want to install. Then, use
curlto download the package. An example command has been provided here. Change the various valuescurl -LO https://github.com/open-horizon/anax/releases/download/v2.30.0-1491/horizon-agent-linux-deb-amd64.tar.gz - Unzip and untar the downloaded package into a directory using the
tar zxvf horizon-agent-linux-deb-amd64.tar.gz
- Install the
hznCLI using a package installer that’s suitable for your Edge device’s host Linux variant and architecture. For example, the command to install thehznCLI on Ubuntu issudo apt install ./horizon-cli*.deb
After installation, you can run hzn –h to do a quick verification, as shown in Chapter 8, in the Using the Open Horizon CLI and API section.
How do I register an Edge device node name?
You can create a node name before registering an Edge node using the following command:
export HZN_EXCHANGE_NODE_AUTH=<desired-node-name>:<node-auth>hzn exchange node create -n $HZN_EXCHANGE_NODE_AUTHSee hzn exchange node create –h for further details.
Service publishing
Section titled “Service publishing”How can I create the signing key to publish a service?
To create a signing key, use the following command:
hzn key create <organisation-name> <your-email-id>See hzn key create –h for more details.
How do I set up an authenticated container registry for Docker container images?
It may be tempting to use Docker Hub, or a similar image container registry, without authentication to manage non-proprietary container images when publishing services in Open Horizon – especially when you are first learning about Edge computing. However, we recommend that you use an authenticated registry for your proprietary images in your production environment. You will need to provide read-only credentials so that the Edge Agent can pull the image from the authenticated container image registry. The authentication credentials to be used by the Edge node are kept securely in the Open Horizon Management Hub.
While publishing a service, you must provide container registry credentials using the –r options, as follows:
hzn exchange service publish -r "<container-registry-and-credential" -f service.definition.json --pull-imageIt’s always a good idea to verify the container registry’s credentials beforehand outside of Open Horizon to ensure their validity by using normal docker commands such as the following:
docker login ...docker push <image>docker pull <image>See hzn exchange service publish –h for more details.
Pattern-based service deployment
Section titled “Pattern-based service deployment”After registering an Edge device with a pattern, even though the node is registered, no agreement is listed – why?
If any of the application’s services require privileged access, then you must register the Edge node with a node policy; otherwise, no agreement will be listed, and no container image will be downloaded on your Edge device node.
For pattern-based deployment, register with a privilege policy that sets the openhorizon.allowPrivileged node property to true.
For example, the node_policy_privileged.json node policy file should have the following properties set at a minimum:
{ "properties": [ { "name": "openhorizon.allowPrivileged", "value": true } ]}Then, register the Edge device with the following command:
hzn register -p <pattern-name> --policy=node_policy_privileged.json -f <user-input.json>The name of the node policy file, node_policy_privileged.json, is arbitrary and the filename could be anything else.
See hzn register –h for more details.
Model management system
Section titled “Model management system”Where does the model management system store data on an edge device node?
Sometimes, you may need to debug the ML model publishing process, and it would be helpful to know the directory location where the newly delivered ML model is saved locally on an Edge device node. The location is a root -protected directory, and the content can be viewed as follows:
sudo ls -Rla /var/horizon/ess-store/sync/localDocker usage
Section titled “Docker usage”When I run the docker ps command as a non-root user, it gives me an error. How can that be fixed?
The reason for this error is that your non-root userid is not in the docker group. To fix this error, add your userid to the docker group by running the following command. Note that you will need sudo access since this is required for installing the Edge Agent:
sudo usermod -aG docker <user-id>You must log back into the Edge device node for the Linux group to become effective. Usually, such settings should be done in the initial stages as you set up your Edge device node for development.
How can I install Docker on my Edge device?
One of the easiest ways to install docker is to run the following command on your Edge device. This will install any necessary dependencies and Docker Engine itself.
After installing Docker, it’s a good idea to add your non-root userid to the Docker group and then re-login, as explained previously:
curl -fsSL get.docker.com | shsudo usermod -aG docker <userid>When I deploy a complex application with many containers using Open Horizon, I see the following error. How do I fix that?
Though this is not directly an Open Horizon error, it is possible that when you deploy a complex application with many services, you may see the following error:
"Error starting containers: API error (404): could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network"The reason for this error is that not enough addresses are available for the Docker network. To fix this, you must do the following:
- Run
ifconfigand find out thedocker0inetaddress. - Create or edit the
/etc/docker/daemon.jsonfile to add an increased pool size for the subnet. You may adjust the CIDR and size value. Use a private IP address range, depending on the address space in class A (10.0.0.0), class B (172.17.0.0), or class C (192.168.0.0). The following two examples are based on the address class that may be running on the Edge device. Here’s the first example:The file’s content may also look like this:{"default-address-pools": [{"base": "172.17.0.0/12","size": 20}]}{"default-address-pools": [{"base": "172.17.0.0/12","size": 20},{"base": "192.168.0.0/16","size": 24}]}
In this section, we provided a set of testing and debugging questions that we found our users running into and the answers for these questions were not that obvious for first-time users. Experienced users may not need this handholding, but we realized these might help those who are starting to use Open Horizon in earnest.
Uninstalling Open Horizon Management Hub
Section titled “Uninstalling Open Horizon Management Hub”In the Installing All-In-One (AIO) Open Horizon Management Hub section of Chapter 6, we learned how to install AIO Open Horizon Management Hub. Though the Open Horizon Management Hub may not need to be uninstalled once it’s running, it is good to know how this can be done just in case.
If you run the deploy-mgmt-hub.sh script with the –h option, you will notice that the same script has an uninstall option that can be invoked using the -S and - P options.
As you may have noticed in Chapter 6, the installation process allocates disk volumes and runs various containers that make up the components of the Open Horizon Management Hub. The uninstallation process does the reverse by stopping the containers, and then purging the volumes and the images. Run the following command to stop and uninstall the Management Hub:
sudo -s -E ./deploy-mgmt-hub.sh -S -PYou will see an output similar to the following:
------- Checking input and initializing...Management hub services will listen on http://<ip-address-of-the-host>Updating apt-get package index...Installing prerequisites, this could take a minute...Certificate /etc/horizon/keys/horizonMgmtHubFDO.crt already exists, so not receating it------- Downloading template files...Substituting environment variables into template files...------- Stopping Horizon services...Unregistering this node, cancelling all agreements, stopping all workloads, and restarting Horizon...Waiting for Horizon node unregister to complete: No Timeout specified ...Waiting for Horizon node unregister to complete: No Timeout specified ...Waiting for agent service to restart and checking the node configuration state...Horizon node unregistered. You may now run 'hzn register ...' again, if desired.Stopping the Horizon agent...Uninstalling the Horizon agent and CLI...Stopping Horizon management hub services and deleting their persistent volumes...Removing network hzn_horizonnetWARNING: Network hzn_horizonnet not found.Removing volume hzn_postgresRemoving volume hzn_postgresvolfdoRemoving volume hzn_mongovolRemoving volume hzn_agbotmsgkeyvolRemoving volume hzn_fdo-ocs-dbRemoving volume hzn_vaultvolRemoving Open-horizon Docker images...After the uninstallation is complete, you can run docker ps to verify that the corresponding containers aren’t running anymore.
Edge device agent verification
Section titled “Edge device agent verification”In Chapter 6, you installed the Edge Agent using the agent-install.sh script and have been using that throughout several exercises and the example applications that you deployed.
You can verify that the Edge Agent is running on an Edge device by running a process check via ps or by running the systemctl status command.
The Edge Agent runs as an anax command and can be easily viewed by running the following ps command:
ps -aef | grep anaxYour output should look like this:
root 4143 1 0 06:35 ? 00:04:07 /usr/horizon/bin/anax -v 3 -logtostderr -config /etc/horizon/anax.jsonhorizon 7984 6613 0 06:35 ? 00:00:00 /bin/bash /home/agentuser/anax.service starthorizon 8100 7984 0 06:35 ? 00:03:45 /usr/horizon/bin/anax -v 3 -logtostderr -config /etc/horizon/anax.jsonhorizon 1799912 1682936 0 17:49 pts/0 00:00:00 grep --color=auto anaxYou can check its status using the following command:
systemctl status horizonYour output should look like this:
horizon.service - Service for Horizon control system Loaded: loaded (/lib/systemd/system/horizon.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2024-05-21 06:35:24 PDT; 11h ago Main PID: 4143 (anax) Tasks: 11 (limit: 9306) Memory: 14.4M CGroup: /system.slice/horizon.service └─4143 /usr/horizon/bin/anax -v 3 -logtostderr -config /etc/horizon/anax.jsonMay 21 17:49:41 <device-name> anax[4143]: I0521 17:49:41.987083 4143 worker.go:363] CommandDispatcher: ExchangeMessages command processor non-blocking for commandsMay 21 17:49:48 <device-name> anax[4143]: I0521 17:49:48.675114 4143 governance.go:1478] GovernanceWorker: GovernanceWorker dispatching no work handler.May 21 17:49:48 <device-name> anax[4143]: I0521 17:49:48.675137 4143 governance.go:405] GovernanceWorker: governing agreementsMay 21 17:49:48 <device-name> anax[4143]: I0521 17:49:48.690373 4143 worker.go:363] CommandDispatcher: Governance command processor non-blocking for commandsMay 21 17:49:51 <device-name> anax[4143]: I0521 17:49:51.987405 4143 worker.go:363] CommandDispatcher: ExchangeMessages command processor non-blocking for commandsMay 21 17:49:53 <device-name> anax[4143]: I0521 17:49:53.581031 4143 worker.go:480] CommandDispatcher: Running subworker SurfaceExchErrorsMay 21 17:49:53 <device-name> anax[4143]: I0521 17:49:53.585453 4143 worker.go:484] CommandDispatcher: Finished run of subworker SurfaceExchErrorsMay 21 17:49:58 <device-name> anax[4143]: I0521 17:49:58.690459 4143 governance.go:1478] GovernanceWorker: GovernanceWorker dispatching no work handler.May 21 17:49:58 <device-name> anax[4143]: I0521 17:49:58.690478 4143 governance.go:405] GovernanceWorker: governing agreementsMay 21 17:49:58 <device-name> anax[4143]: I0521 17:49:58.701384 4143 worker.go:363] CommandDispatcher: Governance command processor non-blocking for commandsWhile working on your Edge device node, there may be a time when you need to check the status of the running Edge Agent. These commands may come in handy.
Summary
Section titled “Summary”In this chapter, we covered some of the not-so-obvious questions that you may have, as well as the answers to them. We also discussed how to tear down the AIO Open Horizon Managment Hub and perform cleanup, if needed.
In the next chapter, we will talk about some of the follow-on topics that are relevant to Edge computing.