Skip to content

use slimmer image for init container#247

Open
sklarsa wants to merge 2 commits intomasterfrom
swap-init-container
Open

use slimmer image for init container#247
sklarsa wants to merge 2 commits intomasterfrom
swap-init-container

Conversation

@sklarsa
Copy link
Contributor

@sklarsa sklarsa commented Feb 18, 2026

This PR swaps the data migration init container to a much smaller alpine distro to reduce the potential attack surface.

Since bash is not installed, we needed to update the migration script to make it POSIX-compliant.

@sklarsa
Copy link
Contributor Author

sklarsa commented Feb 18, 2026

I had claude run 3 tests locally using kind, and here are the results:

  Test 1: Fresh Install (test-fresh)                                                                               
                                                                                                                   
  Init container logs:                                                                                             
  File 'tables.d.*' not found. Nothing to move.                                                                    

  Pod status:
  NAME        READY   STATUS    RESTARTS   AGE   IP           NODE                       NOMINATED NODE   READINESS
   GATES
  questdb-0   1/1     Running   0          44s   10.244.0.6   test-fresh-control-plane   <none>           <none>

  ---
  Test 2: Old-to-New Migration (test-migrate)

  Seeded old data layout (PV root before migration):
  total 4
  drwxrwxrwx    1 root     root           142 Feb 18 16:20 .
  drwxr-xr-x    1 root     root            68 Feb 18 16:20 ..
  -rw-r--r--    1 root     root             0 Feb 18 16:20 .hidden_file
  -rw-r--r--    1 root     root             0 Feb 18 16:20 _tab_index.d
  -rw-r--r--    1 root     root             0 Feb 18 16:20 _txn
  drwxr-xr-x    1 root     root             0 Feb 18 16:20 conf
  -rw-r--r--    1 root     root             0 Feb 18 16:20 db.lock
  -rw-r--r--    1 root     root             9 Feb 18 16:20 somefile.txt
  -rw-r--r--    1 root     root             0 Feb 18 16:20 tables.d.0
  -rw-r--r--    1 root     root             0 Feb 18 16:20 tables.d.1
  SETUP-DONE

  Init container logs:
  Migration complete!

  /var/lib/questdb/ after migration (PV root — clean, only QuestDB-created dirs):
  drwxrwxrwx 1 questdb questdb  54 Feb 18 16:20 .
  drwxr-xr-x 1 root    root     48 Jan 28 15:24 ..
  drwxr-xr-x 1 questdb questdb  58 Feb 18 16:20 conf
  drwxr-xr-x 1 questdb questdb 770 Feb 18 16:20 db
  -rw-rw-r-- 1 questdb questdb 503 Feb 18 16:20 hello.txt
  drwxr-xr-x 1 questdb questdb  48 Feb 18 16:20 import
  drwxr-xr-x 1 questdb questdb  64 Feb 18 16:20 public

  /var/lib/questdb/db/ contents (all old files successfully moved in):
  -rw-r--r-- 1 questdb questdb    0 Feb 18 16:20 .hidden_file
  -rw-r--r-- 1 questdb questdb   16 Feb 18 16:20 .data_id
  drwxrwxr-x 1 questdb questdb   46 Feb 18 16:20 _query_trace
  -rw-r--r-- 1 questdb questdb 4096 Feb 18 16:20 _tab_index.d
  -rw-r--r-- 1 questdb questdb    0 Feb 18 16:20 _txn
  drwxr-xr-x 1 questdb questdb    0 Feb 18 16:20 conf
  -rw-r--r-- 1 questdb questdb    0 Feb 18 16:20 db.lock
  -rw-r--r-- 1 questdb questdb    9 Feb 18 16:20 somefile.txt
  -rw-r--r-- 1 questdb questdb    0 Feb 18 16:20 tables.d.0
  -rw-r--r-- 1 questdb questdb 4096 Feb 18 16:20 tables.d.1
  -rw-r--r-- 1 questdb questdb    0 Feb 18 16:20 tables.d.lock
  drwxrwxr-x 1 questdb questdb   66 Feb 18 16:20 telemetry
  ...

  ---
  Test 3: New-to-New Upgrade (test-upgrade)

  Old chart (debian+bash) installed, table created:
  {"ddl":"OK"}

  Upgraded to new chart (alpine+sh), init container logs:
  File 'tables.d.*' not found. Nothing to move.

  Table survived the upgrade:
  {"query":"SELECT * FROM test_table","columns":[{"name":"ts","type":"TIMESTAMP"},{"name":"val","type":"INT"}],"tim
  estamp":0,"dataset":[],"count":0}

@sklarsa
Copy link
Contributor Author

sklarsa commented Feb 18, 2026

Ran a few more tests...

  Test 4: Existing db/ directory — PASS                                                                            
                                                                                                                   
  - Seeded PV with tables.d.0, tables.d.1, AND an existing db/ dir containing existing_file.txt and                
  some_table/col.d                                                                                                 
  - Init log: "Migration complete!"                                                                                
  - Old db/ was moved to db/db/ (preserving existing_file.txt and some_table/ inside it)                           
  - All root files (rootfile.txt, _txn, .hidden, etc.) moved into db/                                              
  - QuestDB Running

  Test 5: Completely empty volume — PASS

  - PVC with zero files
  - Init log: "Nothing to move."
  - QuestDB started fine, created its own db/ directory
  - Pod 1/1 Running

  Test 6: Files with spaces and special characters — PASS

  - Seeded: file with spaces.txt, dir with spaces/inner.txt, quotefile.txt, .hidden_special
  - Init log: "Migration complete!"
  - All files moved into db/ with names intact: dir with spaces, file with spaces.txt, .hidden_special all present
  - QuestDB Running

@sklarsa sklarsa marked this pull request as ready for review February 18, 2026 16:55
@sklarsa
Copy link
Contributor Author

sklarsa commented Feb 18, 2026

More test results after code changes

  #: 1
  Scenario: Fresh install — empty PVC, no prior data
  Result: PASS
  Init Container Output: "Nothing to move."
  ────────────────────────────────────────
  #: 2
  Scenario: Old-to-new migration — seeded old layout with tables.d.*, hidden files
  Result: PASS
  Init Container Output: "Migration complete!" — all files including .hidden_file moved to db/
  ────────────────────────────────────────
  #: 3
  Scenario: New-to-new upgrade — install old chart (debian+bash), create table, upgrade to alpine+sh
  Result: PASS
  Init Container Output: "Nothing to move." — table survived upgrade
  ────────────────────────────────────────
  #: 4
  Scenario: Existing db/ directory — old layout + pre-existing db/ with files
  Result: PASS
  Init Container Output: "Migration complete!" — old db/ preserved at db/db/ with contents intact
  ────────────────────────────────────────
  #: 5
  Scenario: Empty volume — PVC with zero files
  Result: PASS
  Init Container Output: "Nothing to move." — QuestDB created its own db/
  ────────────────────────────────────────
  #: 6
  Scenario: Special characters — files with spaces, quotes, hidden dotfiles
  Result: PASS
  Init Container Output: "Migration complete!" — file with spaces.txt, dir with spaces, quote'file.txt, .hidden_special

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments