openvcloud / 0-templates

Apache License 2.0
1 stars 5 forks source link

Didn't get clear server error when creating an account with non-exisitng openvcloud param #117

Closed john-kheir closed 6 years ago

john-kheir commented 6 years ago

Scenario

1- Run a blueprint to create an account using non-existing openvlcoud param

Blueprint

services:
  - github.com/openvcloud/0-templates/sshkey/0.0.1__dc168596:
       name: 'cb469ebb'
       dir: '/root/.ssh/'
       passphrase: '4ac9b898'
  - github.com/openvcloud/0-templates/openvcloud/0.0.1__0993295e:
      name: 'be-g8-3.demo.greenitglobe.com'
      address: 'be-g8-3.demo.greenitglobe.com'
      login: 'gig_qa_1@itsyouonline'
      token: '***'
      location: 'be-g8-3'
  - github.com/openvcloud/0-templates/vdcuser/0.0.1__gig_qa_1:
      openvcloud: 0993295e
      name: gig_qa_1
      email: dina.magdy.mohammed+123@gmail.com
      p\rovider: itsyouonline
  - github.com/openvcloud/0-templates/account/0.0.1__3172840e:
      openvcloud: 49d99b4f
      name: de1e1a01

actions:
  - template: github.com/openvcloud/0-templates/vdcuser/0.0.1
    actions: ['install']
  - template: github.com/openvcloud/0-templates/openvcloud/0.0.1
    actions: ['install']
  - template: github.com/openvcloud/0-templates/account/0.0.1
    actions: ['install']

Server Error:

* robot running at :6601
, Retrying in 3 seconds...
* Get OpenvCloud client on URL: be-g8-3.demo.greenitglobe.com
* Get OpenvCloud client on URL: be-g8-3.demo.greenitglobe.com
* Get OpenvCloud client on URL: be-g8-3.demo.greenitglobe.com
, Retrying in 6 seconds...
, Retrying in 12 seconds...
, Retrying in 24 seconds...
[Mon14 07:25] - base.py           :201 :service-74e0319b-d5c2-4b05-b9ce-813990fcad62 - ERROR    - error executing action install:
Traceback (most recent call last):
  File "/root/0-robot/zerorobot/task/task.py", line 79, in execute
    self._result = self._func()
  File "/root/0-robot/zerorobot/template/decorator.py", line 43, in f_retry
    return f(*args, **kwargs)
  File "/opt/code/github/openvcloud/0-templates/templates/account/account.py", line 81, in install
    self._account = self.ovc.account_get(
  File "/opt/code/github/openvcloud/0-templates/templates/account/account.py", line 34, in ovc
    template_uid=self.OVC_TEMPLATE, name=self.data['openvcloud'])
  File "/root/0-robot/zerorobot/dsl/ZeroRobotAPI.py", line 75, in get
    raise scol.ServiceNotFoundError()
zerorobot.service_collection.ServiceNotFoundError

Expected Result

Server Error saying that non existing openvcloud param was provided to the account service

katia-e commented 6 years ago

@john-kheir , there is no check for nonexistent fields. Checks provided in the templates validate only that required fields are provided. In case of openvcloud template provider key is optional and has default value itsyouonline, therefore the faulty key will be added to schema, but never used, while default value is used instead. If required field like name is not given correctly (n\ame), the error will occur pointing out that name is not given. I think the error has occurred because account service uses openvcloud service that doesn't exist, so ServiceNotFoundError is the correct error.

john-kheir commented 6 years ago

@katia-e As we discussed .. seems this is not an issue as the error says "Service Not Found" which is true .. but please check if we can make this error clear by specifying the service that wasn't found.

zaibon commented 6 years ago

This need to be handle in the template code, catch the error and wrap it with proper error message for end user: https://github.com/zero-os/0-robot/issues/198#issuecomment-389534596

katia-e commented 6 years ago

@zaibon , I did try to do it like that at first, but @FastGeert insisted we don't catch errors to improve error message and the error message from robot should be clear, so I removed code catching and wrapping errors. @zaibon and @FastGeert, could we please come to a single opinion about it?

zaibon commented 6 years ago

@katia-e @FastGeert I can't give you more detail cause in certain case like this one, I don't have more info to return to the caller. So if you really want detail, you have to deal with it in the template and wrap error yourself.

FastGeert commented 6 years ago

@zaibon Well the error message could be

ServiceNotFoundError: Could not find service of type "github.com/openvcloud/0-templates/openvcloud/0.0.1" with name "49d99b4f", which is what @john-kheir expects. This data you have at your disposal.

zaibon commented 6 years ago

Not always that's what I'm saying.

zaibon commented 6 years ago

fixed in https://github.com/zero-os/0-robot/commit/621a42a4897b5b3bfccc3102f7c43f0fe48ed33d