Pidoku

Archive

This learning material is in the archive. It is not currently maintained and has not been updated with the latest information, so tool versions, prices and dates may be out of date.

The Hidden Dependencies

Module 9 Lesson 9.d 40 min Difficulty 2/5

Prerequisites 3.b

The idea in one minute#

Some of the most common outages have nothing to do with code or load. A TLS certificate expires. A domain is not renewed. A DNS change propagates wrongly, or the DNS provider is down. A clock drifts and tokens are rejected. A quota or rate limit at a provider is hit. A secret is rotated and one service still uses the old one. A licence expires. A third-party API changes or disappears.

These dependencies are invisible on architecture diagrams, fail on a date rather than under load, and are often owned by nobody. The fix is an inventory with owners and expiry dates, automation (auto-renewal, auto-rotation), and alerts weeks before anything expires.

An analogy#

A house where the burglar alarm, the boiler and the car insurance all work perfectly — until the electricity is cut off because a direct debit expired. Nothing was broken; something was forgotten.

A picture#

flowchart TB
  SVC[":go: <b>Your service</b>"]
  SVC --- CERT[":i-lock: TLS certificates<br/><small>public, internal, mTLS, signing</small>"]
  SVC --- DNS[":i-globe: DNS and domains<br/><small>registrar, provider, TTLs</small>"]
  SVC --- TIME[":i-clock: Time<br/><small>NTP, leap seconds, time zones</small>"]
  SVC --- QUOTA[":i-gauge: Quotas and limits<br/><small>cloud, API, file descriptors</small>"]
  SVC --- SEC[":vault: Secrets<br/><small>keys, tokens, passwords</small>"]
  SVC --- EXT[":i-network: Third parties<br/><small>APIs, SaaS, CDNs, identity</small>"]
  SVC --- LIC[":i-file-text: Licences and contracts"]
  class SVC compute
  class CERT,DNS,TIME,QUOTA,SEC,EXT,LIC warn

How it really works#

Certificates#

  • Inventory every certificate: public endpoints, internal services, mTLS client certs, code-signing, SAML/OIDC signing keys, CA certificates (including intermediate and root expiries).
  • Automate issuance and renewal: ACME (Let’s Encrypt, other ACME CAs) with cert-manager on Kubernetes, cloud certificate managers, a service mesh issuing short-lived workload certificates (SPIFFE/SPIRE, Istio). Public TLS certificate lifetimes are shrinking: under the CA/Browser Forum’s 2025 ballot, the maximum falls from 398 days to 200 days from March 2026, 100 days from March 2027, and 47 days by March 2029 — manual renewal stops being viable.
  • Alert on expiry from the outside (black-box, 3.b) at 30, 14 and 3 days — and on the renewal failing, not just on expiry approaching.
  • Remember clients that pin or bundle certificates (mobile apps, IoT devices, old Java trust stores): a CA change can break them even when your certificate is valid.

DNS and domains#

  • Domains: auto-renew, registrar lock, renewal notices to a team address (not one person’s email), and an inventory of every domain the business uses.
  • DNS changes are risky changes: review them, lower TTLs before a planned change, raise them after.
  • The DNS provider is a hard dependency of everything; consider a secondary provider for the most critical zones, and do not run the only DNS for your own recovery tooling inside the system it is meant to recover.
  • Internal DNS (CoreDNS, resolvers) can be overloaded; cache with care and monitor resolution latency and errors.

Time#

  • Run NTP/chrony on every host; alert on clock offset above ~100 ms. Many protocols (TLS, JWT exp/nbf, Kerberos, distributed databases) fail when clocks disagree.
  • Leap seconds caused famous outages (2012: Linux kernel livelocks; 2016–2017: Cloudflare DNS, due to time going backwards). Large providers now smear leap seconds. The CGPM decided in 2022 to stop adding leap seconds by 2035.
  • In code, use a monotonic clock for durations (Go’s time.Since does), never wall-clock differences.
  • Time zones and DST: cron jobs at 02:30 run twice or never on DST transition days; schedule in UTC.
  • Date bugs: year boundaries, leap years (29 February), 32-bit time (2038), week-numbering.

Quotas and limits#

  • Cloud quotas (instances per region, IPs, load balancers, API request rates), managed-service limits, SaaS API rate limits, OS limits (ulimit -n file descriptors, ephemeral ports, conntrack table size).
  • Inventory them with current usage; alert at 70–80%; request increases well ahead (7.d).
  • Know your provider’s API rate limits: a deploy tool or autoscaler that calls the cloud API too fast can be throttled at the worst moment.

Secrets#

  • Store in a secrets manager (Vault, cloud secret managers), rotate automatically, and support two valid secrets at once during rotation so that services pick up the new one before the old one is revoked.
  • Alert on secret and API-key expiry the same way as certificates.

