saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.09k stars 5.47k forks source link

'salt-call pkg.list_pkgs' in Windows ascii/unicode error #20379

Closed blaffoy closed 9 years ago

blaffoy commented 9 years ago

In versions 2014.7.0 and 2014.7.1 on Windows 7, I see the following error:

C:\Users\blaffoy>salt-call pkg.list_pkgs
[INFO    ] Executing command 'Powershell " $msi = New-Object -ComObject WindowsInstaller.Installer; $msi.GetType().InvokeMember(\'ProductsEx\', \'GetProperty\', $null, $msi, (\'\', \'s-1-1-0\', 7)) | select @{       name=\'name\';       expression={$_.GetType().InvokeMember(\'InstallProperty\', \'GetProperty\', $null, $_, (\'ProductName\'))}     },     @{       name=\'version\';       expression={$_.GetType().InvokeMember(\'InstallProperty\', \'GetProperty\', $null, $_, (\'VersionString\'))}     } | Write-host "' in directory 'C:\\Users\\blaffoy-admin'
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 12: ordinal not in range(128)
Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "__main__.py", line 726, in <module>
  File "__main__.py", line 332, in bootstrap
  File "__main__.py", line 359, in chainload
  File "__main__.py", line 715, in _chainload
  File "__main__.py", line 128, in <module>
  File "__main__salt-call__.py", line 14, in <module>
  File "salt/scripts.py", line 123, in salt_call
  File "salt/cli/__init__.py", line 420, in run
  File "salt/cli/caller.py", line 235, in run
  File "salt/output/__init__.py", line 44, in display_output
  File "salt/output/nested.py", line 122, in output
  File "salt/output/nested.py", line 113, in display
  File "salt/output/nested.py", line 105, in display
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 12: ordinal not in range(128)
Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "__main__.py", line 726, in <module>
  File "__main__.py", line 332, in bootstrap
  File "__main__.py", line 359, in chainload
  File "__main__.py", line 715, in _chainload
  File "__main__.py", line 128, in <module>
  File "__main__salt-call__.py", line 14, in <module>
  File "salt/scripts.py", line 123, in salt_call
  File "salt/cli/__init__.py", line 420, in run
  File "salt/cli/caller.py", line 235, in run
  File "salt/output/__init__.py", line 44, in display_output
  File "salt/output/nested.py", line 122, in output
  File "salt/output/nested.py", line 113, in display
  File "salt/output/nested.py", line 105, in display
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 12: ordinal not in range(128)

C:\Users\blaffoy>

If I reconstruct the Powershell call shown in the output, the result looks correct:

PS C:\> $msi.GetType().InvokeMember('ProductsEx', 'GetProperty', $null, $msi, ('', 's-1-1-0', 7)) | select @{       name='name';       expression={$_.GetType().InvokeMember('InstallProperty', 'GetProperty', $null, $_, ('ProductName'))}
},     @{       name='version';       expression={$_.GetType().InvokeMember('InstallProperty', 'GetProperty', $null, $_, ('VersionString'))}     } | Write-host
@{name=Microsoft Office OneNote MUI (English) 2010; version=14.0.7015.1000}
@{name=Microsoft Office Standard 2010; version=14.0.7015.1000}
@{name=Microsoft Office Shared Setup Metadata MUI (English) 2010; version=14.0.7015.1000}
@{name=Microsoft Office Excel MUI (English) 2010; version=14.0.7015.1000}
@{name=Microsoft Office Shared 64-bit Setup Metadata MUI (English) 2010; version=14.0.7015.1000}
@{name=Microsoft Office 2010 Primary Interop Assemblies; version=14.0.4763.1150}
@{name=Microsoft Office PowerPoint MUI (English) 2010; version=14.0.7015.1000}
@{name=Microsoft Office Publisher MUI (English) 2010; version=14.0.7015.1000}
@{name=Microsoft Office Outlook MUI (English) 2010; version=14.0.7015.1000}
...

Also, if I run this command from the master (running on Ubuntu, v2014.7.1), it looks okay:

blaffoy@salt:~/repos/pillar$ sudo salt my-minion pkg.list_pkgs
salt.myorg.local:
    ----------
     Tools for .Net 3.5:
        3.11.50727
    7-Zip 9.22 (x64 edition):
        9.22.00.0
    ????? Visual Studio 2012 Verification SDK - rus:
        12.0.30501
    AWS Tools for Windows:
        3.7.413.0
    Adobe Flash Player 15 ActiveX:
        15.0.0.167
    Adobe Flash Player 15 Plugin:
        15.0.0.239
    Adobe Reader XI (11.0.10):
        11.0.10
    Adobe Refresh Manager:
        1.8.0
    Application Insights Tools for Visual Studio 2013:
        2.4
    AzureTools.Notifications:
...

I thought that I previously observed this error leading to all calls to pkg.install(ed) and pkg.remove(d) returning an error even if the package installed/uninstalled correctly as they would call pkg.list_pkgs on completion. I can't reproduce that behaviour now, so I may have been mistaken.

ssgward commented 9 years ago

Thanks for the report.

We haven't been able to reproduce on 2014.7.0 or 2014.7.1 on Window 7. The command salt-call pkg.list_pkgs returns correct results without error.

Any other info you could provide to help duplicate the problem? Anything specific about the OS setup/configuration?

blaffoy commented 9 years ago

I wonder if it's a character in one of the package names of those installed? I'll check tomorrow for any non-ascii characters.

blaffoy commented 9 years ago

Hi

I think I understand the problem. Visual Studio installed various language tools with unicode characters in the package name.

IdentifyingNumber : {977CABC5-7B4B-3AE4-8E1B-56C673C1D638} Name : Пакет Visual Studio 2012 Verification SDK - rus Vendor : Microsoft Corporation Version : 12.0.30501 Caption : Пакет Visual Studio 2012 Verification SDK - rus

IdentifyingNumber : {DEBF18DD-F351-3FC3-9BF4-8B20AC2EF5EF} Name : Visual Studio 2012 유효성 검사 SDK - kor Vendor : Microsoft Corporation Version : 12.0.30501 Caption : Visual Studio 2012 유효성 검사 SDK - kor

IdentifyingNumber : {3169A65F-9DA5-331A-ACCE-D970F9020404} Name : Visual Studio 2012 驗證 SDK - cht Vendor : Microsoft Corporation Version : 12.0.30501 Caption : Visual Studio 2012 驗證 SDK - cht

Running pkg.list_pkgs on a machine with these installed results in the error I described before. Running it on a machine without these returns the list of installed packages as expected.

Can you confirm if this makes sense?

Thanks Barry

On Wed, Feb 4, 2015 at 8:58 PM, ssgward notifications@github.com wrote:

Thanks for the report.

We haven't been able to reproduce on 2014.7.0 or 2014.7.1 on Window 7. The command salt-call pkg.list_pkgs returns correct results without error.

Any other info you could provide to help duplicate the problem? Anything specific about the OS setup/configuration?

— Reply to this email directly or view it on GitHub https://github.com/saltstack/salt/issues/20379#issuecomment-72937392.

ssgward commented 9 years ago

That info shares some more light on the problem. Looks like we'll need to account for those different language characters.

twangboy commented 9 years ago

Running Salt-Minion 2015.5.3 on Windows Server 2008R2 64. Installed Google Pinyin 2.7 to get me some Unicode software. Ran salt test_dev_64 pkg.list_pkgs This is what I get:

test_dev_64:
    ----------
    ??????? 2.7:
        Not Found
    AWS Tools for Windows:
        3.7.581.0
    ...

On the local machine (salt-call pkg.list_pkgs):

local:
    ----------
    ??????? 2.7:
        Not Found
    AWS Tools for Windows:
        3.7.581.0
    ...

It's not crashing any more, but it should probably translate the Unicode text instead of giving us question marks, right? It should say this:

谷歌拼音输入法 2.7

@terminalmage @UtahDave ^^^^^^^^^^^^^^

jefftucker commented 9 years ago

I'm seeing this also on my windows machine running masterless on version 2014.7.1. Is a fix available or planned to be available at least? If I fix this and send a pull request will you merge it?

twangboy commented 9 years ago

@jefftucker We're not updating the 2014.7 branch any more. Please upgrade to the latest 2015.5 release. It should be fixed in that branch.