[Bug]: Updating a REST API on the gateway doesn't resolve its vhosts, so _gateway_default_ is stored as a hostname

オープン 初心者向け
#4,167 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
api, backend

調査の方向性

gateway/gateway-controller/pkg/service/restapi/service.goを読み、特にRestAPIService.UpdateとDeployAPIConfigurationを通る作成経路を確認し、それぞれがvhostをどのように扱うか比較してください。次に、gateway/gateway-controller/pkg/utils/api_deployment.goと、その中のresolveVhostSentinels関数を調べてください。更新時に_gateway_default_と未指定のvhostが現在のgatewayのデフォルト値に解決され、GETが解決後の値を返すことが完了条件です。この動作を確認するため、既存のREST API更新テストがあるか確認してください。

索引モデルが issue の本文から書いたものです。

説明

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

Gateway

Please select the aspect the issue is related to

Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)

Description

When a REST API is created on the gateway, its vhosts are resolved at deploy time: _gateway_default_, or a missing vhosts block, becomes the gateway's current default hosts. The resolved values are stored, so a later change to the gateway defaults doesn't move the API (discussion #369).

Updating the API through the gateway's REST API (PUT /rest-apis/{id}) skips that step:

  • With vhosts.main: _gateway_default_: the placeholder is stored literally, as a hostname. The API stops answering on the default hosts.
  • With no vhosts block: nothing is stored. The API keeps answering on the defaults only because the router falls back to the live default. So it follows the next config change, which is what deploy-time resolution is meant to prevent, and GET shows no vhosts.

Observed (gateway with router.vhosts.main.default = "*.wso2.com" and router.vhosts.sandbox.default = "*-sandbox.wso2.com")

  1. POST /rest-apis with no vhosts: GET /rest-apis/{id} shows spec.vhosts.main *.wso2.com and spec.vhosts.sandbox *-sandbox.wso2.com, and a request with Host: api.wso2.com answers 200.
  2. PUT /rest-apis/{id} with vhosts: {"main": "_gateway_default_"}: GET shows spec.vhosts.main _gateway_default_, and the same request now answers 404.
  3. PUT /rest-apis/{id} with no vhosts: GET shows no spec.vhosts at all.

Expected
An update resolves vhosts the same way a create does. _gateway_default_ and a missing vhosts block become the current gateway defaults, which are stored and shown by GET.

Cause
Create goes through DeployAPIConfiguration (gateway/gateway-controller/pkg/service/restapi/service.go:174), which calls resolveVhostSentinels (gateway/gateway-controller/pkg/utils/api_deployment.go:312). RestAPIService.Update (pkg/service/restapi/service.go:320) parses the body and saves it without that call. The event gateway's WebSub update does resolve vhosts, because it goes through DeployAPIConfiguration.

Steps to Reproduce
  1. Start a gateway with [router.vhosts.main] default = "*.wso2.com".
  2. Create a REST API with no vhosts through POST /rest-apis. A request with Host: api.wso2.com answers 200.
  3. Update it through PUT /rest-apis/{id} with "vhosts": {"main": "_gateway_default_"}.
  4. GET /rest-apis/{id} shows _gateway_default_, and the request with Host: api.wso2.com answers 404.
  5. Update it again with no vhosts: GET shows no vhosts.
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 (e90cde473). Platform-api and gateway built from source and run by the IT suite (tests/framework), on macOS with Rancher Desktop.

主要言語
Go
スター
85
フォーク
137
平均マージ
1日 12時間
マージ済み PR(30日)
247

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wso2/api-platform のほかの issue

wso2/api-platform の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。