Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -euo pipefail
#
# Capture the pre-push context.
#
# From githooks(5):
#
# Information about what is to be pushed is provided on the hook's standard
#!/usr/bin/env python3
#
# To produce a report, run like so:
#
# $ ./this-script.py ui/src ui/tests | \
# > cut -f 1 | sort | uniq -c | sort -k 2
#
from pathlib import Path
import re
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
Sending build context to Docker daemon 19MB
Step 1/8 : FROM postgres:10.1
---> 599272bf538f
Step 2/8 : ENV CARGO_HOME /cargo
---> Running in 1c642d69d946
---> 36f826858a27
Removing intermediate container 1c642d69d946
Step 3/8 : ENV PATH $CARGO_HOME/bin:$PATH
---> Running in e7186288251c
@allenap
allenap / wip.md
Last active April 5, 2017 15:07
Notes on WIP bugs.

Notes on bugs.

AttributeError: 'Port' object has no attribute 'socket'

$ twistd3 --nodaemon --pidfile= tftp --enable-reading --root-directory=$PWD
...
2017-04-05T14:08:49+0200 [-] RemoteOriginReadSession starting on 55337
2017-04-05T14:08:49+0200 [-] Starting protocol <tftp.bootstrap.RemoteOriginReadSession object at 0x7f0c16d9f2b0>
@allenap
allenap / bzr-repos-for-fun.md
Last active December 7, 2016 16:03
Bazaar repositories for fun/profit/shenanigans

Bazaar repositories for fun/profit/shenanigans

Starting from scratch

Create a new repository and create a branch within it:

$ bzr init-repo maas
Shared repository with trees (format: 2a)
Location:
import string
import requests
maas_url = "http://maas.server:5240/MAAS/"
api_desc = requests.get(maas_url + "api/2.0/describe/").json()
uri_templates = {h["uri"] for h in api_desc["handlers"]}
@allenap
allenap / maas-backup-and-restore.md
Last active December 31, 2021 13:20
MAAS: Backup & Restore

Dumping

Use the directory output format because it works better with incremental backups and is most flexible when restoring.

Do not compress because the overwhelming majority of the contents of the MAAS database is already compressed images. For a MAAS installation with one image the saving due to compression was only 1.7% but the dump took noticeably longer. With more images the ratio of already-compressed to not-compressed data goes up, and the savings will likely drop.

from contextlib import contextmanager
import time
import dns.resolver
from provisioningserver.utils.twisted import retries
def query_soa(zone):
for rdata in dns.resolver.query(zone, "SOA"):
return rdata # Return the first SOA found.

How MAAS describes swap to curtin

Swap is a bit special, and must be special-cased in both MAAS and curtin:

  1. Swap can exist:

    • on a whole disk,
    • on a partition with the type 0x82 ("Linux swap / Solaris"),
  • in a file without holes (created with fallocate or dd for example).