I’ve just refreshed the version of Pelican used to generate this blog, along with the associated themes and plugins. It all seems to be working, but if you spot a problem feel free to drop me a line.
Posts for: #Tech
Fun with devicemapper snapshots
I find myself working with Raspbian disk images fairly often. A typical workflow is:
- Download the disk image.
- Mount the filesystem somewhere to check something.
- Make some changes or install packages just to check something else.
- Crap I’ve made changes.
…at which point I need to fetch a new copy of the image next time I want to start fresh.
Sure, I could just make a copy of the image and work from there, but what fun is that? This seemed like a perfect opportunity to learn more about the device mapper and in particular how the snapshot target works.
Safely restarting an OpenStack server with Ansible
The other day on #ansible, someone was looking for a way to safely
shut down a Nova server, wait for it to stop, and then start it up
again using the openstack
cli. The first part seemed easy:
- hosts: myserver
tasks:
- name: shut down the server
command: poweroff
become: true
…but that will actually fail with the following result:
TASK [shut down server] *************************************
fatal: [myserver]: UNREACHABLE! => {"changed": false, "msg":
"Failed to connect to the host via ssh: Shared connection to
10.0.0.103 closed.\r\n", "unreachable": true}
This happens because running poweroff
immediately closes Ansible’s
ssh connection. The workaround here is to use a “fire-and-forget”
asynchronous task:
Some notes on PWM on the Raspberry Pi
I was recently working on a project in which I wanted to drive a simple piezo buzzer attached to a GPIO pin on a Raspberry Pi. I was already using the RPi.GPIO module in my project so that seemed like a logical place to start, but I ran into a few issues.
You drive a piezo buzzer by generating a PWM signal with the
appropriate frequency. The RPi.GPIO
module implements PWM via
software, which is tricky on a non-realtime system. It’s difficult to
get the timing completely accurate, which results in sounds that are a
little wobbly at best. Since I’m simply generating tones with a
buzzer (rather than, say, controlling a servo) this is mostly just an
annoyance.
Ansible for Infrastructure Testing
At $JOB
we often find ourselves at customer sites where we see the
same set of basic problems that we have previously encountered
elsewhere (“your clocks aren’t in sync” or “your filesystem is full”
or “you haven’t installed a critical update”, etc). We would like a
simple tool that could be run either by the customer or by our own
engineers to test for and report on these common issues.
Fundamentally, we want something that acts like a typical code test
suite, but for infrastructure.
Better bulk filtering for Gmail
I use Gmail extensively for my personal email, and recently my workplace has been migrated over to Gmail as well. I find that for my work email I rely much more extensively on filters and labels to organize things (like zillions of internal and upstream mailing lists), and that has posed some challenges. While Gmail is in general fairly snappy, attempting to apply an action to thousands of messages (for example, trying to mark 16000 messages as “read”, or applying a new filter to all your existing messages) results in a very poor experience: it is not possible to interact with Gmail (in the same tab) while the action is running, and frequently actions will timeout.
OpenStack, Containers, and Logging
I’ve been thinking about logging in the context of OpenStack and containerized service deployments. I’d like to lay out some of my thoughts on this topic and see if people think I am talking crazy or not.
There are effectively three different mechanisms that an application can use to emit log messages:
- Via some logging-specific API, such as the legacy syslog API
- By writing a byte stream to stdout/stderr
- By writing a byte stream to a file
A substantial advantage to the first mechanism (using a logging API) is that the application is logging messages rather than bytes. This means that if you log a message containing embedded newlines (e.g., python or java tracebacks), you can collect that as a single message rather than having to impose some sort of structure on the byte stream after the fact in order to reconstruct those message.
FAA Cannot Require Drone Registration
This is now old news if you’re already following the drone industry, but if you’re not, I’d like to highlight a recent decision made by the US Court of Appeals regarding the FAA’s drone registration requirements.
To place this in context, back in 2015 the FAA established a new set of regulations (the “Registration Rule”) requiring anyone with a UAV (“unmanned aerial vehicle”, or “drone”) weighing between 0.5 and 55 lbs to register with the FAA. Unfortunately, the 2012 FAA Modernization and Reform Act says says (in section 336(a)):
Making sure your Gerrit changes aren’t broken
It’s a bit of an embarrassment when you submit a review to Gerrit only to have it fail CI checks immediately because of something as simple as a syntax error or pep8 failure that you should have caught yourself before submitting…but you forgot to run your validations before submitting the change.
In many cases you can alleviate this through the use of the git
pre-commit
hook, which will run every time you commit changes
locally. You can have the hook run tox
or whatever tool your
project uses for validation on every commit. This works okay for
simple cases, but if the validation takes more than a couple of
seconds the delay can be disruptive to the flow of your work.
Exploring YAQL Expressions
The Newton release of Heat adds support for a yaql intrinsic function, which allows you to evaluate yaql expressions in your Heat templates. Unfortunately, the existing yaql documentation is somewhat limited, and does not offer examples of many of yaql’s more advanced features.
I am working on a Fluentd composable service for TripleO. I want to allow each service to specify a logging source configuration fragment, for example:
parameters:
NovaAPILoggingSource:
type: json
description: Fluentd logging configuration for nova-api.
default:
tag: openstack.nova.api
type: tail
format: |
/(?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d+) (?<pid>\d+) (?<priority>\S+) (?<message>.*)/
path: /var/log/nova/nova-api.log
pos_file: /var/run/fluentd/openstack.nova.api.pos
This generally works, but several parts of this fragment are going to be the same across all OpenStack services. I wanted to reduce the above to just the unique attributes, which would look something like: