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

(CODEMGMT-1422) Delete spec dirs on module sync #1198

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

tvpartytonight
Copy link
Contributor

Please add all notable changes to the "Unreleased" section of the CHANGELOG in the format:

- (JIRA ticket) Summary of changes. [Issue or PR #](link to issue or PR)

@tvpartytonight tvpartytonight requested a review from a team August 9, 2021 16:48
@Magisus
Copy link
Collaborator

Magisus commented Aug 9, 2021

This doesn't do anything to make sure that what we're deleting from is actually a Puppet module, does it? Are we still concerned about that?

@tvpartytonight
Copy link
Contributor Author

I was actually working on that part of the ticket now with a test PE instance, but I wasn't quite clear on why that was listed as part of the requirements for the ticket; @mwaggett do you remember why? I looked through the paper trail, but I just found the requirement, not the reason for the requirement.

@Magisus
Copy link
Collaborator

Magisus commented Aug 9, 2021

The reason is that people sometimes add git repos of Heira data in their puppetfiles and install them like modules, but usually with a different install path. We don't want to delete any dirs in there that might be called spec.

# Delete the spec dir unless @deploy_spec has been set to true
def delete_spec_dir
unless @deploy_spec
spec_path = @path + 'spec'
Copy link
Member

Choose a reason for hiding this comment

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

We should probably do a File.join here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

File.join will return a string, while a <Pathname> + String operation will return a Pathname object. I could wrap the File.join in a new Pathname, but I don't think that is any better...I'm not sure I need a Pathname for the Dir.exist? and FileUtils.rm_rf calls though... 🤷

Copy link
Member

Choose a reason for hiding this comment

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

Touche.

I didn't realize that @path was a Pathname. In that case you might want to use the instance methods defined on Pathname for symlink?, realpath, directory?...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yeah, that sounds good to me. 👍

@tvpartytonight
Copy link
Contributor Author

@Magisus ok, I added the moduledir detection bits now, still no tests for that specific part yet...

spec/unit/module/git_spec.rb Outdated Show resolved Hide resolved
@@ -238,6 +238,7 @@ def allowed_initialize_opts
modules: :self,
cachedir: :self,
'no-force': :self,
'deploy-spec': :self,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a test associated with this action, like what you added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the tests for environment and module actions, respectively.

CHANGELOG.mkd Outdated Show resolved Hide resolved
@tvpartytonight
Copy link
Contributor Author

I've tested out the following scenarios:

  • r10k deploy environment with and without the deploy-spec flag, set via the CLI and in the Puppetfile
  • r10k deploy module with and without the deploy-spec flag, set via the CLI and in the Puppetfile
  • puppet code deploy with deploy_spec set in the Puppetfile
  • All of the above scenarios with install_path set in the Puppetfile

subject { described_class.new(title, dirname, {}) }

it 'gets deleted by default' do

Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra line here

@@ -66,6 +71,36 @@ def full_path
path.to_s
end

# Delete the spec dir unless @deploy_spec has been set to true or @spec_deletable is false
def delete_spec_dir
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should rename this to something like try_delete_spec_dir and then the other one can be just delete_spec_dir. Makes it more obvious what the difference is between them.

This change deletes the spec directory for deployed modules
to decrease disk usage. This behavior is the new default
behavior, though it can be overridden on the CLI or via a
puppetfile.
@Magisus Magisus merged commit bc366c1 into puppetlabs:main Aug 11, 2021
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.

3 participants