amendlik / salt-gen-resource

Generate Rundeck node resources from the Salt Mine
Other
8 stars 7 forks source link

[Breakage] 2 bugs with recent version of Saltstack #10

Closed sticky-note closed 1 year ago

sticky-note commented 2 years ago

Hi @amendlik, I am using SaltGenResource.py for years now. Everything was working fine but.. I just figured out that rundeck was not refreshing anymore with my minion list. I isolated 2 bugs that seems to be likely related with v3005 release but not 100% sure (maybe bugs arrived with v3004.x).

Bug 1:

root@rundeck_machine:~# sudo python3 /var/lib/rundeck/libext/SaltGenResource.py -s "*" -a manufacturer,os_family,os,osmajorrelease,osrelease,virtual,saltversion,saltenv username="rundeck"
Usage: SaltGenResource.py [options] <target> [<attr>=<value> ...]

SaltGenResource.py: error: Error while processing <function LogLevelMixIn.__setup_logfile_logger_config at 0x7f43f7cac268>: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/parsers.py", line 212, in parse_args
    mixin_after_parsed_func(self)
  File "/usr/lib/python3/dist-packages/salt/utils/parsers.py", line 783, in __setup_logfile_logger_config
    if self.config[self._logfile_loglevel_config_setting_name_] != "quiet":
KeyError: 'resource_generator_log_level_logfile'

Some potential modification in saltstack/salt gives rise to ignore resource_generator_log_level_logfile default value specified in Readme.md of this plugin. I found a workaround by hardcoding resource_generator_log_level_logfile: "warning" in my minion config

Bug 2:

root@rundeck_machine:~# sudo python3 /var/lib/rundeck/libext/SaltGenResource.py -s "*" -a manufacturer,os_family,os,osmajorrelease,osrelease,virtual,saltversion,saltenv username="rundeck"
[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
AttributeError: 'SaltNodesCommandParser' object has no attribute 'setup_logfile_logger_config'
Traceback (most recent call last):
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 431, in <module>
    print(ResourceGenerator().as_yaml())
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 213, in __init__
    parser.setup_logfile_logger_config()
AttributeError: 'SaltNodesCommandParser' object has no attribute 'setup_logfile_logger_config'
Traceback (most recent call last):
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 431, in <module>
    print(ResourceGenerator().as_yaml())
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 213, in __init__
    parser.setup_logfile_logger_config()
AttributeError: 'SaltNodesCommandParser' object has no attribute 'setup_logfile_logger_config'

I found a workaround by commenting problematic line https://github.com/amendlik/salt-gen-resource/blob/master/SaltGenResource.py#L265 and everything seems to work fine again.

Since I do not master developing with Salt Python API and I don't know how you want address this issues (keeping backward compatibility if something break with previous versions of Salt or making a deeper refactor for example), I prefer to open this issue to track these bugs rather than to open an incomplete Pull Request.

amendlik commented 2 years ago

Thank you for the bug report. I will try to look into the problems this week.

amendlik commented 1 year ago

I could not get this to run at all with the latest version of Salt because they removed the six library, which we were using (https://github.com/saltstack/salt/commit/d9b50659b2be467f31d59245e70202fbabc83092). So I guess that means no more support for Python 2 going forward! Once I removed all the Python 2 compatibility code, SaltGenResource is working fine for me with Salt 3005 (Phosphorus).

Could you try the version on this branch and let me know your results? https://github.com/amendlik/salt-gen-resource/tree/phosphorus

amendlik commented 1 year ago

@sticky-note, Any update on this?

sticky-note commented 1 year ago

Strange, with phosphorus version of the script, I get:

root@rundeck_host:~# python3 /var/lib/rundeck/libext/SaltGenResource.py -s "*" -a manufacturer,os_family,os,osmajorrelease,osrelease,virtual,saltversion,saltenv username="rundeck"
Traceback (most recent call last):
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 562, in <module>
    print(ResourceGenerator().as_yaml())
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 246, in __init__
    parser = SaltNodesCommandParser()
TypeError: __new__() missing 3 required positional arguments: 'name', 'bases', and 'attrs'
[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
TypeError: __new__() missing 3 required positional arguments: 'name', 'bases', and 'attrs'
Traceback (most recent call last):
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 562, in <module>
    print(ResourceGenerator().as_yaml())
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 246, in __init__
    parser = SaltNodesCommandParser()
TypeError: __new__() missing 3 required positional arguments: 'name', 'bases', and 'attrs'
sticky-note commented 1 year ago

@amendlik , are you able to reproduce ?

sticky-note commented 1 year ago

@amendlik ?

amendlik commented 1 year ago

I'm sorry. My other obligations have not permitted me time to work on this. I hope to get to it in the next few weeks.

valentin2105 commented 1 year ago

Same problem here with Salt 3005.1

amendlik commented 1 year ago

I was able to reproduce this and have made some changes for compatibility with Phosphorus. Please try the latest version on the phosphorus branch.

valentin2105 commented 1 year ago

Thanks @amendlik, it work perfectly for me.

sticky-note commented 1 year ago

@amendlik Works like a charm with us too.

Let's do a release and we will be done.

Thanks

sticky-note commented 1 year ago

@amendlik Wonderful, I close this issue