Todd's Odds & Ends: Troubleshooting asset downloads

What’s the first rule of troubleshooting asset download issues? Check the filters.

One of the most common issues we see when dealing with the failure to download and run new assets is the misconfiguration of the asset’s filter settings. Asset filters allow you to have multiple build versions available for a single asset definition.

For example, let’s look at the asset definition for the Bonsai asset sensu-plugins/sensu-plugins-cpu-checks.

---
type: Asset
api_version: core/v2
metadata:
  name: sensu-plugins-cpu-checks
  labels: 
  annotations:
    io.sensu.bonsai.url: https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-cpu-checks
    io.sensu.bonsai.api_url: https://bonsai.sensu.io/api/v1/assets/sensu-plugins/sensu-plugins-cpu-checks
    io.sensu.bonsai.tier: Community
    io.sensu.bonsai.version: 4.1.0
    io.sensu.bonsai.namespace: sensu-plugins
    io.sensu.bonsai.name: sensu-plugins-cpu-checks
    io.sensu.bonsai.tags: ruby-runtime-2.4.4
spec:
  builds:
  - url: https://assets.bonsai.sensu.io/24e5a5d7ff0a5e63b0a6902f1224b7d4592cbdc9/sensu-plugins-cpu-checks_4.1.0_debian9_linux_amd64.tar.gz
    sha512: 9dd717a7a71fa78b7647b27e9bde303ebf5b14dbf6a9aef6050d30cb6e255058b1c82d1bb9e5dfdcc2ce5ae8a0804964c807500142d09beb2cffb735d93c9797
    filters:
    - entity.system.os == 'linux'
    - entity.system.arch == 'amd64'
  - url: https://assets.bonsai.sensu.io/24e5a5d7ff0a5e63b0a6902f1224b7d4592cbdc9/sensu-plugins-cpu-checks_4.1.0_debian_linux_amd64.tar.gz
    sha512: f0435fd0f138fc1483aa7ca1c5262f336c3d758b862a2b646928f32dd4ee4785847c63d66886127819da036a7a85c4bc22f316dbdc61fc6641db90eb45559baa
    filters:
    - entity.system.os == 'linux'
    - entity.system.arch == 'amd64'
    - entity.system.platform_family == 'debian'
  - url: https://assets.bonsai.sensu.io/24e5a5d7ff0a5e63b0a6902f1224b7d4592cbdc9/sensu-plugins-cpu-checks_4.1.0_centos7_linux_amd64.tar.gz
    sha512: 8a018622018220323588a0d69ce0ee1e8c3ae72ad708108eb105006e1453a507289445eefb222da838b132106abf86910e2226d2148cc90ae64def9e7d887584
    filters:
    - entity.system.os == 'linux'
    - entity.system.arch == 'amd64'
    - entity.system.platform_family == 'rhel'
    - entity.system.platform_version.split('.')[0] == '7'
  - url: https://assets.bonsai.sensu.io/24e5a5d7ff0a5e63b0a6902f1224b7d4592cbdc9/sensu-plugins-cpu-checks_4.1.0_centos6_linux_amd64.tar.gz
    sha512: f42be798f276d29c6076b33199f99da300f9d83d23556eba409a468d45169d2c4b58b397885ce17d78ce5a55bb867d466f3ba995b739584bd5f4957faff3c98b
    filters:
    - entity.system.os == 'linux'
    - entity.system.arch == 'amd64'
    - entity.system.platform_family == 'rhel'
    - entity.system.platform_version.split('.')[0] == '6'
  - url: https://assets.bonsai.sensu.io/24e5a5d7ff0a5e63b0a6902f1224b7d4592cbdc9/sensu-plugins-cpu-checks_4.1.0_alpine3.8_linux_amd64.tar.gz
    sha512: 7a5ad2d967d2880076f11dc0ab4abec75dc5f19542a5713cb7694db8f06b186b3834a22dda897797a3dad95ca7e1a8e95cb6b0bc074e416ed6238d861f158071
    filters:
    - entity.system.os == 'linux'
    - entity.system.arch == 'amd64'
    - entity.system.platform == 'alpine'
  - url: https://assets.bonsai.sensu.io/24e5a5d7ff0a5e63b0a6902f1224b7d4592cbdc9/sensu-plugins-cpu-checks_4.1.0_alpine_linux_amd64.tar.gz
    sha512: a67676f88d88ff2a9a5e08deab462035c0d129ba37ccac5b4bddafce3d61122e8395adc04036546038c7c76a217376f9600804d531e6139cec69460c746f11f9
    filters:
    - entity.system.os == 'linux'
    - entity.system.arch == 'amd64'
    - entity.system.platform == 'alpine'
    - entity.system.platform_version.split('.')[0] == '3'

Notice the use of the platform_family attribute? That allows us to match a single definition to multiple platforms (e.g. rhel for RHEL, CentOS, and other derivatives or Debian for Debian and Ubuntu).

One common misconfiguration is to set a match on the platform attribute instead of platform_family. This means that an asset defined with entity.system.platform == 'debian' would not match an Ubuntu based system and therefore would not download and run.

Another pattern you’ll see is the use of Javascript based expressions for filtering based on platform_version.

When troubleshooting asset downloads make sure to compare the entity specifications from the asset with those of the actual entity you are trying to match (using sensuctl entity info <entity_name> --format yaml).