-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add pacemaker_resource plugin #9531
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
3ced6e7
to
1c0286e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @munchtoast thanks for your contribution!
I have many comments on this PR, hope not to crush your motivation. We have all made these mistakes in the past, it is just a matter of learning. :-)
Also, please note that all new modules must have tests created with them (unit tests or integration tests).
In your case, since this is a module based on run_command()
, you can easily write unit tests using the test helper I wrote. Take a look at the directory
https://github.com/ansible-collections/community.general/tree/main/tests/unit/plugins/modules take a look at the tests modules that have an accompanying YAML file. I am yet to write proper documentation for that helper, but its use should be quite straightforward. If you decide to follow this path, I will be happy to assist you with those tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @munchtoast , still a draft, I know, but leaving a couple of comments nonetheless.
Hi @russoz, thank you so much for your reviews! I am currently writing unit tests but running into issues. I'll push what I have but I'm sorry for slow delay in applying feedback. Just wanted to give you an update that my wip commits should come in by end of this weekend. |
No worries, take your time and feel free to ask for help. We have all been there once 😉 |
Noticing that there may be an issue with the current implementation, where the Also I noticed in other |
This comment was marked as resolved.
This comment was marked as resolved.
Without seeing the specific error it's going to be hard to guess what the problem is. Could you please push the code generating that error so I can see the output here? Or if one of these runs above had that, please point it to me. Couple of housekeeping comments:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, some comments on the code - there are some improvements that could be made.
@munchtoast this PR contains the following merge commits: Please rebase your branch to remove these commits. |
I don't think this is an error, but seems to be misunderstanding on my part as I am still learning. Other test
Should be up to date now! |
Refactorization on pacemaker_resource to utilize module helpers.
The test
The test
The test
The test
The test
|
if fail_on_err and rc != 0 and err and ignore_err_msg not in err: | ||
self.do_raise( | ||
'pcs failed with error (rc={0}): {1}'.format(rc, err)) | ||
out = out.rstrip() | ||
self.vars.value = None if out == "" else out | ||
return self.vars.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation should be 4, not 2:
if fail_on_err and rc != 0 and err and ignore_err_msg not in err: | |
self.do_raise( | |
'pcs failed with error (rc={0}): {1}'.format(rc, err)) | |
out = out.rstrip() | |
self.vars.value = None if out == "" else out | |
return self.vars.value | |
if fail_on_err and rc != 0 and err and ignore_err_msg not in err: | |
self.do_raise('pcs failed with error (rc={0}): {1}'.format(rc, err)) | |
out = out.rstrip() | |
self.vars.value = None if out == "" else out | |
return self.vars.value |
argument_action=dict(type='str', choices=[ | ||
'clone', 'master', 'group', 'promotable']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to break the line here
argument_action=dict(type='str', choices=[ | |
'clone', 'master', 'group', 'promotable']), | |
argument_action=dict(type='str', choices=['clone', 'master', 'group', 'promotable']), |
ctx.run( | ||
state=self.vars.state, | ||
name=self.vars.name, | ||
resource_type=self.vars.resource_type, | ||
resource_option=self.vars.resource_option, | ||
resource_operation=self.vars.resource_operation, | ||
resource_meta=self.vars.resource_meta, | ||
resource_argument=self.vars.resource_argument, | ||
disabled=self.vars.disabled, | ||
wait=self.vars.wait) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and since they all seem to be module params, you can also do:
ctx.run( | |
state=self.vars.state, | |
name=self.vars.name, | |
resource_type=self.vars.resource_type, | |
resource_option=self.vars.resource_option, | |
resource_operation=self.vars.resource_operation, | |
resource_meta=self.vars.resource_meta, | |
resource_argument=self.vars.resource_argument, | |
disabled=self.vars.disabled, | |
wait=self.vars.wait) | |
ctx.run() |
- This module can manage resources to a pacemaker cluster from Ansible using | ||
the pacemaker cli. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More of a style recommendation, although capitalization is usually required.
- This module can manage resources to a pacemaker cluster from Ansible using | |
the pacemaker cli. | |
- This module can manage resources in a Pacemaker cluster using the pacemaker CLI. |
self.do_raise( | ||
'pcs failed with error (rc={0}): {1}'.format(rc, err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to break:
self.do_raise( | |
'pcs failed with error (rc={0}): {1}'.format(rc, err)) | |
self.do_raise('pcs failed with error (rc={0}): {1}'.format(rc, err)) |
I was referring to the assertion errors you mentioned. It is looking so much better now - we still have a couple of sanity check errors to clear, then after that work our way through these tests. ;-) |
SUMMARY
Adds in pacemaker_resource plugin for managing pacemaker cluster resources.
ISSUE TYPE
COMPONENT NAME
pacemaker_resource
ADDITIONAL INFORMATION