Antenna configuration

Introduction

Antenna uses environment configuration to define its behavior.

The local development environment is configured in the my.env and docker/config/local_dev.env env files and that configuration is pulled in when you run Antenna using docker-compose.

In a server environment, configuration is pulled in from the process environment.

Here’s an example. This uses Datadog installed on the EC2 node for metrics and also IAM bound to the EC2 node that Antenna is running on so it doesn’t need S3 credentials for crashstorage.

# Metrics things
STATSD_NAMESPACE=mcboatface

# BreakdpadSubmitterResource settings
CRASHMOVER_CRASHSTORAGE_CLASS=antenna.ext.s3.crashstorage.S3CrashStorage

# S3CrashStorage and S3Connection settings
CRASHMOVER_CRASHSTORAGE_BUCKET_NAME=org-myorg-mybucket

Application

First, you need to configure the application-scoped variables.

Configuration

These all have sane defaults, so you don’t have to configure any of this.

Options
  • BASEDIR (str) –

    The root directory for this application to find and store things.

    Defaults to '/home/docs/checkouts/readthedocs.org/user_builds/antenna/checkouts/latest'.

  • LOGGING_LEVEL (str) –

    The logging level to use. DEBUG, INFO, WARNING, ERROR or CRITICAL

    Defaults to 'INFO'.

  • LOCAL_DEV_ENV (bool) –

    Whether or not this is a local development environment.

    Defaults to 'False'.

  • STATSD_HOST (str) –

    Hostname for statsd server.

    Defaults to 'localhost'.

  • STATSD_PORT (int) –

    Port for statsd server.

    Defaults to '8125'.

  • STATSD_NAMESPACE (str) –

    Namespace for statsd metrics.

    Defaults to ''.

  • SECRET_SENTRY_DSN (str) –

    Sentry DSN to use. See https://docs.sentry.io/quickstart/#configure-the-dsn for details. If this is not set an unhandled exception logging middleware will be used instead.

    Defaults to ''.

  • HOST_ID (str) –

    Identifier for the host that is running Antenna. This identifies this Antenna instance in the logs and makes it easier to correlate Antenna logs with other data. For example, the value could be a public hostname, an instance id, or something like that. If you do not set this, then socket.gethostname() is used instead.

    Defaults to ''.

Breakpad crash resource

component antenna.breakpad_resource.BreakpadSubmitterResource

Handles incoming breakpad-style crash reports.

This handles incoming HTTP POST requests containing breakpad-style crash reports in multipart/form-data format.

It can handle compressed or uncompressed POST payloads.

It parses the payload from the HTTP POST request, runs it through the throttler with the specified rules, generates a crash_id, returns the crash_id to the HTTP client, and passes the crash report data to the crashmover.

Options

BREAKPAD_DUMP_FIELD (str) –

The name of the field in the POST data for dumps.

Defaults to 'upload_file_minidump'.

Throttler

component antenna.throttler.Throttler

Accept or reject incoming crashes based on specified rule set.

The throttler can throttle incoming crashes using the content of the crash. To throttle, you set up a rule set which is a list of Rule instances. That goes in a Python module which is loaded at run time.

If you don’t want to throttle anything, use this:

BREAKPAD_THROTTLER_RULES=antenna.throttler.ACCEPT_ALL

If you want to support all products, use this:

BREAKPAD_THROTTLER_PRODUCTS=antenna.throttler.ALL_PRODUCTS

To set up a rule set, put it in a Python file and define the rule set there. For example, you could have file myruleset.py with this in it:

from antenna.throttler import Rule

rules = [
    Rule('ProductName', 'Firefox', 100),
    # ...
]

then set BREAKPAD_THROTTLER_RULES to the path for that. For example, depending on the current working directory and PYTHONPATH, the above could be:

BREAKPAD_THROTTLER_RULES=myruleset.rules
Options
  • BREAKPAD_THROTTLER_RULES (antenna.throttler.parse_attribute) –

    Python dotted path to ruleset

    Defaults to 'antenna.throttler.MOZILLA_RULES'.

  • BREAKPAD_THROTTLER_PRODUCTS (antenna.throttler.parse_attribute) –

    Python dotted path to list of supported products

    Defaults to 'antenna.throttler.MOZILLA_PRODUCTS'.

Crash mover

component antenna.crashmover.CrashMover

Handles saving and publishing crash reports.

The crashmover saves the crash using the configured crashstorage class and publishes it using the configured crashpublish class.

Note

From when a crash comes in to when it’s saved by the crashstorage class, the crash is entirely in memory. Keep that in mind when figuring out how to scale your Antenna nodes.

The most important configuration bit here is choosing the crashstorage class.

For example:

CRASHMOVER_CRASHSTORAGE_CLASS=antenna.ext.s3.crashstorage.S3CrashStorage
Options
  • CRASHMOVER_CONCURRENT_CRASHMOVERS (antenna.crashmover.positive_int) –

    The number of crashes concurrently being saved and published. Each process gets this many concurrent crashmovers, so if you’re running 5 processes on the node, then it’s (5 * concurrent_crashmovers) sharing upload bandwidth.

    Defaults to '2'.

  • CRASHMOVER_CRASHSTORAGE_CLASS (everett.manager.parse_class) –

    The class in charge of storing crashes.

    Defaults to 'antenna.ext.crashstorage_base.NoOpCrashStorage'.

  • CRASHMOVER_CRASHPUBLISH_CLASS (everett.manager.parse_class) –

    The class in charge of publishing crashes.

    Defaults to 'antenna.ext.crashpublish_base.NoOpCrashPublish'.

Crash storage

For crash storage, you have three options one of which is a no-op for debugging.

NoOpCrashStorage

The NoOpCrashStorage class is helpful for debugging, but otherwise shouldn’t be used.

component antenna.ext.crashstorage_base.NoOpCrashStorage

This is a no-op crash storage that logs crashes it would have stored.

It keeps track of the last 10 crashes in .saved_things instance attribute with the most recently stored crash at the end of the list. This helps when writing unit tests for Antenna.

Filesystem

The FSCrashStorage class will save crash data to disk. If you choose this, you’ll want to think about what happens to the crash after Antenna has saved it and implement that.

component antenna.ext.fs.crashstorage.FSCrashStorage

Save raw crash files to the file system.

This generates a tree something like this which mirrors what we do on S3:

<FS_ROOT>/
    <YYYYMMDD>/
        raw_crash/
            <CRASHID>.json
        dump_names/
            <CRASHID>.json
        <DUMP_NAME>/
            <CRASHID>

Couple of things to note:

  1. This doesn’t ever delete anything from the tree. You should run another process to clean things up.

  2. If you run out of disk space, this component will fail miserably. There’s no way to recover from a full disk–you will lose crashes.

FIXME(willkg): Can we alleviate or reduce the likelihood of the above?

When set as the CrashMover crashstorage class, configuration for this class is in the CRASHMOVER_CRASHSTORAGE namespace.

Example:

CRASHMOVER_CRASHSTORAGE_FS_ROOT=/tmp/whatever
Options

CRASHMOVER_CRASHSTORAGE_FS_ROOT (str) –

path to where files should be stored

Defaults to '/tmp/antenna_crashes'.

AWS S3

The S3CrashStorage class will save crash data to AWS S3. You might be able to use this to save to other S3-like systems, but that’s not tested or supported.

component antenna.ext.s3.connection.S3Connection

Connection object for S3.

Credentials and permissions

When configuring credentials for this connection object, you can do one of two things:

  1. provide ACCESS_KEY and SECRET_ACCESS_KEY in the configuration, OR

  2. use one of the other methods described in the boto3 docs https://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials

The AWS credentials that Antenna is configured with must have the following Amazon S3 permissions:

  • s3:ListBucket

    Antenna periodically checks its health and during that health check, it will HEAD the S3 Bucket. This requires s3:ListBucket permissions.

  • s3:PutObject

    This permission is used to save items to the bucket.

    Additionally, at startup, Antenna will attempt to save a test file to the bucket. If that fails, then this will raise an error and will halt startup.

Retrying saves

When saving crashes, this connection will retry saving several times. Then give up. The crashmover coroutine will put the crash back in the queue to retry later. Crashes are never thrown out.

When set as the CrashMover crashstorage class, configuration for this class is in the CRASHMOVER_CRASHSTORAGE namespace.

Example:

