Bug 1048758 - Unable to modify app;a env variable via REST
Summary: Unable to modify app;a env variable via REST
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Pod
Version: 1.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Dan McPherson
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-06 10:10 UTC by Oleg Fayans
Modified: 2016-12-01 00:27 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-02-18 03:27:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
error message (834 bytes, text/html)
2014-01-06 10:10 UTC, Oleg Fayans
no flags Details

Description Oleg Fayans 2014-01-06 10:10:11 UTC
Created attachment 846008 [details]
error message

Description of problem:

When I create a custom env variable via REST and then try to alter it using REST, I get the routing error.
Then REST request which causes the error is: 

curl -k -X PUT https://ec2-75-101-181-228.compute-1.amazonaws.com/broker/rest/application/52ca7db613d6588c4a0000e7/environment-variables/foo --data-urlencode value=4444 -u ofayans:redhat

Version-Release number of selected component (if applicable):
AMI ID: 
ami-71370018

How reproducible:
Always

Steps to Reproduce:
1. Create an app
2. Create a custom env variable named foo:
curl -k -X POST https://ec2-75-101-181-228.compute-1.amazonaws.com/broker/rest/application/52ca7db613d6588c4a0000e7/environment-variables --data-urlencode name=foo --data-urlencode value=1111 -u ofayans:redhat

3. try to alter it with the command listed in the problem description.

Actual results:
Routing error (see attachment)

Expected results:
env var is modified

Additional info:
I used the REST API guide available at http://docbuilder.usersys.redhat.com/17780/#Update_Environment_Variable

Comment 1 Oleg Fayans 2014-01-08 14:54:29 UTC
same problem with unsetting the env var:
curl -k -X DELETE https://ec2-54-196-165-106.compute-1.amazonaws.com/broker/rest/application/52cd62f6f017aea3310002f6/environment-variables/foo

fails to find corresponding route

Comment 2 Dan McPherson 2014-01-09 19:02:38 UTC
@ofayans You need to change

environment-variables  to be   environment-variable  for PUT and DELETE


I will transfer the bug to get the doc fixed.

-Dan

Comment 3 Dan McPherson 2014-01-09 20:02:29 UTC
Note: Also GET in the docs of a single variable should use the singular environment-variable.

Comment 6 Oleg Fayans 2014-01-28 15:54:09 UTC
Modified the path, now the response is as follows:

$ curl -k -X PUT https://ec2-23-23-29-188.compute-1.amazonaws.com/broker/rest/application/52e7cd00a661de34c400025c/environment-variable/OPENSHIFT_DATA_DIR.json --data-urlencode value=1234 -u ofayans:redhat

{"api_version":1.6,"data":null,"messages":[{"exit_code":189,"field":null,"index":null,"severity":"error","text":"Environment name 'OPENSHIFT_DATA_DIR' not found in application"}],"status":"not_found","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6],"type":null,"version":"1.6"}

Should be exit_code 403 and error text something like: cannot be overridden

Comment 7 Dan McPherson 2014-01-28 16:26:29 UTC
You can't modify system env vars with the api.  Only user set env vars.

Comment 8 Oleg Fayans 2014-01-29 12:54:57 UTC
Agree, but let's at least make error message more meaningful. Because now it informs the user that there is no such ENV variable in the app, which is clearly not true

Comment 9 Dan McPherson 2014-01-29 14:09:52 UTC
https://github.com/openshift/origin-server/pull/4615

Comment 12 Jianwei Hou 2014-01-30 05:23:03 UTC
Verified on devenv_4302

The messgae to the user is improved

curl -s -k -H "content-type: application/json" -u jhou:redhat https://ec2-184-73-38-27.compute-1.amazonaws.com/broker/rest/application/52e9cc23444416b526000006/environment-variable/OPENSHIFT_DATA_DIR -X GET       

{"api_version":1.6,"data":null,"messages":[{"exit_code":189,"field":null,"index":null,"severity":"error","text":"User environment variable named 'OPENSHIFT_DATA_DIR' not found in application"}],"status":"not_found","supported_api_versions":[1.0,1.1,1.2,1.3,1.4,1.5,1.6],"type":null,"version":"1.6"}


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