Uploaded image for project: 'TrueNAS'
  1. TrueNAS
  2. NAS-103259

Remove use of os.chdir to prevent cwd issues with the iocage API

    XMLWordPrintable

    Details

      Description

      Here is the Stacktrace
      
      pool_dict = {'aclmode': {'parsed': 'passthrough', 'rawvalue': 'passthrough', 'source': 'INHERITED', 'value': 'PASSTHROUGH'}, 'atim...tivity': {'parsed': 'sensitive', 'rawvalue': 'sensitive', 'source': 'NONE', 'value': 'SENSITIVE'}, 'children': [], ...}
      
          def test_16_Destroying_dataset_for_WebDAV_use(pool_dict):
              id = pool_dict['id'].replace('/', '%2F')
          
              results = DELETE(f'/pool/dataset/id/{id}/')
      >       assert results.status_code == 200, results.text
      E       AssertionError: {
      E          "message": "[Errno 20] Not a directory",
      E          "traceback": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/restful.py\", line 535, in do\n    result = await self.middleware.call(methodname, *method_args, **method_kwargs)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1155, in call\n    app=app, pipes=pipes, job_on_progress_cb=job_on_progress_cb, io_thread=True,\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1097, in _call\n    return await methodobj(*args)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/service.py\", line 375, in delete\n    f'{self._config.namespace}.delete', self, self.do_delete, [id] + list(args)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1097, in _call\n    return await methodobj(*args)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/schema.py\", line 949, in nf\n    return await f(*args, **kwargs)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/pool.py\", line 2860, in do_delete\n    attachments = await delegate.query(path, True)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/snapshot.py\", line 347, in query\n    for task in await self.middleware.call('pool.snapshottask.query', [['enabled', '=', enabled]]):\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1155, in call\n    app=app, pipes=pipes, job_on_progress_cb=job_on_progress_cb, io_thread=True,\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1097, in _call\n    return await methodobj(*args)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/schema.py\", line 949, in nf\n    return await f(*args, **kwargs)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/service.py\", line 349, in query\n    'datastore.query', self._config.datastore, [], datastore_options\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1155, in call\n    app=app, pipes=pipes, job_on_progress_cb=job_on_progress_cb, io_thread=True,\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1111, in _call\n    return await run_method(methodobj, *args)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1053, in run_in_thread\n    return await self.loop.run_in_executor(self.__io_threadpool, functools.partial(method, *args, **kwargs))\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/io_thread_pool_executor.py\", line 25, in run\n    result = self.fn(*self.args, **self.kwargs)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/schema.py\", line 953, in nf\n    return f(*args, **kwargs)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/datastore.py\", line 185, in query\n    qs, options.get('extend'), options.get('extend_context'), options.get('prefix'), options.get('select'),\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/datastore.py\", line 98, in __queryset_serialize\n    select=select)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/__init__.py\", line 79, in django_modelobj_serialize\n    data = middleware.call_sync(extend, data, extend_context_value)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1171, in call_sync\n    io_thread=True, job_on_progress_cb=job_on_progress_cb,\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1194, in run_coroutine\n    return fut.result()\n  File \"/usr/local/lib/python3.7/concurrent/futures/_base.py\", line 428, in result\n    return self.__get_result()\n  File \"/usr/local/lib/python3.7/concurrent/futures/_base.py\", line 384, in __get_result\n    raise self._exception\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/main.py\", line 1097, in _call\n    return await methodobj(*args)\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/snapshot.py\", line 31, in extend\n    data['legacy'] = self._is_legacy(data, context['legacy_replication_tasks'])\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/plugins/snapshot.py\", line 326, in _is_legacy\n    (data['recursive'] and is_child(replication_task['source_datasets'][0], data['dataset'])) or\n  File \"/usr/local/lib/python3.7/site-packages/middlewared/utils/path.py\", line 11, in is_child\n    rel = os.path.relpath(child, parent)\n  File \"/usr/local/lib/python3.7/posixpath.py\", line 475, in relpath\n    start_list = [x for x in abspath(start).split(sep) if x]\n  File \"/usr/local/lib/python3.7/posixpath.py\", line 383, in abspath\n    cwd = os.getcwd()\nNotADirectoryError: [Errno 20] Not a directory\n"
      E         }
      E       assert 500 == 200
      E        +  where 500 = <Response [500]>.status_code
      
      api2/webdav_bsd.py:141: AssertionError

        Attachments

          Attachments

            JEditor

              Activity

                People

                Assignee:
                waqar Waqar Ahmed
                Reporter:
                eturgeon Eric Turgeon
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: