threefoldtecharchive / 0-templates

0-robot templates
Apache License 2.0
1 stars 1 forks source link

get returns all services if the `name=''` and namespace creation will stuck at some point #235

Closed 0xIslamTaha closed 5 years ago

0xIslamTaha commented 5 years ago
======================================================================
1) ERROR: test002_upload_stop_parity_zdb_download
----------------------------------------------------------------------
   Traceback (most recent call last):
    testcases/s3/test02_zdb.py line 47 in test002_upload_stop_parity_zdb_download
      self.s3.failures.zdb_up(count=self.s3.parity)
    utils/failures.py line 179 in zdb_up
      zdb = robot.services.get(name=ns.data['data']['zerodb'], template_name='zerodb')
    /opt/code/github/threefoldtech/0-robot/zerorobot/dsl/ZeroRobotManager.py line 120 in get
      raise TooManyResults("%d services found" % i)
   TooManyResults: 20 services found

we found how exactly that happened

ipdb> robot.services.get(name=ns.data['data']['zerodb'], template_name='zerodb')
*** zerorobot.service_collection.TooManyResults: 20 services found
ipdb> ns.data['data']['zerodb']
''
ipdb> ns.data
{'data': {'password': 'ubj2rj8i3koqp7cvzsm3gdg9p1kv1ju7', 'zerodb': '', 'public': False, 'diskType': 'hdd', 'nsName': 'namespace', 'size': 1000, 'mode': 'direct'}, 'guid': 'cf1b7e0c-4e48-489c-b08d-165c1ebf5c2f', 'name': 'cf1b7e0c-4e48-489c-b08d-165c1ebf5c2f', 'public': False, 'state': [{'category': 'actions', 'state': 'ok', 'tag': 'install'}], 'template': 'github.com/threefoldtech/0-templates/namespace/0.0.1', 'version': '0.0.1'}

we were trying to get a service with empty name so it returns all zdbs. I suggest checking the len of the name args to fix the error.

In another hand we found that this namespace hasn't a zdb and that may be occured cause we turned off this namespace's zdb many times and at some point all the running zdb has a namespace with the same name of this namespace so there is no way to create it again so it wouldn't have a zdb forever.

This scenario should be healing on the s3_redundant

serboctor commented 5 years ago

After discussion with @zaibon, we decided to drop the naemspace selfheal where it reinstalls itself on a different zerodb. The selfhealing implemented by @muhamadazmy and @andrewayoub is already enough and if a namespace is not reachable anymore it uninstalls and delete it, then creates a new namespace service and install it

This https://github.com/threefoldtech/0-templates/pull/236/files reverts the namespace selfhealing. And makes sure the s3 keeps trying to delete the dead namespace services.