Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az storage blob sync: path NoneType #9576

Closed
dbaio opened this issue Jun 6, 2019 · 4 comments
Closed

az storage blob sync: path NoneType #9576

dbaio opened this issue Jun 6, 2019 · 4 comments
Assignees
Labels
Storage az storage

Comments

@dbaio
Copy link

dbaio commented Jun 6, 2019

The path is valid, it seems the arguments are not read...

Command Name
az storage blob sync

Errors:

The command failed with an unexpected error. Here is the traceback:


stat: path should be string, bytes, os.PathLike or integer, not NoneType
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 560, in execute
    raise ex
  File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 618, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 609, in _run_job
    cmd_copy.exception_handler(ex)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/command_modules/storage/__init__.py", line 240, in new_handler
    handler(ex)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/command_modules/storage/__init__.py", line 183, in handler
    raise ex
  File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 588, in _run_job
    result = cmd_copy(params)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 297, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 461, in default_command_handler
    return op(**command_args)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 36, in storage_blob_sync
    azcopy = _azcopy_blob_client(cmd, client)
  File "/usr/local/lib/python3.6/site-packages/azure/cli/command_modules/storage/operations/azcopy.py", line 54, in _azcopy_blob_client
    return AzCopy(creds=blob_client_auth_for_azcopy(cmd, client))
  File "/usr/local/lib/python3.6/site-packages/azure/cli/command_modules/storage/azcopy/util.py", line 34, in __init__
    if not os.path.isfile(install_location):
  File "/usr/local/lib/python3.6/genericpath.py", line 30, in isfile
    st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az storage blob sync -c {} --account-name {} -s {} -d {}

Expected Behavior

Environment Summary

FreeBSD-13.0-CURRENT-amd64-64bit-ELF
Python 3.6.8
Shell: bash

azure-cli 2.0.66

Extensions:
interactive 0.4.1

Additional Context

@tjprescott tjprescott added bug This issue requires a change to an existing behavior in the product in order to be resolved. Storage az storage labels Jun 6, 2019
@limingu
Copy link
Member

limingu commented Jun 7, 2019

PR: #9589 should fix this issue.

@dbaio
Copy link
Author

dbaio commented Jun 23, 2019

@limingu limingu assigned Juliehzl and unassigned limingu Aug 1, 2019
@Juliehzl
Copy link
Contributor

@dbaio We have discussed with azcopy team. Because azcopy team has high-priority work to do, they need some time to release FreeBSD version and we will keep a close watch on this.

@haroldrandom haroldrandom added bug This issue requires a change to an existing behavior in the product in order to be resolved. Storage-cli labels Oct 25, 2019
@cemeyer
Copy link

cemeyer commented Dec 3, 2019

(#9589 is not related to this bug.)

The following small change should address the issue, combined with manually building azcopy:

--- azure/cli/command_modules/storage/azcopy/util.py.orig        2019-12-02 13:03:52.425115000 -0800
+++ azure/cli/command_modules/storage/azcopy/util.py     2019-12-02 13:05:51.576481000 -0800
@@ -41,6 +41,8 @@
                 file_url = base_url.format('linux', 'tar.gz')
             elif self.system == 'Darwin':
                 file_url = base_url.format('darwin', 'zip')
+            elif self.system == 'FreeBSD':
+                raise CLIError('Azcopy ({}) binary not available, please build from https://github.com/Azure/azure-storage-azcopy and install in $HOME/bin/azcopy'.format(self.system))
             else:
                 raise CLIError('Azcopy ({}) does not exist.'.format(self.system))
             try:
@@ -163,7 +165,7 @@
         if not home_dir:
             return None
         install_location = os.path.join(home_dir, r'.azcopy\azcopy.exe')
-    elif system in ('Linux', 'Darwin'):
+    elif system in ('Linux', 'Darwin', 'FreeBSD'):
         install_location = os.path.expanduser(os.path.join('~', 'bin/azcopy'))
     else:
         install_location = None

The problem is returning None for install_location above causes an immediate and unintuitive backtrace in the caller (os.path.isfile(None) raises an exception because the isfile API only accepts strings and Paths). While the patch above addresses the issue for FreeBSD, it might be better in general to raise an exception here for unrecognized platforms instead of returning None.

In addition, I have implemented basic azcopy support for FreeBSD in Azure/azure-storage-azcopy#768 . It seems like it is at least sufficient to upload a local image to a managed disk.

@Juliehzl Juliehzl added Storage az storage and removed Storage-cli labels Jan 2, 2020
@yonzhan yonzhan added this to the S165 milestone Feb 1, 2020
@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 1, 2020
@yonzhan yonzhan modified the milestones: S165, S166 Feb 15, 2020
@yonzhan yonzhan modified the milestones: S166, S167 Mar 5, 2020
@yonzhan yonzhan modified the milestones: S167, S168 Mar 26, 2020
@yonzhan yonzhan modified the milestones: S168, S169 - For Build Apr 18, 2020
zhoxing-ms added a commit that referenced this issue May 15, 2020
…azcopy cannot find the installation location (#9576)  (#13104)

* Fix the incorrect error message when azcopy cannot find the installation location

* Modify error message

* format code
derekbekoe added a commit to derekbekoe/azure-cli that referenced this issue May 18, 2020
* 'dev' of https://github.com/Azure/azure-cli: (85 commits)
  {Monitor} az monitor autoscale profile show: bug fix (Azure#13515)
  [Monitor] az monitor diagnostic-settings create: support --export-to-specific-resource argument (Azure#13544)
  [aro]Add tests for generate_random_id function (Azure#13522)
  [ARO]Change CLIError to correct flag for --worker-vm-disk-size-gb (Azure#13439)
  [Packaging] Add Ubuntu Focal Package (Azure#13491)
  Update parse_zone_file.py (Azure#13377)
  {Release} Upgrade to Azure CLI 2.6.0 (Azure#13542)
  fix (Azure#13511)
  {Resource} Add example to tell how to pass array to --parameters (Azure#13510)
  [NetAppFiles] Anf 5207 Bugfix - add missing snapshot restore function (Azure#13481)
  {Network} az network nic create: Refine help message (Azure#13513)
  [Storage] az storage blob sync: Fix the incorrect error message when azcopy cannot find the installation location (Azure#9576)  (Azure#13104)
  Support --connect-string for az storage blob sync (Azure#13135)
  Modify the deprecate information for deployment operation (Azure#13390)
  [AppService] Onboard local context for app service (Azure#12984)
  {Monitor} az monitor metrics alert: refine severity explanation (Azure#13512)
  [IoT Hub] Support for 2020-03-01 API and Network Isolation commands (Azure#13467)
  [Compute] az vm list-skus: Update --zone behavior, return all type skus now (Azure#13470)
  Fix that cli doe not fail when user only specifies Windows password (Azure#13418)
  {ACR}: expose --expiration from token commands (Azure#13451)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage az storage
Projects
None yet
Development

No branches or pull requests

8 participants