Author Archives: qsf

Strength Gel

Samson had his long hair, Asterix and Obelix their magic potion, but for today’s man-about-town wishing to increase his muscular prowess, I discover that this small and convenient tube of ‘Strength Gel’ is readily available from most pharmacies!

It’s surprising, because Anbesol is a name I knew from my youth. A treatment for mouth ulcers and similar dental complaints, it was packaged as a very small vial of liquid. Well, the strength gel, it turns out, can also be used for this antiseptic and anaesthetic purpose, and, indeed, has such a powerful calming and numbing effect that I’m surprised Simon and Garfunkel didn’t write a song about it.

As to why it might be Adult strength gel, though, I can only leave to your imagination. The packaging is very uninformative about any use in more intimate situations, but I would suggest any experimental applications be done very, very cautiously.

Healthchecks in a Docker Swarm

This is a very geeky post for those who might be Googling for particular details of Linux containerisation technologies. Others please feel free ignore! We were searching for this information online today and couldn’t find it, so I thought I’d post it myself for the benefit of future travellers…

How happy are your containers?

In your Dockerfile, you can specify a HEALTHCHECK: a command that will be run periodically within the container to ascertain whether it seems to be basically happy.

A typical example for a container running a web server might try and retrieve the front page with curl, and exit with an error code if that fails. Something like this, perhaps:

HEALTHCHECK CMD /usr/bin/curl --fail http://localhost/ || exit 1

This will be called periodically by the Docker engine — every 30 seconds, by default — and if you look at your running containers, you can see whether the healthcheck is passing in the ‘STATUS’ field:

$ docker ps
CONTAINER ID   IMAGE           CREATED          STATUS                     NAMES
c9098f4d1933   website:latest  34 minutes ago   Up 33 minutes (healthy)    website_1

Now, you can configure this healthcheck in various ways and examine its state through the command line and other Docker utilities and APIs, but I had always thought that it wasn’t actually used for anything by Docker. But I was wrong.

If you are using Docker Swarm (which, in my opinion, not enough people do), then the swarm ensures that an instance of your container keeps running in order to provide your ‘service’. Or it may run several instances, if you’ve told the swarm to create more than one replica. If a container dies, it will be restarted, to ensure that the required number of replicas exist.

But a container doesn’t have to die in order to undergo this reincarnation. If it has a healthcheck and the healthcheck fails repeatedly, a container will be killed off and restarted by the swarm. This is a good thing, and just how it ought to work. But it’s remarkably hard to find any documentation which specifies this, and you can find disagreement on the web as to whether this actually happens, partly, I expect, because it doesn’t happen if you’re just running docker-compose.

But my colleague Nicholas and I saw some of our containers dying unexpectedly, wondered if this might be the issue, and decided to test it, as follows…

First, we needed a minimal container where we could easily change the healthcheck status. Here’s our Dockerfile:

FROM bash
RUN echo hi > /tmp/t
HEALTHCHECK CMD test -f /tmp/t
CMD bash -c "sleep 5h"

and we built our container with

docker build -t swarmtest .

When you start up this exciting container, it just goes to sleep for five hours. But it contains a little file called /tmp/t, and as long as that file exists, the healthcheck will be happy. If you then use docker exec to go into the running container and delete that file, its state will eventually change to unhealthy.

If you’re trying this, you need to be a little bit patient. By default, the check runs every 30 seconds, starting 30s after the container is launched. Then you go in and delete the file, and after the healthcheck has failed three times, it will be marked as unhealthy. If you don’t want to wait that long, there are some extra options you can add to the HEALTHCHECK line to speed things up.

OK, so let’s create a docker-compose.yml file to make use of this. It’s about as small as you can get:

version: '3.8'

services:
  swarmtest:
    image: swarmtest

You can run this using docker-compose (or, now, without the hyphen):

docker compose up

or as a swarm stack using:

docker stack deploy -c docker-compose.yml swarmtest

(You don’t need some big infrastructure to use Docker Swarm; that’s one of its joys. It can manage large numbers of machines, but if you’re using Docker Desktop, for example, you can just run docker swarm init to enable Swarm on your local laptop.)

