bzp2010 commented on code in PR #12214: URL: https://github.com/apache/apisix/pull/12214#discussion_r2095447439
########## t/admin/standalone.spec.ts: ########## @@ -210,6 +245,38 @@ describe("Admin - Standalone", () => { }); }); + it("only set routes_conf_version", async () => { + const resp = await clientException.put( + ENDPOINT, + YAML.stringify({ routes_conf_version: 15 }), + {headers: {"Content-Type": "application/yaml"}, + }); + expect(resp.status).toEqual(202); + + const resp_1 = await client.get(ENDPOINT); + expect(resp_1.status).toEqual(200); + expect(resp_1.data.routes_conf_version).toEqual(15); + expect(resp_1.data.ssls_conf_version).toEqual(4); + expect(resp_1.data.services_conf_version).toEqual(4); + expect(resp_1.data.upstreams_conf_version).toEqual(4); + expect(resp_1.data.consumers_conf_version).toEqual(4); + + const resp2 = await clientException.put( + ENDPOINT, + YAML.stringify({ routes_conf_version: 17 }), + {headers: {"Content-Type": "application/yaml"}, + }); + expect(resp2.status).toEqual(202); + + const resp2_1 = await client.get(ENDPOINT); + expect(resp2_1.status).toEqual(200); + expect(resp2_1.data.routes_conf_version).toEqual(17); + expect(resp2_1.data.ssls_conf_version).toEqual(5); + expect(resp2_1.data.services_conf_version).toEqual(5); + expect(resp2_1.data.upstreams_conf_version).toEqual(5); + expect(resp2_1.data.consumers_conf_version).toEqual(5); + }); Review Comment: This is not an exception test, please move to the previous describe block. ########## t/admin/standalone.spec.ts: ########## @@ -228,5 +295,48 @@ describe("Admin - Standalone", () => { error_msg: "invalid request body: empty request body", }); }); + + it("control resource changes using modifiedIndex", async () => { + const c1 = structuredClone(routeWithModifiedIndex); + c1.routes[0].modifiedIndex = 1; + + const c2 = structuredClone(c1); + c2.routes[0].uri = "/r2"; + + const c3 = structuredClone(c2); + c3.routes[0].modifiedIndex = 2; + + // Update with c1 + const resp = await clientException.put(ENDPOINT, c1); + expect(resp.status).toEqual(202); + + // Check route /r1 exists + const resp_1 = await client.get("/r1"); + expect(resp_1.status).toEqual(200); + + // Update with c2 + const resp2 = await clientException.put(ENDPOINT, c2); + expect(resp2.status).toEqual(202); + + // Check route /r1 exists + const resp2_2 = await client.get("/r1"); + expect(resp2_2.status).toEqual(200); + + // Check route /r2 not exists + const resp2_1 = await client.get("/r2").catch((err) => err.response); + expect(resp2_1.status).toEqual(404); + + // Update with c3 + const resp3 = await clientException.put(ENDPOINT, c3); + expect(resp3.status).toEqual(202); + + // Check route /r1 not exists + const resp3_1 = await client.get("/r1").catch((err) => err.response); + expect(resp3_1.status).toEqual(404); + + // Check route /r2 exists + const resp3_2 = await client.get("/r2"); + expect(resp3_2.status).toEqual(200); + }); Review Comment: ditto ########## docs/en/latest/deployment-modes.md: ########## @@ -115,73 +115,162 @@ This method is more suitable for two types of users: Now, we have two standalone running modes, file-driven and API-driven. -1. The file-driven mode is the kind APISIX has always supported. +#### File-driven - The routing rules in the `conf/apisix.yaml` file are loaded into memory immediately after the APISIX node service starts. At each interval (default: 1 second), APISIX checks for updates to the file. If changes are detected, it reloads the rules. +The file-driven mode is the kind APISIX has always supported. - *Note*: Reloading and updating routing rules are all hot memory updates. There is no replacement of working processes, since it's a hot update. +The routing rules in the `conf/apisix.yaml` file are loaded into memory immediately after the APISIX node service starts. At each interval (default: 1 second), APISIX checks for updates to the file. If changes are detected, it reloads the rules. - This requires us to set the APISIX role to data plane. That is, set `deployment.role` to `data_plane` and `deployment.role_data_plane.config_provider` to `yaml`. +*Note*: Reloading and updating routing rules are all hot memory updates. There is no replacement of working processes, since it's a hot update. - Refer to the example below: +This requires us to set the APISIX role to data plane. That is, set `deployment.role` to `data_plane` and `deployment.role_data_plane.config_provider` to `yaml`. - ```yaml - deployment: - role: data_plane - role_data_plane: - config_provider: yaml - #END - ``` +Refer to the example below: - This makes it possible to disable the Admin API and discover configuration changes and reloads based on the local file system. +```yaml +deployment: + role: data_plane + role_data_plane: + config_provider: yaml +``` -2. The API-driven is an emerging paradigm for standalone. +This makes it possible to disable the Admin API and discover configuration changes and reloads based on the local file system. - The routing rules will be entirely in memory and not in a file, and it will need to be updated using the dedicated Standalone Admin API. +#### API-driven (Experimental) Review Comment: ```suggestion #### API-driven (Experimental) > This mode is experimental, please do not rely on it in your production environment. > We use it to validate certain specific workloads and if it is appropriate we will turn it into an officially supported feature, otherwise it will be removed. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org