[Bug]: An immutable gateway accepts and serves deployments from the control plane

Open
#4,160 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, sqlite
Domain
api, backend

Research direction

Read gateway/gateway-controller/pkg/immutable/loader.go and the control-plane handling around pkg/controlplane/client.go:532 and :1465. Trace how immutable mode affects deployment events and startup sync, then check the relevant deployment tests. Done means control-plane deployments are rejected with a clear failure reason and are not restored or served after a restart.

Written by the indexing model from the issue text.

Description

Area/Gateway Area/Platform-API Aspect/Configuration Severity/Major Type/Bug
Please select the area the issue is related to

Gateway, Platform API

Please select the aspect the issue is related to

Aspect/Configuration (Config files, settings, env vars, defaults)

Description

An immutable gateway ([immutable_gateway] enabled = true) is meant to serve only the artifacts in its files, and it refuses changes through its REST API with 405. But a deployment made from the control plane is applied, served and reported back as a success. It is also restored on every restart, because the startup sync re-applies the control plane's deployments after the artifacts are loaded from files.

Observed

  • POST /rest-apis on the gateway: 405 {"status":"error","message":"Gateway is in immutable mode. Mutating operations are not allowed."}
  • A REST API created in the control plane and deployed to this gateway (POST /api/v0.9/rest-apis/{id}/deployments): the deployment reaches DEPLOYED, and the gateway's GET /rest-apis/{id} answers 200.
  • After restarting gateway-controller (which wipes its SQLite database), GET /rest-apis/{id} answers 200 again.

Expected
The immutable gateway rejects a deployment from the control plane, and the control plane shows the deployment as failed with a clear reason. The gateway serves only what its artifact files define.

Cause

  • Immutable mode is enforced only by the REST middleware (gateway/gateway-controller/pkg/immutable/loader.go:256). The control-plane client handles api.deployed and the other deploy events (pkg/controlplane/client.go:1465 onwards) without checking immutable mode.
  • The startup sync (pkg/controlplane/client.go:532, syncDeployments) doesn't check it either, so the control plane's deployments come back after every restart.
  • Platform-api has no notion of an immutable gateway, so it can't refuse the deployment itself.
Steps to Reproduce
  1. Start a gateway with SQLite storage and [immutable_gateway] enabled = true, connected to platform-api.
  2. Create a REST API in the control plane and deploy it to that gateway.
  3. The deployment shows DEPLOYED, and the gateway serves the API.
  4. Restart gateway-controller: the API is served again.
Severity Level of the Issue

Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)

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.

Dominant language
Go
Stars
85
Forks
137
Avg merge
1d 12h
Merged PRs (30d)
247

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wso2/api-platform

All issues in wso2/api-platform

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.