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

Add methods to get and set the glusterfs op-version #45091

Conversation

Projects
None yet
2 participants
@robertpenberthy
Copy link
Contributor

commented Dec 20, 2017

What does this PR do?

Adds methods to the existing glusterfs execution and state modules to querying and setting the glusterfs op-version.

What issues does this PR fix or reference?

None

Tests written?

No

Commits signed with GPG?

Yes

@robertpenberthy

This comment has been minimized.

Copy link
Contributor Author

commented Dec 20, 2017

This is my first PR to this project and Github, so please let me know if there is anything I missed / could do better.

I made these changes locally on my salt master to assist with upgrading Glusterfs versions in our environment. Post upgrade, glusterfs documentation recommends updating the op-version, http://docs.gluster.org/en/latest/Upgrade-Guide/op_version/. Now I'm just trying to share my additions with the community.

@robertpenberthy

This comment has been minimized.

Copy link
Contributor Author

commented Dec 20, 2017

Also, according to the coding-style section, I need to bring up that I am not sure what should be added to the function documentation for versionadded.

robertpenberthy added some commits Dec 20, 2017

@rallytime
Copy link
Contributor

left a comment

Welcome @robertpenberthy! Thank you for submitting your addition. This is a really great start.

I have a couple of comments. Most are documentation updates, but there are a couple of things in the state functions that need to be fixed in the code.

Can you also write some tests for these new functions?

Please let us know if you have any questions!


def get_op_version(name):
'''
Returns the glusterfs volume op-version

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

Can you add a .. versionadded:: Fluorine tag here for this new function?

This comment applies to the other functions you've added here as well. :)

'''

version = ''
cmd = 'gluster volume get {0} cluster.op-version'.format(name)

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

Can you change this to a list of command options, rather than a string? It's safer that way since name could pass in anything.

This comment has been minimized.

Copy link
@robertpenberthy

robertpenberthy Dec 21, 2017

Author Contributor

To make sure I understand what you're asking, is this what I should change it to?

cmd = ['gluster', 'volume', 'get', name, 'cluster.op-version']

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

Yes, that's it exactly!

salt '*' glusterfs.set_op_version <volume>
'''

cmd = 'gluster volume set all cluster.op-version {0}'.format(version)

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

Same comment here about lists vs. a string.

def op_version(name, version):
'''
Add brick(s) to an existing volume

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

versionadded tags are needed for these 2 new state functions as well.

'''
Returns the glusterfs volume's max op-version value
Requires Glusterfs version > 3.9
'''

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

This function needs a CLI Example.

ret['result'] = True
return ret

result = __salt__['glusterfs.set_op_version'](version)

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

This state function needs to support test=true behavior before actually changing anything. Can you add that, please?

ret['result'] = True
return ret

result = __salt__['glusterfs.set_op_version'](max_version)

This comment has been minimized.

Copy link
@rallytime

rallytime Dec 21, 2017

Contributor

This state function also needs to support test=true functionality.

robertpenberthy added some commits Dec 22, 2017

Code Review Changes
Changing cmd to list.
Adding test=True handling for the states.
Added try / except around calls to the execution module.
@rallytime

This comment has been minimized.

Copy link
Contributor

commented Dec 27, 2017

Thanks @robertpenberthy! This looks great. Now all we need is some unit tests and we'll be good to go. There's some docs on that here. Let us know if you have any questions. :)

@robertpenberthy

This comment has been minimized.

Copy link
Contributor Author

commented Dec 27, 2017

@rallytime Yep, I'm aware that I need to add those unit tests. It may take me a while to get those done, due to some of my other priorities, as well as I am new to Python (doing this custom module is pretty much the only Python I have ever written) and have never written Unit tests before. I hope to get through the documentation soon and then the tests written. I've looked at the existing tests for these modules and hopefully can easily pattern after them.

@rallytime

This comment has been minimized.

Copy link
Contributor

commented Dec 27, 2017

@robertpenberthy Wonderful! Thank you so much. Definitely let us know if you have troubles.

@robertpenberthy

This comment has been minimized.

Copy link
Contributor Author

commented Dec 29, 2017

@rallytime So I've been looking at how the tests are written for the existing functions in the module execution module and realize that these methods are all executing their commands through the _gluster_xml private method. I've also learned a bit more about how the existing functions work.

The existing functions use the string.format(variable) syntax, which you told me to change to a list for my functions. When passing the list to the _gluster_xml function, it returns with an error. It does work if I use the string.format(variable) syntax.

So now I am wondering, should I switch my command back to string.format(variable) and make my functions execute the commands in the same way as the existing code? Should I go through and change the existing functions to use and accept the list format? Or break from the existing pattern in this specific module and its unit tests, executing my code how I wrote it initially and write my tests to fit how I executed the commands?

robertpenberthy added some commits Dec 29, 2017

Adding Unit Tests for the Execution Module
- Changed the functions to execute the commands in the same manner as the pre-existing functions.
- Added unit tests
@robertpenberthy

This comment has been minimized.

Copy link
Contributor Author

commented Dec 29, 2017

@rallytime I assumed I should change it up to be like the pre-existing fucntions and did so, then wrote some unit tests. Just wrote them for the execution module functions so far. Please let me know if I got anything wrong with them.

robertpenberthy added some commits Jan 3, 2018

Merge remote-tracking branch 'origin/glusterfs-op-version-upstream/de…
…velop' into glusterfs-op-version-upstream/develop
@robertpenberthy

This comment has been minimized.

Copy link
Contributor Author

commented Jan 17, 2018

@rallytime I've added tests. I believe I've completed all requests in the code review.

@rallytime

This comment has been minimized.

Copy link
Contributor

commented Jan 18, 2018

@rallytime rallytime merged commit 2908a35 into saltstack:develop Jan 18, 2018

4 of 10 checks passed

jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #18920 — ABORTED
Details
codeclimate 13 issues to fix
Details
default Build finished.
Details
jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #1393 — FAILURE
Details
jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #5913 — FAILURE
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #15395 — FAILURE
Details
WIP ready for review
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #21366 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #13767 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #18373 — SUCCESS
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.