Support gzip compression for EtcdSnapshot

Offen
#374 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
aws, go, kubernetes

Rechercherichtung

Start from the agent's snapshot path, where cli.Snapshot() streams to the file or S3 uploader, and from the objectKey/localPath naming, then trace how the Job receives its settings. The restore path needs ensureRestoreSpace to account for uncompressed size and a .gz check before calling etcdutl. Done means a gzip-enabled snapshot round-trips through restore, and status.artifact reports the compressed size and SHA-256. Settle the --skip-hash-check question with maintainers before changing it.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Our etcd database size is already several GB, so it would be nice if EtcdSnapshot can support gzip compression. Every snapshot is uploaded to S3 (and downloaded again when restore), which costs a lot of traffic, and with frequent snapshots and some retention, the .db files also take a lot of space in the bucket.

etcd snapshots compress well. In my test, gzip saves about 85% space, both before and after defrag.

spec:
  compression: gzip  # default: none

I took a quick look at the code. For snapshot, the agent already streams cli.Snapshot() to the file/S3 uploader, so I think we only need to wrap it with a gzip.Writer, change the file name to <name>.db.gz (objectKey / localPath), and pass the setting to the Job.

For restore, the source is already an exact key/path, so no new field is needed. The agent can decompress it when the name ends with .gz, then call etcdutl. ensureRestoreSpace also needs to consider the uncompressed size.

I think status.artifact size/SHA-256 should be for the compressed file, since that is what is actually stored. gzip also has a CRC, so a broken file will fail when decompressing.

by the way,
restore uses --skip-hash-check because the snapshot stream "carries no hash", but actually the server appends a SHA-256 at the end and clientv3 keeps it, so this flag can be removed.
(or do I need to open a new issue for that?)

I'm happy to send a PR if this looks OK.

Vorherrschende Sprache
Go
Sterne
154
Forks
31
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

  • Enthält ein Dockerfile oder eine Docker-Compose-Datei
  • Keine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus cozystack/etcd-operator

Alle Issues in cozystack/etcd-operator

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.