Bug 1039760 - Environment variables REST api: PATCH http method broken
Summary: Environment variables REST api: PATCH http method broken
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Pod
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Ravi Sankar
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-09 22:41 UTC by Ravi Sankar
Modified: 2015-05-15 00:23 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-01-30 00:52:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Ravi Sankar 2013-12-09 22:41:44 UTC
[root@ip-10-73-193-147 ~]# curl -k --user 'user:nopass' https://localhost/broker/rest/application/52a62d954950ead54b00004b/environment-variables -X PATCH -d environment_variables[][name]=FOO -d environment_variables[][name]=BAR -d environment_variables[][value]=updated -d environment_variables[][name]=NEW -d environment_variables[][value]='new var'
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Action Controller: Exception caught</title>
  <style>
    body { background-color: #fff; color: #333; }

    body, p, ol, ul, td {
      font-family: helvetica, verdana, arial, sans-serif;
      font-size:   13px;
      line-height: 18px;
    }

    pre {
      background-color: #eee;
      padding: 10px;
      font-size: 11px;
      white-space: pre-wrap;
    }

    a { color: #000; }
    a:visited { color: #666; }
    a:hover { color: #fff; background-color:#000; }
  </style>
</head>
<body>

<h1>Routing Error</h1>
<p><pre>No route matches [PATCH] &quot;/broker/rest/application/52a62d954950ead54b00004b/environment-variables&quot;</pre></p>
<p>
  Try running <code>rake routes</code> for more information on available routes.
</p>

</body>
</html>

Comment 1 Ravi Sankar 2013-12-09 22:50:55 UTC
Decide whether to support POST or PATCH for adding multiple env vars
(a) For PATCH
- Fix broker REST api (currently showing routing error)
- Fix CLI tools(rhc) to use PATCH method for adding multiple env vars.

(b) For POST
- Fix rest application link method, change from PATCH to POST.

Comment 2 Jordan Liggitt 2013-12-10 14:49:07 UTC
RHC isn't using PATCH because it's set to version 1.5. The 1.5 API returns POST for the env var methods. That's fine for now, we can bump the API version of RHC separately.

Created PR https://github.com/openshift/origin-server/pull/4311 which adds PATCH support, mapping it to #create (just like POST).

Comment 3 Jordan Liggitt 2013-12-10 16:49:50 UTC
STG pull of https://github.com/openshift/origin-server/pull/4314

Comment 4 Liang Xia 2013-12-11 07:50:27 UTC
Verified on devenv-stage_609 and STG(devenv-stage_609).

# curl -k --user lxia https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variables -X PATCH -d environment_variables[][name]=FOO -d environment_variables[][name]=BAR -d environment_variables[][value]=updated -d environment_variables[][name]=NEW -d environment_variables[][value]='new var'
{"api_version":1.6,"data":[{"links":{"GET":{"href":"https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variable/BAR","method":"GET","optional_params":[],"rel":"Get environment variable","required_params":[]},"UPDATE":{"href":"https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variable/BAR","method":"PUT","optional_params":[],"rel":"Update environment variable","required_params":[{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"DELETE":{"href":"https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variable/BAR","method":"DELETE","optional_params":[],"rel":"Delete environment variable","required_params":[]}},"name":"BAR","value":"updated"},{"links":{"GET":{"href":"https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variable/NEW","method":"GET","optional_params":[],"rel":"Get environment variable","required_params":[]},"UPDATE":{"href":"https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variable/NEW","method":"PUT","optional_params":[],"rel":"Update environment variable","required_params":[{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"DELETE":{"href":"https://localhost/broker/rest/application/52a816c830f2c8a076000007/environment-variable/NEW","method":"DELETE","optional_params":[],"rel":"Delete environment variable","required_params":[]}},"name":"NEW","value":"new var"}],"messages":[{"exit_code":0,"field":null,"index":null,"severity":"info","text":"Patched environment variables for application app"}],"status":"created","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6],"type":"environment-variables","version":"1.6"}


# curl -k --user 'lxia+migrate' https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variables -X PATCH -d environment_variables[][name]=FOO -d environment_variables[][name]=BAR -d environment_variables[][value]=updated -d environment_variables[][name]=NEW -d environment_variables[][value]='new var'
Enter host password for user 'lxia+migrate':
{"api_version":1.6,"data":[{"links":{"GET":{"href":"https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variable/BAR","method":"GET","optional_params":[],"rel":"Get environment variable","required_params":[]},"UPDATE":{"href":"https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variable/BAR","method":"PUT","optional_params":[],"rel":"Update environment variable","required_params":[{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"DELETE":{"href":"https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variable/BAR","method":"DELETE","optional_params":[],"rel":"Delete environment variable","required_params":[]}},"name":"BAR","value":"updated"},{"links":{"GET":{"href":"https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variable/NEW","method":"GET","optional_params":[],"rel":"Get environment variable","required_params":[]},"UPDATE":{"href":"https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variable/NEW","method":"PUT","optional_params":[],"rel":"Update environment variable","required_params":[{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"DELETE":{"href":"https://stg.openshift.redhat.com/broker/rest/application/52972ba7dbd93c4dd6000252/environment-variable/NEW","method":"DELETE","optional_params":[],"rel":"Delete environment variable","required_params":[]}},"name":"NEW","value":"new var"}],"messages":[{"exit_code":0,"field":null,"index":null,"severity":"info","text":"Patched environment variables for application diy"}],"status":"created","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6],"type":"environment-variables","version":"1.6"}

Comment 5 openshift-github-bot 2013-12-11 15:22:31 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/fe197de3e056e9d71df9891a4c15c0d894c90136
Fix bug 1039760: Add patch support for env vars

Comment 6 Liang Xia 2013-12-12 09:24:34 UTC
Verified on devenv_4125.

# curl -k --user lxia https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variables -X PATCH -d environment_variables[][name]=FOO -d environment_variables[][name]=BAR -d environment_variables[][value]=updated -d environment_variables[][name]=NEW -d environment_variables[][value]='new var'
Enter host password for user 'lxia':
{"api_version":1.6,"data":[{"links":{"GET":{"href":"https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variable/BAR","method":"GET","optional_params":[],"rel":"Get environment variable","required_params":[]},"UPDATE":{"href":"https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variable/BAR","method":"PUT","optional_params":[],"rel":"Update environment variable","required_params":[{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"DELETE":{"href":"https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variable/BAR","method":"DELETE","optional_params":[],"rel":"Delete environment variable","required_params":[]}},"name":"BAR","value":"updated"},{"links":{"GET":{"href":"https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variable/NEW","method":"GET","optional_params":[],"rel":"Get environment variable","required_params":[]},"UPDATE":{"href":"https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variable/NEW","method":"PUT","optional_params":[],"rel":"Update environment variable","required_params":[{"description":"Value of the environment variable","invalid_options":[],"name":"value","type":"string","valid_options":[]}]},"DELETE":{"href":"https://localhost/broker/rest/application/52a94d348cdc1fe434000084/environment-variable/NEW","method":"DELETE","optional_params":[],"rel":"Delete environment variable","required_params":[]}},"name":"NEW","value":"new var"}],"messages":[{"exit_code":0,"field":null,"index":null,"severity":"info","text":"Patched environment variables for application diy"}],"status":"created","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6],"type":"environment-variables","version":"1.6"}


Note You need to log in before you can comment on or make changes to this bug.