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

Use structured-facts for array values instead of joining them by , #120

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

coder-hugo
Copy link

This PR converts all custom facts that contain array values from string to structured-facts.
Btw. this PR will conflict with #118 as both are touching line 31 of lib/facts/gluster.rb. This PR just touches this line as the peer_list fact is already joined within the "calculation" code and not like for the others in the Facter.add section. If #118 will be merged first I'll rebase the PR and fix the merge conflict.

@@ -163,7 +163,7 @@
# this volume exists

# our fact lists bricks comma-separated, but we need an array
$vol_bricks = split( getvar( "::gluster_volume_${title}_bricks" ), ',')
$vol_bricks = getvar( "::gluster_volume_${title}_bricks" )
if $bricks != $vol_bricks {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coder-hugo Do you think the arrays can be sorted before they're compared (and operated on)?

This would fix #121 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it would be even better to sort the arrays already when generating the facts. I'll just try this now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a patch that sorts all array facts and also the $bricks array given to the gluster::volume.

@alexjfisher
Copy link
Member

Looks good to me, but I'm not in a position to actually test it. I'll have an ask around for volunteers. Have you been using this branch yourself?

@coder-hugo
Copy link
Author

At the moment we are using the fix-port-facts branch for our setup. This is a combination of this PR and #118. And it works pretty well.

end
end
volume_bricks.each do |vol, bricks|
Facter.add("gluster_volume_#{vol}_bricks".to_sym) do
setcode do
bricks
bricks.sort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having read a bit more, I'm not actually sure this is the correct thing to do. Brick order is important?
See #121 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. After a short look to the documentation I'd say the brick order is important for stripped and distributed volumes. So it looks like #121 isn't a bug in this module but in the puppet configuration of the author of #121.

@ekohl
Copy link
Member

ekohl commented Jan 2, 2018

Should this create a complex $facts['gluster'] fact hash not to change existing facts? It'd be a breaking change for users and I like the nesting when it makes sense.

@bastelfreak
Copy link
Member

I agree with @ekohl. @coder-hugo can you please take a look at the suggestions?

@vox-pupuli-tasks
Copy link

Dear @coder-hugo, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@vox-pupuli-tasks
Copy link

Dear @coder-hugo, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants