You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/01/12 10:42:04 UTC
[GitHub] [apisix] suslovsergey opened a new issue #6085: request help: Update route with full filled object
suslovsergey opened a new issue #6085:
URL: https://github.com/apache/apisix/issues/6085
### Issue description
Hello, team!
At the moment I am developing a provider for terraform, and it confuses me that there is no method that would update the entire route object. IMHO it is very inconvenient to calculate changes on the provider side. And here's the question: if I will use the `PUT /apisix/admin/routes/{id}` method to update the route - what could be the side effect of this approach? is there a possibility that the route that I am updating will start giving 404 for a short time?
On dev VM i add some code for patch method in routes.lua:
``` lua
...
if sub_path and sub_path ~= "" then
if sub_path == "__full__" then
node_value = conf
else
local code, err, node_val = core.table.patch(node_value, sub_path, conf)
node_value = node_val
if code then
return code, err
end
end
...
```
### Environment
- apisix version (cmd: `apisix version`): 2.11.0
- OS (cmd: `uname -a`): centOS7
- OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): openresty/1.19.9.1
- etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
- apisix-dashboard version, if have:
- the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
- luarocks version, if the issue is about installation (cmd: `luarocks --version`):
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] suslovsergey commented on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
suslovsergey commented on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1011840012
@tokers exactly!
in my case terraform provider control data in resource. when i apply changes for terraform plan it's make next:
1. Build full object for resource from terraform plan state (with default values like in documentation)
2. Send object (json) to api
3. Read object from api and create new state for terraform resource
4. and finally compare plan and new state, if we have diff here - raise error
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1011044804
Are you saying that you need the data in the PUT to be exactly the same as the data in etcd? (no need to set default values)
I think it would be more user-friendly to use default values for some of the configurations.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] suslovsergey closed issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
suslovsergey closed issue #6085:
URL: https://github.com/apache/apisix/issues/6085
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] suslovsergey commented on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
suslovsergey commented on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1011157420
Example
Before update i have next structure:
``` json
"plugins" : {
"a": { some options here }
"b": { some options here }
}
```
Now i want to drop plugin "b", so i will send next structure:
``` json
"plugins" : {
"a": { some options here }
}
```
Of course you i can compare the terraform states (current and plan) and make diff for PATCH method, but it's painful approach.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] suslovsergey commented on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
suslovsergey commented on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1027684633
@tokers
Ok, i just patch core.table.patch via hook -
```lua
local apisix = require("apisix")
local core = require("apisix.core")
local old_http_init = apisix.http_init
apisix.http_init = function(...)
local old_core_table_path = core.table.patch
core.table.patch = function(node_value, sub_path, conf)
if sub_path == "__patch_terraform_plugin_apisix__" then
return old_core_table_path(conf, "", conf)
else
return old_core_table_path(node_value, sub_path, conf)
end
end
old_http_init(...)
end
```
Please close issue.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] suslovsergey commented on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
suslovsergey commented on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1011151396
I using admin api to create/update/delete resources and in terraform provider i set default values (like in the documentation). And when i need ti update route for example or may be service, i send http request via PATCH method, but patch method currently ( in documentation says) - updates only part of data. In my case it's very uncomfortable to detect where i must send null or empty object. So main question: it's right way use PUT method (with ID of resource) to update resource? or i need to make hack like in code snippet?
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] suslovsergey edited a comment on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
suslovsergey edited a comment on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1011157420
Example
Before update i have next structure:
``` json
"plugins" : {
"a": { some options here }
"b": { some options here }
}
```
Now i want to drop plugin "b", so i will send next structure:
``` json
"plugins" : {
"a": { some options here }
}
```
Of course i can compare the terraform states (current and plan) and make diff for PATCH method, but it's painful approach.
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #6085: request help: Update route with full filled object
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #6085:
URL: https://github.com/apache/apisix/issues/6085#issuecomment-1011603610
@suslovsergey So the current situation is:
1. It's not easy to execute the "delete part of data" in the PATCH method;
2. We have to maintain (or fetch in advance) the object that we want to change, and apply the changes then sending to the Admin API.
Is my understanding exact?
--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org