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 crash caused by empty presentation text element #53532

dafyddj opened this issue Jun 19, 2019 · 4 comments


Copy link

commented Jun 19, 2019

Description of Issue

lgpo.set crashes when trying to configure "Delivery Optimization" on Windows 10.

FAO @lomeroe


    - computer_policy:
        Windows Components\Delivery Optimization\Download Mode:
          Download Mode: LAN (1)

Steps to Reproduce Issue

PS C:\WINDOWS\system32> salt-call.bat -l debug state.apply lgpo-test
          ID: lgpo-set-test
    Function: lgpo.set
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "C:\salt\bin\lib\site-packages\salt\", line 1919, in call
                File "C:\salt\bin\lib\site-packages\salt\", line 1918, in wrapper
                  return f(*args, **kwargs)
                File "C:\salt\bin\lib\site-packages\salt\states\", line 245, in set_
                File "c:\salt\var\cache\salt\minion\extmods\modules\", line 7736, in get
                File "c:\salt\var\cache\salt\minion\extmods\modules\", line 6238, in _checkAllAdmxPolicies
                File "c:\salt\var\cache\salt\minion\extmods\modules\", line 5562, in _getFullPolicyName
                  fullPolicyName = _getAdmlPresentationRefId(adml_data, policy_item.attrib['id'])
                File "c:\salt\var\cache\salt\minion\extmods\modules\", line 5523, in _getAdmlPresentationRefId
                  prepended_text = getattr(p_item, 'text', '').rstrip()
              AttributeError: 'NoneType' object has no attribute 'rstrip'
     Started: 15:31:57.920000
    Duration: 4030.0 ms

I believe this is caused by the empty text elements in the file en-US\DeliveryOptimization.adml file:

      <presentation id="SetHoursToLimitBackgroundDownloadBandwidth">
        <text>Set Business Hours to Limit Background Download Bandwidth:</text>
        <dropdownList defaultItem="8" noSort="true" refId="SetHoursToLimitBackgroundDownloadBandwidthFrom">From:</dropdownList>
        <dropdownList defaultItem="17" noSort="true" refId="SetHoursToLimitBackgroundDownloadBandwidthTo">To:</dropdownList>
        <text>Maximum Background Download Bandwidth (percentage) during Business Hours:</text>
        <decimalTextBox defaultValue="0" refId="SetHoursToLimitBackgroundDownloadBandwidthIn"/>
        <text>The default value is 0 (unlimited)</text>
        <text>Maximum Background Download Bandwidth (percentage) outside of Business Hours:</text>
        <decimalTextBox defaultValue="0" refId="SetHoursToLimitBackgroundDownloadBandwidthOut"/>
        <text>The default value is 0 (unlimited)</text>
      <presentation id="SetHoursToLimitForegroundDownloadBandwidth">
        <text>Set Business Hours to Limit Foreground Download Bandwidth:</text>
        <dropdownList defaultItem="8" noSort="true" refId="SetHoursToLimitForegroundDownloadBandwidthFrom">From:</dropdownList>
        <dropdownList defaultItem="17" noSort="true" refId="SetHoursToLimitForegroundDownloadBandwidthTo">To:</dropdownList>
        <text>Maximum Foreground Download Bandwidth (percentage) during Business Hours:</text>
        <decimalTextBox defaultValue="0" refId="SetHoursToLimitForegroundDownloadBandwidthIn"/>
        <text>The default value is 0 (unlimited)</text>
        <text>Maximum Foreground Download Bandwidth (percentage) outside of Business Hours:</text>
        <decimalTextBox defaultValue="0" refId="SetHoursToLimitForegroundDownloadBandwidthOut"/>
        <text>The default value is 0 (unlimited)</text>

Versions Report

Also tested with 2019.2.

Salt Version:
           Salt: 2018.3.4

Dependency Versions:
           cffi: 1.10.0
       cherrypy: 10.2.1
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: 2.1.3
          ioflo: Not Installed
         Jinja2: 2.9.6
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: 1.0.6
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.17
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)]
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.3
           RAET: Not Installed
          smmap: 2.0.5
        timelib: 0.2.4
        Tornado: 4.5.1
            ZMQ: 4.1.6

System Versions:
         locale: cp1252
        machine: AMD64
        release: 10
         system: Windows
        version: 10 10.0.17763  Multiprocessor Free

This comment has been minimized.

Copy link

commented Jun 20, 2019

@twangboy Anything specific jump out at you?

@xeacott xeacott added this to the Approved milestone Jun 20, 2019

This comment has been minimized.

Copy link

commented Jun 21, 2019

I'll try to take a look at this next week if @twangboy doesn't beat me to it...but updating the line throwing the exception to something like this should at least stop the exception from occurring (would need to be tested that the policy still gets set as desired)

prepended_text = getattr(p_item, 'text', '').rstrip() if getattr(p_item, 'text', '') else ''

This comment has been minimized.

Copy link

commented Jun 25, 2019

                    for p_item in presentation_element.getchildren():
                        if p_item == result:
                            if etree.QName(p_item.tag).localname == 'text':
                                if prepended_text:
                                    prepended_text = ' '.join(
                                        (text for text in (prepended_text, getattr(
                                        p_item, 'text', '').rstrip() if getattr(
                                        p_item, 'text', '') else '') if text))
                                    prepended_text = getattr(
                                        p_item, 'text', '').rstrip() if getattr(
                                        p_item, 'text', '') else ''
                                prepended_text = ''

This will do it.

@xeacott xeacott self-assigned this Jun 25, 2019
lomeroe added a commit to lomeroe/salt that referenced this issue Jun 28, 2019
fixes saltstack#53532

update test to handle "user" policy class test

This comment has been minimized.

Copy link

commented Jul 5, 2019

@dafyddj A PR was recently merged that should fix the issues you've been having, and if they did I'll go ahead and close this issue.

@xeacott xeacott closed this Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.