Bug 1308739 - It will not validate the deployment type when do app deploy via REST API
It will not validate the deployment type when do app deploy via REST API
Status: CLOSED ERRATA
Product: OpenShift Container Platform
Classification: Red Hat
Component: Master (Show other bugs)
2.2.0
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Rory Thrasher
weiwei jiang
:
Depends On: 1104140
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-15 17:12 EST by Rory Thrasher
Modified: 2016-10-30 18:55 EDT (History)
7 users (show)

See Also:
Fixed In Version: rubygem-openshift-origin-controller-1.38.5.1-1.el6op
Doc Type: Bug Fix
Doc Text:
Apps have a deploy mode that can be either binary or git. When attempting to deploy via the REST API, this deploy mode was not checked, allowing users to deploy using the incorrect method. The REST API will now check the git deploy mode and return an error if the deployment attempt is not using the correct mode.
Story Points: ---
Clone Of: 1104140
Environment:
Last Closed: 2016-03-22 12:54:50 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rory Thrasher 2016-02-15 17:12:43 EST
+++ This bug was initially created as a clone of Bug #1104140 +++

Description of problem:
Try to do binary deploy on the app with git deploy method configured via rest api, will get succeeded. Vice versa. 

Version-Release number of selected component (if applicable):
STG(devenv-stage_861)
devenv-stage_861

How reproducible:
always

Steps to Reproduce:
1. Create app of any type
2. Do binary deploy via rest api without change the app configure to use binary deploy method
# curl -k -H "Accept: application/xml" --user "bmeng:123123" https://localhost/broker/rest/application/538dcd847c317b9d03000009/deployments -XPOST -d artifact_url=http://cphp-ccyd.rhcloud.com/cphp2.tar.gz

3. 

Actual results:
Will get succeeded.

  <status>created</status>
  <type>deployment</type>
  <data>
    <deployment>
      <created-at>2014-06-03T13:33:53Z</created-at>
      <hot-deploy>false</hot-deploy>
      <force-clean-build>false</force-clean-build>
      <ref>master</ref>
      <sha1 nil="true"></sha1>
      <id>a99f1e03</id>
      <activations>
        <activation>2014-06-03T13:33:56Z</activation>
      </activations>
    </deployment>
  </data>
  <messages>
    <message>
      <severity>info</severity>
      <text>Added a99f1e03 to application php54</text>
      <exit-code>0</exit-code>
      <field nil="true"></field>
      <index nil="true"></index>
    </message>
  </messages>


Expected results:
Should report that the app is configured as git deploy and does not support for the binary deploy.

Additional info:
Works well for the rhc client.

# rhc deploy http://cphp-ccyd.rhcloud.com/cphp2.tar.gz -a php54
The application 'php54' is configured for git reference deployments but the artifact provided ('http://cphp-ccyd.rhcloud.com/cphp2.tar.gz') is a url. Please provide a
git reference to deploy (branch, tag or commit SHA1) or configure your app to deploy from binaries with 'rhc configure-app php54 --deployment-type binary'.

The artifact provided is not compatible with the app deployment type.

--- Additional comment from openshift-github-bot on 2015-11-25 11:05:32 EST ---

Commits pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/8a3183b4b860c9b1de530647ebc6aa6e168d4ec4
deployments_controller.rb: Adds checks for app deployment mode via REST

Bug 1104140
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1104140

Adds additional checks to verify that the app is in the correct deployment mode when deploying via the REST api.  Will throw a 422 error when attempting to binary deploy in git mode or vice versa.

Adds deployment types to relevant REST api tests to specify deployment mode.

https://github.com/openshift/origin-server/commit/db254f5ee9cd758774427a42814f183932541571
Merge pull request #6320 from thrasher-redhat/bug1104140

Merged by openshift-bot

--- Additional comment from Rory Thrasher on 2016-01-06 16:46:08 EST ---

QA,

Please verify that this bug has been fixed.

1. When attempting to binary deploy via the rest API while in git deployment mode (default mode), there should be a 422 error similar to "The binary artifact provided is not compatible with the app deployment type, git".

2. When attempting to git deploy via the rest API while in binary deployment mode, there should be a 422 error similar to "The git ref provided is not compatible with the app deployment type, binary".

3. When attempting to git deploy in git deployment mode or binary deploy in binary deployment mode, the deployment should succeed as normal.

--- Additional comment from Meng Bo on 2016-01-08 05:26:40 EST ---

  <messages>
    <message>
      <severity>error</severity>
      <text>The git ref provided is not compatible with the app deployment type, 'binary'.</text>
      <exit-code>-1</exit-code>
      <field>ref</field>
      <index nil="true"></index>
    </message>
  </messages>

  <messages>
    <message>
      <severity>error</severity>
      <text>The binary artifact provided is not compatible with the app deployment type, 'git'.</text>
      <exit-code>-1</exit-code>
      <field>artifact_url</field>
      <index nil="true"></index>
    </message>
  </messages>

Issue has been fixed, the error message shown when deploying with incorrect type.
Comment 4 weiwei jiang 2016-02-26 01:48:10 EST
Checked with Puddle: http://etherpad.corp.redhat.com/puddle-2-2-2016-02-19.

1. When attempting to binary deploy via the rest API while in git deployment mode (default mode), there should be a 422 error similar to "The binary artifact provided is not compatible with the app deployment type, git".

2. When attempting to git deploy via the rest API while in binary deployment mode, there should be a 422 error similar to "The git ref provided is not compatible with the app deployment type, binary".

3. When attempting to git deploy in git deployment mode or binary deploy in binary deployment mode, the deployment should succeed as normal.

All as expected result.
Comment 6 errata-xmlrpc 2016-03-22 12:54:50 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-0489.html

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