Bug 1048758

Summary: Unable to modify app;a env variable via REST
Product: OpenShift Online Reporter: Oleg Fayans <ofayans>
Component: PodAssignee: Dan McPherson <dmcphers>
Status: CLOSED NEXTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.xCC: alyoung, amarecek, baulakh, dmcphers, gpei, jhou
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-18 03:27:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
error message none

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"}