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

(PUP-4776) Make 'puppet agent arg' error instead of silently running the catalog #4043

Conversation

peculater
Copy link

Currently, 'puppet agent' only analyses options beginning with '--', such as '--test' and
'--disable'. Any other words after agent are ignored. That is different from the way that
commands like 'puppet resource' and 'puppet apply' work, mainly because those require
an argument, while 'puppet agent' does not. This has led to, for instance, one of our new
sysadmins typing 'puppet agent disable' instead of 'puppet agent --disable' and being
terribly surprised when about 5 minutes later the server died.

This patch raises an error if someone on the CLI tries to invoke 'puppet agent' with what
has to be an invalid argument.

@puppetcla
Copy link

CLA signed by all contributors.

@joshcooper
Copy link
Contributor

@peculater thank you for your contribution! The rdoc appveyor failures are unrelated and can be ignored. We'll take a look at this before next week's PR triage on June 30th.

@@ -359,6 +359,12 @@ def main(daemon)
daemon.start
end

def parse_args(args)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of having a parse_args method that doesn't really parse the arguments, but instead ensures they are empty.

I think this really could simply be a one liner at the start of setup:

raise ArgumentError, "The puppet agent command does not take parameters" unless command_line.args.empty?

@peterhuene
Copy link
Contributor

@kylog is this considered a breaking change? Before puppet agent foo (note: not --foo, as options are handled differently) would merrily go on its way, but now we'll error on startup. My only concern is people that run puppet agent from cron or something that (most likely unintentionally) pass previously ignored arguments will now error.

@kylog
Copy link

kylog commented Jul 1, 2015

IMHO this is not a breaking change in the semver sense, i.e. there isn't an established contract that we are changing here. This is just a good old-fashioned bug fix :)

@peterhuene
Copy link
Contributor

Hi @peculater. I just wanted to check-in to see if you saw my feedback above. Generally this looks good and we should be able to merge this with the recommended changes applied. Thanks!

@peterhuene
Copy link
Contributor

Hi @peculater. Thanks for pushing up the changes. One last thing and I'll get this merged this afternoon: could you either amend the second commit message to be prefixed with (PUP-4776) like the first commit or squash the second commit into the first one? I have a preference for squashing, but it either way works for us. Thanks again for your contribution!

…the catalog

Currently, 'puppet agent' only analyses options beginning with '--', such as '--test' and
'--disable'.  Any other words after agent are ignored.  That is different from the way that
commands like 'puppet resource' and 'puppet apply' work, mainly because those require
an argument, while 'puppet agent' does not.  This has led to, for instance, one of our new
sysadmins typing 'puppet agent disable' instead of 'puppet agent --disable' and being
terribly surprised when about 5 minutes later the server died.

This patch raises an error if someone on the CLI tries to invoke 'puppet agent' with what
has to be an invalid argument.
@peculater peculater force-pushed the puppet-agent-cli-should-error-instead-of-daemonize branch from b21e1e2 to e959744 Compare July 6, 2015 21:08
@peculater
Copy link
Author

OK, I think that squashed correctly. :-)

@peterhuene
Copy link
Contributor

👍 will merge after CI passes.

peterhuene added a commit that referenced this pull request Jul 6, 2015
…-instead-of-daemonize

(PUP-4776) Make 'puppet agent arg' error instead of silently running the catalog
@peterhuene peterhuene merged commit cb86c3c into puppetlabs:master Jul 6, 2015
@peterhuene
Copy link
Contributor

@peculater Thanks again for the contribution! This has been merged into the upcoming Puppet 4.3.0 release.

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

Successfully merging this pull request may close these issues.

None yet

5 participants