Bug 1020162

Summary: Deployments model validation fails for application
Product: OpenShift Online Reporter: Qiushui Zhang <qiuzhang>
Component: ocAssignee: Fabiano Franz <ffranz>
Status: CLOSED WONTFIX QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: ccoleman, dmcphers, ffranz, xtian
Target Milestone: ---Keywords: UpcomingRelease
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-11 21:32:13 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
Add broker log from instance in case it is helpful none

Description Qiushui Zhang 2013-10-17 07:42:19 UTC
Description of problem:
Add/Update member of a domain, an error may pop up, saying "is invalid". This error most likely happens when adding a new member to the domain at the first time.


Version-Release number of selected component (if applicable):
devenv_3907

How reproducible:
often

Steps to Reproduce:
The following steps may help to reproduce the issue:
1. Create an account on instance. Upgrade it to silver. Assume the first domain name is "qiuzhang".
2. Configure the instance so that one account may have more than one domains, for example 3 domains. Create some other domains, e.g. "qiuzhang2".
3. Create apps and operation on it, e.g. git push some changes, app restart, etc.
4. Add another account(assume the account name is "walter") to the first domain "qiuzhang":
rhc member add walter -n qiuzhang -r admin


Actual results:
[walter@dhcp-10-238 tmp]$ rhc member add walter -n qiuzhang -r admin 
Adding 1 administrator to domain ... is invalid
[walter@dhcp-10-238 tmp]$ rhc member list -n qiuzhang
Login               Role
------------------- -------------
qiuzhang admin (owner)
walter              admin


An error message pops up, saying "is invalid". But in fact, the member operation success and the member "walter" is added to the domain "qiuzhang"

Expected results:
The member is added and no error message is shown.

Additional info:
The exact steps to reproduce the issue are not figured out, but I meet this several times during my acceptance testing. The steps are what I did during the acceptance testing until I saw the issue.

Comment 1 Qiushui Zhang 2013-10-17 07:43:32 UTC
Created attachment 813214 [details]
Add broker log from instance in case it is helpful

Comment 2 Qiushui Zhang 2013-10-17 08:40:49 UTC
When removing member from a domain, similar error message could be seen:
[walter@dhcp-10-238 tmp]$ rhc domain list
Domain qiuzhang (owned by qiuzhang)
----------------------------------------------
  Created:            2:09 PM
  Allowed Gear Sizes: small, medium
  Members:            walter (admin), user_with_certificate_capabilities (view)

Domain qiuzhang2 (owned by qiuzhang)
-----------------------------------------------
  Created:            2:40 PM
  Allowed Gear Sizes: small, medium

You have access to 2 domains.
[walter@dhcp-10-238 tmp]$ rhc member remove user_with_certificate_capabilities -n qiuzhang -l walter 
Removing 1 member from domain ... Member '525f547e30ee63f8bf000005' not found.
[walter@dhcp-10-238 tmp]$ rhc domain list
Domain qiuzhang (owned by qiuzhang)
----------------------------------------------
  Created:            2:09 PM
  Allowed Gear Sizes: small, medium
  Members:            walter (admin)

Domain qiuzhang2 (owned by qiuzhang)
-----------------------------------------------
  Created:            2:40 PM
  Allowed Gear Sizes: small, medium

You have access to 2 domains.

Comment 4 Jordan Liggitt 2014-04-15 19:52:30 UTC
Can't recreate. Ran the above scenario 100 times and didn't hit any failures. Looking in the log, it looks like the following error was causing this message:

[0;37m2013-10-17 02:50:35.287[0m [[31mERROR[0m] Problem:
  Validation of Application failed.
Summary:
  The following errors were found: Deployments is invalid
Resolution:
  Try persisting the document with valid data or remove the validations. (pid:1653)
[0;37m2013-10-17 02:50:35.293[0m [[0;37mDEBUG[0m] SUCCESS ACTION=ADD_DOMAIN_MEMBER USER_ID=525f7f09aea893af4c000001 LOGIN=qiuzhang DOMAIN=qiuzhang  is invalid (pid:1653)


It looks like one of the deployment requests sent an empty array of activations in a Deployment object. This line in deployment.rb requires the "activations" field to be present (non-nil, non-empty):
validates_presence_of :activations

I see an empty activations array come through mcollective in the log:
[0;37m2013-10-17 02:30:04.609[0m [[0;37mDEBUG[0m] DEBUG: [#<MCollective::RPC::Result:0x000000014f9d30 @agent="openshift", @action="cartridge_do", @results={:sender=>"ip-10-151-24-155", :statuscode=>0, :statusmsg=>"OK", :data=>{:time=>nil, :output=>"Starting PYTHON cart\n", :exitcode=>0, :addtl_params=>{:deployments=>[{:id=>"5e6b6319", :ref=>"master", :sha1=>"8519d91", :force_clean_build=>false, :hot_deploy=>false, :created_at=>1381991398.3779998, :activations=>[]}]}}}>] (Request ID: 2b0cf1810c64f58595770d821fa13ba3) (pid:1877)

Then, attempts are made to add members, which fail because the login does not exist yet:

[0;37m2013-10-17 02:49:10.785[0m [[32mINFO [0m] Started POST "/broker/rest/domain/qiuzhang/members" for 203.114.244.88 at 2013-10-17 02:49:10 -0400 (pid:1653)
[0;37m2013-10-17 02:49:10.932[0m [[0;37mDEBUG[0m] SUCCESS ACTION=ADD_DOMAIN_MEMBER USER_ID=525f7f09aea893af4c000001 LOGIN=qiuzhang DOMAIN=qiuzhang Not all provided members exist. There is no account with identifier walter. (pid:1653)

[0;37m2013-10-17 02:50:22.128[0m [[32mINFO [0m] Started POST "/broker/rest/domain/qiuzhang/members" for 203.114.244.88 at 2013-10-17 02:50:22 -0400 (pid:1653)
[0;37m2013-10-17 02:50:22.139[0m [[0;37mDEBUG[0m] SUCCESS ACTION=ADD_DOMAIN_MEMBER USER_ID=525f7f09aea893af4c000001 LOGIN=qiuzhang DOMAIN=qiuzhang Not all provided members exist. There is no account with identifier walter. (pid:1653)

And then, an attempt is made to add a member which fails because of the invalid deployment in the app model:

[0;37m2013-10-17 02:50:35.230[0m [[32mINFO [0m] Started POST "/broker/rest/domain/qiuzhang/members" for 203.114.244.88 at 2013-10-17 02:50:35 -0400 (pid:1653)
[0;37m2013-10-17 02:50:35.287[0m [[31mERROR[0m] Problem:
  Validation of Application failed.
Summary:
  The following errors were found: Deployments is invalid
Resolution:
  Try persisting the document with valid data or remove the validations. (pid:1653)

Comment 5 Jordan Liggitt 2014-04-16 12:44:40 UTC
ffranz, any idea on how this validation could fail, or if the empty activations array might have anything to do with it?