CRASHMOVER_CRASHSTORAGE_BUCKET_NAME=mybucket
CRASHMOVER_CRASHSTORAGE_REGION=us-west-2
CRASHMOVER_CRASHSTORAGE_ACCESS_KEY=somethingsomething
CRASHMOVER_CRASHSTORAGE_SECRET_ACCESS_KEY=somethingsomething
Options
  • CRASHMOVER_CRASHSTORAGE_ACCESS_KEY (str) –

    AWS access key. You can also specify AWS_ACCESS_KEY_ID which is the env var used by boto3.

    Defaults to ''.

  • CRASHMOVER_CRASHSTORAGE_SECRET_ACCESS_KEY (str) –

    AWS secret access key. You can also specify AWS_SECRET_ACCESS_KEY which is the env var used by boto3.

    Defaults to ''.

  • CRASHMOVER_CRASHSTORAGE_REGION (str) –

    AWS region to connect to. For example, us-west-2

    Defaults to 'us-west-2'.

  • CRASHMOVER_CRASHSTORAGE_ENDPOINT_URL (str) –

    endpoint_url to connect to; None if you are connecting to AWS. For example, http://localhost:4569/.

    Defaults to ''.

  • CRASHMOVER_CRASHSTORAGE_BUCKET_NAME (str) – AWS S3 bucket to save to. Note that the bucket must already have been created and must be in the region specified by region.

component antenna.ext.s3.crashstorage.S3CrashStorage

Save raw crash files to S3.

This will save raw crash files to S3 in a pseudo-tree something like this:

<BUCKET>
   v1/
       dump_names/
           <CRASHID>
       <DUMPNAME>/
           <CRASHID>
   v2/
       raw_crash/
           <ENTROPY>/
               <YYYYMMDD>/
                   <CRASHID>

When set as the CrashMover crashstorage class, configuration for this class is in the CRASHMOVER_CRASHSTORAGE namespace.

Generally, if the default connection class is fine, you don’t need to do any configuration here.

Options

CRASHMOVER_CRASHSTORAGE_CONNECTION_CLASS (everett.manager.parse_class) –

S3 connection class to use

Defaults to 'antenna.ext.s3.connection.S3Connection'.

Crash publish

For crash publishing, you have two options one of which is a no-op.

NoOpCrashPublish

The NoOpCrashPublish class is helpful for debugging and also if you don’t want Antenna to be publishing crash ids somewhere.

component antenna.ext.crashpublish_base.NoOpCrashPublish

No-op crash publish class that logs crashes it would have published.

It keeps track of the last 10 crash ids in .published_things instance attribute with the most recently published crash id at the end of the list. This helps when writing unit tests for Antenna.

AWS SQS

The SQSCrashPublish class will publish crash ids to an AWS SQS queue.

component antenna.ext.sqs.crashpublish.SQSCrashPublish

Publisher to AWS SQS.

Required AWS SQS things

When configuring credentials for this crashpublish object, you can do one of two things:

  1. provide ACCESS_KEY and SECRET_ACCESS_KEY in the configuration, OR

  2. use one of the other methods described in the boto3 docs https://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials

You also need to create an AWS SQS standard queue with the following settings:

Setting

Value

Default Visibility Timeout

5 minutes

Message Retention Period

default

Maximum Message Size

default

Delivery Delay

default

Receive Message Wait Time

default

The AWS credentials that Antenna is configured with must have the following Amazon SQS permissions on the SQS queue you created:

  • sqs:GetQueueUrl

    Antenna needs to convert a queue name to a queue url. This requires the sqs:GetQueueUrl

  • sqs:SendMessage

    Antenna sends messages to a queue–this is how it publishes crash ids. This requires the sqs:SendMessage permission.

If something isn’t configured correctly, then Antenna may not start.

Verification

This component verifies that it can publish to the queue by publishing a fake crash id of test. Downstream consumers should ignore these.

When set as the CrashMover crashpublish class, configuration for this class is in the CRASHMOVER_CRASHPUBLISH namespace.

Options
  • CRASHMOVER_CRASHPUBLISH_ACCESS_KEY (str) –

    AWS SQS access key. You can also specify AWS_ACCESS_KEY_ID which is the env var used by boto3.

    Defaults to ''.

  • CRASHMOVER_CRASHPUBLISH_SECRET_ACCESS_KEY (str) –

    AWS SQS secret access key. You can also specify AWS_SECRET_ACCESS_KEY which is the env var used by boto3.

    Defaults to ''.

  • CRASHMOVER_CRASHPUBLISH_REGION (str) –

    AWS region to connect to. For example, us-west-2

    Defaults to 'us-west-2'.

  • CRASHMOVER_CRASHPUBLISH_ENDPOINT_URL (str) –

    endpoint_url to connect to; None if you are connecting to AWS. For example, http://localhost:4569/.

    Defaults to ''.

  • CRASHMOVER_CRASHPUBLISH_QUEUE_NAME (str) – The AWS SQS queue name.