Description of problem: `oc env -h` shows "--overwrite=true: If true, allow environment to be overwritten, otherwise reject updates that overwrite existing environment". But "--overwrite=false" does not work in fact. Version-Release number of selected component (if applicable): oc v1.1.1-361-g6408278 kubernetes v1.2.0-alpha.4-851-g4a65fa1 How reproducible: Always Steps to Reproduce: 1. oc login, create a project 2. Create a rc $ oc run hello-rc --image=openshift/hello-openshift --generator=run-controller/v1 3. Set an env variable into rc pod template 1> $ oc env rc/hello-rc -e MY_ENV=VALUE replicationcontroller "hello-rc" updated 2> $ oc env rc/hello-rc --list # replicationcontrollers hello-rc, container hello-rc MY_ENV=VALUE 4. Use "--overwrite=false" when using "oc env -e" 1> $ oc env rc/hello-rc -e MY_ENV=VALUE-2 --overwrite=false replicationcontroller "hello-rc" updated 2> $ oc env rc/hello-rc --list # replicationcontrollers hello-rc, container hello-rc MY_ENV=VALUE-2 5. Use "--overwrite=false" when not using "-e" flag 1> $ oc env rc/hello-rc MY_ENV=VALUE-3 --overwrite=false replicationcontroller "hello-rc" updated 2> $ oc env rc/hello-rc --list # replicationcontrollers hello-rc, container hello-rc MY_ENV=VALUE-3 Actual results: In steps 4 and 5, "--overwrite=false" does not work Expected results: In steps 4 and 5, "--overwrite=false" should reject updates that overwrite existing environment Additional info:
Fixed in https://github.com/openshift/origin/pull/9495
Tested with: oc v1.3.0-alpha.2-194-g82718a8 kubernetes v1.3.0-alpha.3-599-g2746284 The problem is fixed. --overwrite=false takes effect now. The results of step 4.1 and 5.1 give message: error: replicationcontrollers/hello-rc 'MY_ENV' already has a value (VALUE), and --overwrite is false error: no environment variable has been set But when used for multiple resources, in which some resource already has defined the var but some other resource does not yet defined that var, it will do additional PATCH on the former resource: # Prepare steps oc run hello-rc --image=openshift/hello-openshift --generator=run-controller/v1 oc run world-rc --image=openshift/hello-openshift --generator=run-controller/v1 oc set env rc/hello-rc -e MY_ENV=VALUE oc set env rc hello-rc world-rc --list # replicationcontrollers hello-rc, container hello-rc MY_ENV=VALUE # replicationcontrollers world-rc, container world-rc # Now check the issue oc set env rc hello-rc world-rc -e MY_ENV=newvalue --overwrite=false error: replicationcontrollers/hello-rc 'MY_ENV' already has a value (VALUE), and --overwrite is false replicationcontroller "hello-rc" updated <-- ** Note this message (the additional PATCH does not take effect, though) replicationcontroller "world-rc" updated # see with --loglevel oc set env rc hello-rc world-rc -e MY_ENV=newvalue --overwrite=false --loglevel 6 ... GET https://<master>:8443/api/v1/namespaces/xxia-proj/replicationcontrollers/world-rc 200 OK in 258 milliseconds error: replicationcontrollers/hello-rc 'MY_ENV' already has a value (VALUE), and --overwrite is false ... PATCH https://<master>:8443/api/v1/namespaces/xxia-proj/replicationcontrollers/hello-rc 200 OK in 256 milliseconds replicationcontroller "hello-rc" updated ... # for single resource, does not do the additional PATCH oc set env rc hello-rc -e MY_ENV=newvalue --overwrite=false --loglevel 6 ... GET https://<master>:8443/api/v1/namespaces/xxia-proj/replicationcontrollers/hello-rc 200 OK in 255 milliseconds error: replicationcontrollers/hello-rc 'MY_ENV' already has a value (VALUE), and --overwrite is false F0624 17:33:21.523285 18414 helpers.go:107] error: no environment variable has been set ^ ** No additional PATCH after error message So need fix the issue? If necessary, could use a new bug to track it.
Fixed in https://github.com/openshift/origin/pull/9552, we also removed the "no environment variable has been set" message.
Thanks! Checked the issue in comment 2 is fixed in oc v1.3.0-alpha.2-250-g61eba05