image test: Zugangsdaten pruefen, ohne etwas herunterzuladen

Neues Unterkommando "image test" und ein Menuepunkt im Image-Menue.
Geprueft wird in Sekunden, statt erst beim mehrere Gigabyte grossen
Download zu scheitern:

  Registry  - Erreichbarkeit, Anmeldung und ob das Konto ueberhaupt
              Zugriff auf das Repository hat. Umgesetzt ueber den
              Docker-Registry-v2-Ablauf: WWW-Authenticate auswerten,
              Token beim genannten realm holen, damit /tags/list
              abfragen. Dadurch wird "Anmeldung stimmt, aber keine
              Berechtigung" von "Anmeldung falsch" unterschieden.
  Downloads - HTTP-Basic gegen die Tarball-URLs. HTTP 404 ohne 401
              bedeutet: Zugangsdaten sind richtig, nur Version oder
              Dateiname passen nicht - das wird auch so gemeldet.

Es wird nichts gespeichert: die Zugangsdaten gehen per temporaerer
.netrc an curl und stehen damit nicht in der Prozessliste (geprueft).
Fehlt curl, weicht die Registry-Pruefung auf podman/docker login in
eine Wegwerfdatei aus (--authfile bzw. DOCKER_CONFIG), die gespeicherte
Anmeldung des Systems bleibt unberuehrt.

Beim Testen gegen die echten Dienste gefunden und behoben:
  - "docker.io" ist nicht der API-Host der Registry; angesprochen wird
    registry-1.docker.io. Vorher lieferte /v2/ nur eine 302.
  - Die Schlussauswertung zaehlte auch Pruefungen als bestanden, die
    wegen --only gar nicht gelaufen waren.

Verifiziert gegen die echten Endpunkte: Docker Hub anonym inkl.
Tag-Liste von checkmk/check-mk-raw (HTTP 200), registry.checkmk.com
und download.checkmk.com jeweils mit falschen Zugangsdaten (HTTP 401,
korrekt als abgelehnt gemeldet).

Dokumentiert als Abschnitt 8.4 in beiden Sprachfassungen.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-20 15:06:59 +02:00
co-authored by Claude Opus 5
parent 8ad4a5cbd9
commit 3dd59fb973
3 changed files with 475 additions and 5 deletions
+78 -2
View File
@@ -673,7 +673,83 @@ CMK_DOWNLOAD_PASSWORD=<password>
The credentials come from the Checkmk customer portal (portal.checkmk.com).
`.env` should therefore be `chmod 600` – `install.sh` takes care of that.
### 8.4 Fetching the image – three ways
### 8.4 Testing the credentials first
Rather than having a multi-gigabyte download fail on a wrong login, both can be
checked in seconds:
```bash
./scripts/cmk-manage.sh image test --edition enterprise --version 2.3.0p23
```
Nothing is downloaded and no login is stored. What gets checked:
| Check | What it answers |
|---|---|
| registry reachable | network, proxy, DNS |
| login accepted | are the username and password correct? |
| access to the repository | does the account have the required entitlement (subscription)? |
| download portal | is the image tarball there and is the login accepted? |
Example with correct credentials from `.env`:
```
Registry registry.checkmk.com
[ OK ] erreichbar (HTTP 401)
[ OK ] Anmeldung akzeptiert
[ OK ] Zugriff auf 'enterprise/check-mk-enterprise' vorhanden
Downloadportal download.checkmk.com
[ OK ] Datei erreichbar (HTTP 200)
https://download.checkmk.com/checkmk/2.3.0p23/check-mk-enterprise-2.3.0p23.docker.tar.gz
[ OK ] Zugangsweg nutzbar.
```
With a wrong password:
```
Registry registry.checkmk.com
[ OK ] erreichbar (HTTP 401)
[FEHLER] Anmeldung abgelehnt (HTTP 401)
Benutzername/Kennwort des Checkmk-Kundenportals pruefen
```
(`erreichbar` = reachable, `Anmeldung akzeptiert` = login accepted,
`Anmeldung abgelehnt` = login rejected, `Zugangsweg nutzbar` = a route works.)
Useful distinctions the test makes:
* **Login accepted, but no access to the repository** – the credentials are
correct, but the subscription lacks the entitlement for this edition.
* **Login accepted, but HTTP 404 on the download portal** – username and
password are right, only the version or file name does not match. Give the
exact version (no `-latest`) or set `CMK_DOWNLOAD_URL`.
* For the freely available editions (`raw`, `pro`, `cloud`, …) the test reports
"public repository – no login required" and still verifies that the
repository can actually be reached.
Options:
```bash
# supply credentials once without writing them to .env
./scripts/cmk-manage.sh image test --edition enterprise --version 2.3.0p23 \
--user <user> --password <password>
# check only one route
./scripts/cmk-manage.sh image test --only registry
./scripts/cmk-manage.sh image test --only download
```
The credentials are passed to `curl` through a temporary `.netrc` and therefore
do **not** appear in the process list. If `curl` is missing, the registry check
falls back to `podman login` / `docker login` – into a throwaway file as well,
so the system's stored login is left untouched.
In the ncurses interface the test lives under
**Checkmk-Image beschaffen/auswählen → "Zugangsdaten prüfen"**.
### 8.5 Fetching the image – three ways
**a) From a registry (recommended)**
@@ -724,7 +800,7 @@ typically `localhost/checkmk/check-mk-enterprise:2.3.0p23`) and writes it to
sudo ./scripts/cmk-manage.sh up
```
### 8.5 Checking what is in effect
### 8.6 Checking what is in effect
```bash
./scripts/cmk-manage.sh image status # configured image + local images