Third parties#

  • List every external dependency, its SLA, its status page, its support contact, and what your service does when it is down (degraded mode, 6.f).
  • Subscribe to their status pages and change notices (API deprecations).
  • For the critical ones: a second provider, or a manual fallback.

A worked example#

A company’s inventory exercise, one afternoon, finds:

ItemExpires / limitOwnerAutomated?
api.example.com TLS41 daysplatformYes (cert-manager)
Internal mTLS CA19 daysnobodyNo
SAML signing cert for SSO7 monthsITNo
example-shop.de domain12 daysmarketing (left the company)No
Elastic IPs in eu-west-148 of 50 usedplatform—
Payment provider API keyNo expiry, created 2019paymentsNo rotation

Two of these would have been outages within three weeks: the internal CA (every service-to- service call would have failed) and the domain. The program below is the core of the automated check that replaced the spreadsheet: it inspects certificates and reports days to expiry. To run offline, it generates its own test certificates; in production you would load them from the endpoints (as probe.go in 3.b does) or from the certificate store.

Code#

Go
// expiry.go — inventory check: days until certificates and other dated dependencies expire.
package main

import (
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"crypto/x509"
	"crypto/x509/pkix"
	"fmt"
	"math/big"
	"sort"
	"time"
)

// makeCert creates a self-signed certificate valid until notAfter (stands in for a real one).
func makeCert(cn string, notAfter time.Time) *x509.Certificate {
	key, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
	tmpl := &x509.Certificate{
		SerialNumber: big.NewInt(time.Now().UnixNano()),
		Subject:      pkix.Name{CommonName: cn},
		NotBefore:    notAfter.AddDate(-1, 0, 0),
		NotAfter:     notAfter,
	}
	der, _ := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &key.PublicKey, key)
	cert, _ := x509.ParseCertificate(der)
	return cert
}

type item struct {
	kind, name, owner string
	expires           time.Time
	automated         bool
}

func main() {
	now := time.Date(2026, 10, 24, 0, 0, 0, 0, time.UTC)
	certs := []*x509.Certificate{
		makeCert("api.example.com", now.AddDate(0, 0, 41)),
		makeCert("internal-mtls-ca", now.AddDate(0, 0, 19)),
		makeCert("sso-saml-signing", now.AddDate(0, 7, 0)),
	}
	owners := map[string]string{"api.example.com": "platform", "internal-mtls-ca": "", "sso-saml-signing": "it"}
	auto := map[string]bool{"api.example.com": true}

	var inv []item
	for _, c := range certs {
		inv = append(inv, item{"tls cert", c.Subject.CommonName, owners[c.Subject.CommonName], c.NotAfter, auto[c.Subject.CommonName]})
	}
	inv = append(inv,
		item{"domain", "example-shop.de", "", now.AddDate(0, 0, 12), false},
		item{"api key", "payments-provider", "payments", now.AddDate(0, 0, 400), false},
	)
	sort.Slice(inv, func(i, j int) bool { return inv[i].expires.Before(inv[j].expires) })

	fmt.Printf("%-9s %-20s %6s  %-9s %-5s %s\n", "kind", "name", "days", "owner", "auto", "action")
	for _, it := range inv {
		days := int(it.expires.Sub(now).Hours() / 24)
		owner := it.owner
		if owner == "" {
			owner = "NOBODY"
		}
		action := "ok"
		switch {
		case days <= 3:
			action = "PAGE"
		case days <= 14:
			action = "ticket, urgent"
		case days <= 30 && !it.automated:
			action = "ticket"
		}
		if it.owner == "" {
			action += "; assign an owner"
		}
		if !it.automated && days < 120 {
			action += "; automate renewal"
		}
		fmt.Printf("%-9s %-20s %6d  %-9s %-5v %s\n", it.kind, it.name, days, owner, it.automated, action)
	}
}

Remember this#

  • Certificates, domains, DNS, time, quotas, secrets, licences and third parties fail on dates and limits, not under load — and are often unowned.
  • Keep an inventory with owners and expiry; automate renewal and rotation; alert weeks ahead and on renewal failure.
  • Public certificate lifetimes are shrinking towards 47 days by 2029: automate now.
  • Use monotonic clocks for durations, UTC for schedules, NTP everywhere.
  • Treat DNS changes as risky changes; know every quota and how close you are.

Try it#

  1. Run expiry.go. Add a quota row (48 of 50 Elastic IPs). How would you represent it?
  2. List every certificate in your system, including internal CAs and signing keys. Which have no owner?
  3. Find every cron job scheduled in local time.

Check yourself#

  1. Why should certificate monitoring alert on renewal failure, not only on expiry?
  2. Why does a lowered DNS TTL need to be set before a planned change?
  3. Why measure durations with a monotonic clock?
  4. How should secret rotation avoid an outage?

Sources#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in