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

kb0149 task added #3

Merged
merged 4 commits into from
Jun 29, 2018
Merged

kb0149 task added #3

merged 4 commits into from
Jun 29, 2018

Conversation

@MartyEwings MartyEwings added the enhancement New feature or request label Jun 28, 2018
Copy link
Contributor

@jarretlavallee jarretlavallee left a comment

Choose a reason for hiding this comment

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

Since travis isn't configured yet, below is the rake output.

$ bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop shellcheck
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
Running RuboCop...
Inspecting 1 file
.

1 file inspected, no offenses detected
shellcheck tasks/kb0149.sh

In tasks/kb0149.sh line 9:
        if $(/usr/bin/which grep) -q "ss2m" /etc/sysconfig/pe-puppetserver
             ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In tasks/kb0149.sh line 11:
        else  $(/usr/bin/which sed) -i 's/\(JAVA_ARGS="\)/JAVA_ARGS="-Xss2m /g' /etc/sysconfig/pe-puppetserver
                ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In tasks/kb0149.sh line 20:
        if $(/usr/bin/which grep) -q "ss2m" /etc/default/pe-puppetserver
             ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In tasks/kb0149.sh line 22:
        else  $(/usr/bin/which sed) -i 's/\(JAVA_ARGS="\)/JAVA_ARGS="-Xss2m /g' /etc/default/pe-puppetserver
                ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.

@abottchen
Copy link
Collaborator

One thing that could make this better would be to make the new stack size configurable. I'm thinking along the lines of specifying a target Xss size as a parameter to the task. If the parameter isn't there, just default to doubling what is currently there. Although this specific task may not be used all that often, the same code could then be re-used for other settings we will write tasks for down the line.

@MartyEwings
Copy link
Collaborator Author

yeah adam, i have some bash and sed that does that for jvm heap here from my early demonstration:

https://github.com/MartyEwings/kb9999/blob/master/tasks/kb9999.sh

we can pick that up for a "REAL" task

tasks/kb0149.sh Outdated

if $(/usr/bin/which grep) -q "ss2m" /etc/sysconfig/pe-puppetserver
then echo "Argument Already Present"
else $(/usr/bin/which sed) -i 's/\(JAVA_ARGS="\)/JAVA_ARGS="-Xss2m /g' /etc/sysconfig/pe-puppetserver
Copy link
Collaborator

Choose a reason for hiding this comment

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

One concern I have is if this task is run when Xss is already set, but to something the customer has already tuned. If they have anything other than Xss2m, this code is going to overwrite it with Xss2m (in fact, it will stack the additional Xss setting so they end up with two of them). That means if they have tuned it up to Xss4m, this code will actually de-tune it. I don't know how common that would be, but I would be inclined to make these tasks as safe as possible to prevent any potential problems for customers that might run them at unexpected times.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i could turn the match to xss and not the 2m part

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be good for the task as it is now. Of course, if we are updating it to have the stack be configurable, it would be fine for Xss to already be there, the task would just be updating it to the new value. The text returned could then be "increased stack from X to Y" or "decreased stack from X to Y".

@jarretlavallee
Copy link
Contributor

@abottchen Shouldn't we be specifying this setting in puppet_enterprise::profile::master::java_args instead of modifying it in the sysconfig file? It seems fragile to specify it manually in the sysconfig file, unless it would be used as a temporary workaround to getting the service online. The customer should be able to do something like the following.

 {"Xmx": "4096m", "Xms": "4096m", "Xss2m": ""}

Or in hiera:

puppet_enterprise::profile::master::java_args:
  Xmx: '4096m'
  Xms: '4096m'
  'Xss2m': ''

tasks/kb0149.sh Outdated

if $(/usr/bin/which grep) -q "ss2m" /etc/sysconfig/pe-puppetserver
then echo "Argument Already Present"
else $(/usr/bin/which sed) -i 's/\(JAVA_ARGS="\)/JAVA_ARGS="-Xss2m /g' /etc/sysconfig/pe-puppetserver
Copy link
Contributor

Choose a reason for hiding this comment

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

This will replace commented out lines in the file as customers will sometimes use those as a backup to specific settings. The regex would match any JAVA_ARGS. Can you modify the regex to match lines without # in them? Something like 's/^\s*\(JAVA_ARGS="\)/JAVA_ARGS="-Xss2m /g' would skip any commented lines.

@abottchen
Copy link
Collaborator

abottchen commented Jun 28, 2018

@jarretlavallee Yea, putting it in the console or Hiera would be a superior solution. Safely automating that becomes more of a challenge, however. We could pull the classifier data, update the field if present, and then import it back, but that could introduce race conditions if another user is messing with things in the console. Of course, updating Hiera is not possible since that would be in the customer's control repo, and thus out of our reach as a task.

Updating the file directly will work, even if it is less elegant. Setting puppet_enterprise::profile::master::java_args will only overwrite the manual stack size setting if Xss was explicitly added to the hash, so it wouldn't be just a temporary solution.

@MartyEwings
Copy link
Collaborator Author

@jarretlavallee @abottchen Iv updated the match pattern and changed the regex to skip commented lines However regarding the RAKE recommendations, command -v does not always return the binary path, in some cases, particularly with grep, it returns any alias set, so wouldnt work for this use case.

Considering the KB is targetted at RHEL and Ubuntu it should be ok to use Which.

@abottchen
Copy link
Collaborator

We will ultimately want to document in the KB that the task specifically sets the stack size to 2m, so if you already have it larger than that or need it larger than that, don't use it.

@MartyEwings
Copy link
Collaborator Author

@abottchen yep that will be part of the addition at the bottom, the manual steps set explicitly to 2m in terms of matching the Task to the original article, i think we are good, ill never get enough content together to launch if we start with every piece of functionality :)

Prior to this commit shellcheck would fail with warnings about using
`which`. This commit disables SC2230 for the kb0149 script.
@jarretlavallee
Copy link
Contributor

I just pushed a commit to ignore the shellcheck lint check with a file directive. If we see this same check trigger in many different scripts we will update the travis.yml to ignore a set of checks since there is no rc file. Sorry for being so onto the lint checking and testing. I figure it is a basis for ensuring consistency and quality, so we might as well as start with it. Let's modify it to fit the needs we have as this repo evolves.

@abottchen That makes sense, thanks for clarifying. 👍

@MartyEwings I'll merge this, but I just want your review on the commit I pushed first. When you open the change to the KB with the task, would you mind adding the steps to make the change permanent with the pe module in conjunction to running the task?

@MartyEwings
Copy link
Collaborator Author

Will do! This is an unmanaged setting by default I've found puppet does not remove it unless you regen the whole file, but aye for completeness I'll totally stick it in.

And thanks for the checking this stuff, I'm totally making this up as I go along,

@MartyEwings MartyEwings merged commit 8cc0a97 into puppetlabs:master Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants