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

Implement knife bootstrap client.d RFC #4529

Merged
merged 13 commits into from
Feb 25, 2016
Merged

Conversation

jaym
Copy link
Contributor

@jaym jaym commented Feb 5, 2016

This implements the RFC described in chef-boneyard/chef-rfc#183

There are some minor differences:

  • client.d is natively interpreted by chef-client in this implementation. It does not rely on a block at the end of the client.rb that loads the files in client.d
  • client.d is not found in the bootstrap directory, instead just the repo path.
  • used client_d_dir instead of client_d_path to keep it consistent with trusted_certs_dir

cc @chef/client-core

@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from 849c82d to 4608f47 Compare February 5, 2016 03:06
@coderanger
Copy link
Contributor

How does this interact with chef-solo and local mode/knife? Do we want to make a solo.d and knife.d?

def client_d_content
content = ""
if @chef_config[:client_d_dir] && File.exist?(@chef_config[:client_d_dir])
root = Pathname(@chef_config[:client_d_dir])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a require "pathname" to this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, good catch

@jaym
Copy link
Contributor Author

jaym commented Feb 5, 2016

@coderanger good question. My intention was that this does not get loaded with knife as it shouldn't be reading client.rb, and I don't personally see it useful to have for knife.

As for solo, I'm open to suggestions. Would people who use solo find it useful? I think solo.d would probably make the most sense for a directory name.

@danielsdeleo
Copy link
Contributor

One use case for knife.d would be for folks in the same org to share most of their knife config in a git repo and gitignore the actual knife.rb where they'd set username and other stuff.

@jaym
Copy link
Contributor Author

jaym commented Feb 5, 2016

Interesting. That seems useful.
Perhaps we add that one.

What about solo?

@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from 1b7d6cd to 29db233 Compare February 5, 2016 17:24
@thommay
Copy link
Contributor

thommay commented Feb 8, 2016

Just spoke to Jay about this. We agree with Dan that this would be useful for knife users, and the directory for that should be .chef/config.d.

However, my feelings are that we should not do this work for solo.

@coderanger
Copy link
Contributor

The party line is that solo is fully supported, if we do it for client we should do it for solo.

@btm
Copy link
Contributor

btm commented Feb 8, 2016

@coderanger chef-solo being supported doesn't mean guaranteed feature parity. we don't require all features we add to the client mode to also work in chef-solo.

Further, RFC031 is accepted as the path to deprecate chef-solo by ensuring local-mode has feature parity and then having chef-solo commands be an alias for local-mode.

I don't see any reason to require new feature for chef-solo, only that by supporting it we're promising to not break it.

@coderanger
Copy link
Contributor

@btm Given how little work it would be (the impl is the same as for chef-client), I don't see any reason not to do it other than trying to convince people that they shouldn't use chef-solo and that is something we should never do.

@btm
Copy link
Contributor

btm commented Feb 8, 2016

@coderanger that's a different argument. If @jaym or whoever implements it looks and thinks the code paths are similar enough that it's easy to add .d support to chef-solo, that's fine, go wild. But it's not required.

@coderanger
Copy link
Contributor

@btm I'm saying it should be required as long as chef-solo is a supported tool/workflow. AFAIK it still is.

@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from 29db233 to 6e4e712 Compare February 8, 2016 22:51
@jaym
Copy link
Contributor Author

jaym commented Feb 8, 2016

Added conf.d for knife things

@btm
Copy link
Contributor

btm commented Feb 8, 2016

@coderanger then I'm disagreeing. There is no chef-solo based workflow in RFC019 and chef-solo is effectively deprecated except for it's existing UX by RFC031. There's no reason to add additional UX to chef-solo when all it is going to be is a backwards-compatible interface to local-mode, which does support .d configs.

@coderanger
Copy link
Contributor

RFC 19 is both not an exhaustive list and not fully implemented and RFC 31 hasn't been implemented at all. The whole point of RFC 31 is that this would be supported by way of solo being client internally, so why not support it from the start as literally any chef-solo user (and yes, they exist) would expect. How would you justify not adding new features to solo other than "we don't think you should be using it"?

@coderanger
Copy link
Contributor

Or alternatively "we don't want to support it", which is fine but it has to be supported until RFC 31 is fully implemented, that was the whole point of RFC 31.

@thommay
Copy link
Contributor

thommay commented Feb 9, 2016

I'm pretty sure we've never said nor intended that support implies complete feature parity.

@coderanger
Copy link
Contributor

@thommay What does it mean then? Remember that solo is explicitly not deprecated. Keeping a high-quality user experience should mean that non-server-related features should go in both unless there is a compelling reason not to and no one has mentioned a reason other than "we don't want people using chef-solo anymore" which is not a reason I accept.

@btm
Copy link
Contributor

btm commented Feb 9, 2016

I hate the word support. Support means we don't break something. Everything beyond that is trouble. I can't formulate how support relates to new features. We certainly haven't required resource parity across all supported platforms before adding a new resource for one or more platforms. We've added a few features to the client that didn't make it into solo until someone added some kind of compatibility later, e.g. support in solo or via an external cookbook.

There's an issue here with our differing development priorities. Let's talk on chef-dev.

@luckymike
Copy link

@btm @thommay Solo was actually just broken (existing functionality completely changed) in 12.7 to ensure that its flags had parity with client.

Chef Solo -r (–recipe-url) changes
https://www.chef.io/blog/2016/02/12/chef-client-12-7-released/

If breaking existing (if rarely or accidentally used) functionality was in order, why not supporting the conf directory?

Is the goal for solo to be a debasing experience that encourages switching to client?

@danielsdeleo
Copy link
Contributor

@luckymike

Instead invokes the --recipe-url code, which had the side effect of running an immediate unprompted rm -rf * in the current working directory of the user. Due to this problem and other issues around this rm -rf * behavior it has been removed from the --recipe-url code in chef-solo. The use of -r in chef-solo to mean --recipe-url has also been deprecated.

So basically we screwed up, and merged an "improvement" that was actually a net negative for Chef Solo users, including ourselves, who were rm -rf *-ing their home directories. I guess in some pedantic sense this change violates SemVer, and it happens to only impact solo users, but tbqf I would rather delete all copies of SemVer from the internet than delete your home directory on accident.

Is the goal for solo to be a debasing experience that encourages switching to client?

Is accidentally deleting a bunch of your files "a debasing experience"? If so, wouldn't making it less likely that you do this on accident be the opposite of that?

In any case, this discussion is about adding a feature.

@btm
Copy link
Contributor

btm commented Feb 12, 2016

@luckymike the issue that @danielsdeleo explained aside, the debate is about policy, i.e. by policy do we require feature parity to merge a new feature. It's less about adding the feature this PR represents for solo (I think there's more work/shed-building to figure out the right medium-term UX decisions given RFC031 than there is writing the code for solo.d support).

@luckymike
Copy link

I wasn't arguing for deleting home directories, I was trying to offer a clear example of rightfully favoring parity over policy (sem ver). Turning @coderanger's argument for including support in solo into a larger policy debate effectively decides this issue without anyone taking responsibility for it.

@btm
Copy link
Contributor

btm commented Feb 12, 2016

@luckymike by "this issue" you mean #4529, not something related to the -r stuff, right?

This feature is part of the plan I envisioned in the ohai-config RFC discussion for getting ohai UX happy and @coderanger happy about ohai UX being happy. So I'm responsible for it [and @coderanger's happiness!]. But we're in the middle of another hairy chef-client release so it's not my top priority at the moment.

@luckymike
Copy link

Yes, the issue #4529, the issue we're commenting on :)

@lamont-granquist
Copy link
Contributor

We can argue about the semantics of the word "deprecated" but I think the reality is that chef-solo is "deprecated". Time spent on chef-solo-specific codepaths is wasted time since chef-zero eventually will be replacing chef-solo via RFC 031. That also completely forces our hand when it comes to conflicting features that have been caused by chef-solo and chef-client/chef-zero having different codepaths. RFC 31 means that at some point in the future the conflicting meanings of the '-r' flag need to be resolved. Generally chef-solo is the smaller userbase and is going to lose that argument. In the case in question its just laughable since making the solo behavior the new meaning of '-r' would mean that everyone using '-r' on the client to mean '--run-list' and doing elastic scaling would have their argument changed to '--recipe-url' and get a complimentary rm -rf run in the direction they're executing chef-client in. We have to deprecate the meaning of '-r' for chef-solo users and I don't think there can be any meaningful debate about that.

So there isn't parity here. And in fact I think that "solo.d" may buy us a worse compatibility issue since how is that supposed to work when we change chef-solo to invoke chef-client local-mode? Not only is that doing work to create "solo.d" in codepaths that we'll throw away, but we need to have zero pick up solo.d for backcompat when RFC 31 is executed, which is just going to be digging ourselves a deeper hole to climb out of, it doesn't move us any closer towards executing RFC 031.

And removal of the rm_rf is entirely because when I was debugging #4368 recently, which is a chef-solo specific issue, I took my usual chef-zero command line argument:

chef-client -z -r 'recipe[test]'

And blindly converted that into a chef-solo command line:

chef-solo -r 'recipe[test]'

Which immediately wiped out all the cookbooks in my current working directory.

Which made me more or less like this:

Rage Quit

I was actually the one that merged the rm_rf line initially:

#2418

We've also had chef-solo user requests to remove that line:

#3802

And not only that but I went and added the "--delete-entire-chef-repo" line and added the rm_rf TO chef-client from chef-solo which didn't exist there before. I just did it in a much safer way where users of "--recipe-url" who do NOT want that behavior do not get it forced down their throat and where a simple command line option like "-r" is not brutally destructive.

And I don't see how having to change a command line from:

chef-solo -r http:///whatever.com/recipies.tgz

To:

chef-solo --recipe-url http:///whatever.com/recipies.tgz --delete-entire-chef-repo

And getting exactly_the_same_behavior_as_you_had_before is "breaking functionality" or a "debasing experience"

@btm
Copy link
Contributor

btm commented Feb 12, 2016

someone please file an issue about chef-solo -r if they want to keep talking about it beyond this point.

@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from 13f8b8b to b5e6119 Compare February 17, 2016 05:24
This configuration defaults to config_dir/client.d,
but can be set to nil if you do not want chef-client
loading any extra config files.
When knife finds a client.d/ directory, it will upload
all files nested under that directory.
client.d/*.rb will be read in sorted order. All directories will be
ignored.
This will behave similarly to the client.d directory.
The top-level ruby files will be loaded in sorted order.
Also, do less mocking so the test will catch the error
Passing the value of `escape_glob` to Dir.glob does
not always work correctly on Windows. Always use
forward slashes when globbing, even on Windows. We
now do this via `escape_glob_dir`, which calls
Pathname.cleanpath, which does the foward slash thing.
@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from b5e6119 to 32e7c41 Compare February 25, 2016 05:24
@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from 32e7c41 to 4cc7325 Compare February 25, 2016 05:27
@jaym
Copy link
Contributor Author

jaym commented Feb 25, 2016

@chef/client-maintainers I added solo.d, could probably use another round of reviews

This commit refactors the spec to use shared examples
as the test for client.d and solo.d is the same.

knife.d is a little special so it cannot use this.
@jaym jaym force-pushed the jdm/knife-bootstrap-clientd branch from 4cc7325 to 158178c Compare February 25, 2016 06:18

# A directory that contains additional configuration scripts to load for
# the workstation config
default(:conf_d_dir) { PathHelper.join(config_dir, "conf.d") }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is supposed to be config.d because the workstation config is config.rb.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't workstation config usually knife.rb?

Copy link
Contributor

Choose a reason for hiding this comment

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

knife.rb is very softly deprecated. There's no real upside to forcing people to switch, but we decided to use config.rb going forward because it's used by many tools other than knife.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

config.rb is supposed to be used in preference to knife.rb according to the docs

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL.

@btm
Copy link
Contributor

btm commented Feb 25, 2016

👍 with the s/conf_d/config_d/ change.

@smurawski
Copy link
Contributor

confirming my 👍 after the latest updates

btm added a commit that referenced this pull request Feb 25, 2016
Implement knife bootstrap client.d RFC
@btm btm merged commit dbedc9c into master Feb 25, 2016
@btm btm deleted the jdm/knife-bootstrap-clientd branch February 25, 2016 19:57
@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 25, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.