[Bug]: A failed artifact push on reconnect clears the gateway's record of the control plane's artifact ID

Aperta Adatta ai principianti
#4,162 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
83/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, sqlite
Ambito
api, backend

Direzione di ricerca

Inizia da gateway/gateway-controller/pkg/controlplane/sync.go:741, dove i fallimenti di riconnessione chiamano UpdateCPSyncStatus, e confronta con la chiamata di push singolo in pkg/controlplane/client.go:4730. Controlla come viene aggiornato l’ID memorizzato in pkg/storage/sql_store.go:1336. Il lavoro è completo quando un push di riconnessione non riuscito conserva l’ID dell’artefatto esistente del piano di controllo; verificalo con un test di regressione per quel percorso di errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Area/Gateway Aspect/Other Severity/Minor Type/Bug
Please select the area the issue is related to

Gateway

Please select the aspect the issue is related to

Aspect/Other (Anything else which does not match above categories)

Description

When the gateway reconnects, it re-pushes every artifact it created. If the control plane rejects one of them, the gateway marks it failed and also deletes the control plane's artifact ID it had stored for it. A failed single push (on create or update) keeps the ID; only the reconnect push clears it.

Until a later push succeeds, the gateway can't match control-plane events that name the artifact by its control-plane ID. API keys are one example: getArtifactConfigByID falls back to the stored ID (pkg/utils/api_key.go:1930), and the API-key backfill on connect maps by it (pkg/controlplane/client.go:1126).

Observed

  1. I created a REST API on the gateway with the project-id annotation of an existing project. It was pushed, and the gateway recorded cp_artifact_id.
  2. I updated it on the gateway to the annotation of a project that doesn't exist, so the control plane rejects the push. cp_sync_status became failed, and cp_artifact_id was still set.
  3. I restarted gateway-controller. The reconnect push failed for the same reason, cp_sync_status is failed, and cp_artifact_id is now NULL.

Expected
A failed push leaves the stored control-plane artifact ID unchanged, as the single-push path already does.

Cause
The reconnect push records a failure with an empty ID (gateway/gateway-controller/pkg/controlplane/sync.go:741: UpdateCPSyncStatus(cfg.UUID, "", …)), and UpdateCPSyncStatus writes NULL for an empty ID (pkg/storage/sql_store.go:1336). The single-push path passes the existing ID (pkg/controlplane/client.go:4730: UpdateCPSyncStatus(cfg.UUID, cfg.CPArtifactID, …)). The fix is to pass cfg.CPArtifactID at sync.go:741.

Steps to Reproduce
  1. Create a REST API on a connected gateway with the project-id annotation of an existing project, and wait for it to be pushed.
  2. Update it on the gateway so the control plane rejects the push (for example, an annotation naming a project that doesn't exist).
  3. Restart gateway-controller.
  4. In the gateway's database, the artifact's cp_artifact_id is now NULL.
Severity Level of the Issue

Severity/Minor (Non-critical functionality. Can be fixed in future releases)

Environment Details (with versions)

Current main (0ee943ff4). Platform-api and gateway built from source and run by the IT suite (tests/framework), with the gateway on SQLite, on macOS with Rancher Desktop.

Lingua principale
Go
Stelle
85
Fork
137
Merge medio
1g 12h
PR unite (30g)
247

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wso2/api-platform

Tutte le issue di wso2/api-platform

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.