In either case, you can then use docker ps to find the container’s ID and start the healthcheck failing with

docker exec CONTAINER_ID rm /tmp/t

And so here’s a key difference between running something under docker compose and running it with docker stack deploy. With the former, after a couple of minutes, you’ll see the container change to ‘(unhealthy)’, but it will continue to run. The healthcheck is mostly just an extra bit of decoration; possibly useful, but it can be ignored.

With Docker Swarm, however, you’ll see the container marked as unhealthy, and shortly afterwards it will be killed off and restarted. So, yes, healthchecks are important if you’re running Docker Swarm, and if your container has been built to include one and, for some reason you don’t want to use it, you need to disable it explicitly in the YAML file if you don’t want your containers to be restarted every couple of minutes.

Finally, if you have a service that takes a long time to start up (perhaps because it’s doing a data migration), you may want to configure the ‘start period’ of the healthcheck, so that it stays in ‘starting’ mode for longer and doesn’t drop into ‘unhealthy’, where it might be killed off before finishing.

Watt’s the cost?

A few years ago, I came across a really useful rule-of-thumb for calculating electricity cost:

A 1-watt device costs £1/year, if it’s running 24×7.

At the time, this was almost exactly right for most people in the UK, and it made it very easy to estimate the impact of, say, using that old 200W PC as a server for the next three years rather than getting a more modern low-power one.

Sadly, for most of us, energy costs are going up a lot at the moment, and the above is probably rather optimistic now, so you might want to do the calculation for yourself. For example, I currently have a big Synology NAS server here at home storing lots of my data and backups. Once you’ve bought such a device, how do the running costs compare with storing your data in the cloud?

So here’s my exciting new highly-sophisticated web application, which is designed to answer this simple question:

Watt’s The Cost?

AirTags and Airplanes

I’m a big fan of my Apple AirTags. I have a few of them now, and they’ve been jolly useful on several occasions, enabling me to find things quickly that would otherwise have involved more time and stress, or to notice that something has been left behind and so recover it far sooner than would otherwise have been possible.

They’re very cunning devices. Tilly even has one on her collar now!

For those not familiar with the underlying technology, the general challenge with locating devices in the past has been that it typically involves two components: a GPS receiver (to find out where the item is), and a connection to the mobile phone network (to report that location to whomever may be looking for it). Both of these need significant battery power, so trackers have been bulky, required frequent recharging, and the phone connection generally implied a subscription. In the past, therefore, tracking has generally been reserved for valuable things which can carry big batteries, like cars, or like smartphones which happen already to have the necessary functions built-in and get recharged every night.

Since I have been known, just occasionally, to be a little absent-minded, I have made extensive use of Apple’s ‘Find my…’ system over the years to locate iPhones, iPads, even spouses. And before you scoff, I should mention that my knowledge of how to use it also once won me an enthusiastic embrace in the middle of a field from a rather beautiful young woman who was a complete stranger to me. So there! But that’s a story for another day…

Anyway, the AirTags have neither a GPS nor a big battery, and yet still manage to transmit their location back to you remarkably effectively in most circumstances. How do they do it? Well, they can be detected by any passing iPhone, and there are a billion of those moving around the world, so there’s a surprisingly good chance that if a human passes close to your lost bunch of keys, you’ll get to know about its location fairly soon.

The AirTags are also, I believe, the first large-scale deployment of UWB location technology, the details of which are beyond the scope of this post, but it basically means that if you have a recent iPhone, when you get really close to the Tag, you can be guided to it using a compass-needle-type display, in a way that would not be possible with something like Bluetooth alone. You can find out not just that your wallet is in this room, but that it’s behind this sofa cushion.

Still, my use of AirTags has been very practical and prosaic. Others have had more fun, and a YouTuber calling himself AirtagAlex has done some wonderful experiments over the last few months of mailing AirTags to different parts of the world and seeing the routes they took to reach their destination.

I rather liked his latest video, though, which explores one of those questions you might never have thought of asking in the past: what actually happens if you get on a plane and leave something in the pocket of the seat in front of you?

Happy MMXXII

Today, I.I.MMXXII, we visited Mevagissey, never having been there before, and found it a really delightful spot to start the New Year (though many of its normal attractions were, of course, closed today).

Here’s a quick view of what we saw.

(Also available here, and there’s a 360 panorama here.)

A Traditional Tesla Blessing

My friend Gareth, hearing that I was about set off for a long journey across the country in my electric car, wished me well. “Bon Voyage”, he said, “and may all your supercharges be 100kW+”.

This kind thought prompted me to do some serious research into other traditional travellers’ blessings. After weeks of diligent studies in the library of Trinity College Dublin, I came across a previously-unknown fragment, hidden between the pages of an old vellum manuscript. On being translated from the Gaelic and converted into unicode, it reads roughly as follows, and I’d like to offer it to all my readers as my best wishes for you all in 2022:

“May the road rise up to meet you
And may you regenerate efficiently on the way back down.
May the sun not blind your autopilot cameras,
And the rain fall soft on your wiper sensors.
Until we meet again…
Wherever this sat-nav chooses to take us.”

Collecting The Milk

For as long as I can remember, since my earliest childhood, we’ve had milk delivered to the front door. Many visitors seem surprised that we can still do this (and that it still comes in nice recycled glass bottles), so perhaps we’re just lucky — but everywhere we’ve ever lived has had a convenient milkman doing regular deliveries at sensible prices.

Actually buying milk in a shop is an activity I therefore associate with going on holiday or having unexpected quantities of guests! For the rest of the time, we’re just occasionally aware of a quiet clinking on the doorstep in the middle of the night, and getting the milk just involves pottering to the front door in my dressing gown. But it’s often the first real chance I get to view the day, breathe the air, feel the temperature.

And sometimes, like this morning, that’s a wonderful thing.

Happy Winter Solstice, everybody!

The Wet Wood

On a misty walk in one of our favourite local woods this morning, we spotted an unusual white tree stump. On closer inspection, it appeared to have been partly sawn through, and so was covered in its own sawdust.

These were pretty quick snaps with my Fuji, but were also a reminder that, impressive as my iPhone 12 Pro is these days, there are times when it pays to take a proper camera with you.

You can click the images for larger versions.

A Decisive Moment?

I generally try to avoid anything too political here, but I loved this photo of Helen Morgan, the new Liberal Democrat MP who won the North Shropshire by-election a couple of days ago, and so took a seat that has been Conservative for 200 years.

Regardless of your political opinions, as well as the pleasing facial expressions, I think the suspense encapsulated in this is just brilliant. Many photos make you laugh because you can see the inevitable, but often you’re glimpsing just a split second into the future. Here, you feel they could hold this pose for quite some time yet, but with all the certainty of Greek tragedy, you know what’s eventually coming!

Photo credit: PA, originally spotted in this FT article.

Down Denver Way

One of the most important bits of civil engineering in our part of the world is less than an hour’s drive away, but it was only last month that I actually got around to visiting it.

What is this thing and why is it so important? Here’s my little explanation:

And if you want to take a look around from on high yourself…

You can drag the image around to look in different directions, and you can zoom in and out by scrolling, or using Shift & Ctrl keys.

Well, that’s reassuring!

I discover that what has been happening to my waistline recently is perfectly normal and natural, and lots of other people are being tested for it too.

It’s called ‘lateral flow’.

Non-instant Messaging

I sent a colleague a question by email, and yesterday, he replied. The fact that there was an intervening period of three and a half years doesn’t seem to have phased him at all; it was not, in fact, worthy of mention in his response.

It reminded me of a Physics teacher I had at school. An excellent teacher, but known for being very slow in returning marked homework assignments — if, indeed, they came back at all.

One day, as he was handing out some marked scripts, he said, “Ah, this one’s for Cardozo”, and handed it to my classmate, who was about to protest that the script wasn’t, in fact, his… when he recognised it as his father’s handwriting.

© Copyright Quentin Stafford-Fraser