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

(#9440) exec resource: set path param to path fact #9445

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bastelfreak
Copy link
Contributor

No description provided.

@bastelfreak bastelfreak requested a review from a team as a code owner August 7, 2024 14:22
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@bastelfreak bastelfreak force-pushed the issue-9440 branch 3 times, most recently from 8a1f94c to fba26a5 Compare August 7, 2024 14:37
@@ -650,32 +650,6 @@ def with_another_agent_running(&block)
.and output(/No more routes to fileserver/).to_stderr
end

it 'preserves the old cached catalog if validation fails with the old one' do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should probably keep this it. It used the exec resource to create a broken catalog. but with this change it's not broken anymore. I removed it for now so the tests continue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add path => '' to preserve the intent of the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this now verifies that path => '' fails. But it doesn't verify anymore if the cached catalog isn't updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah interesting, this is because previously the agent attempted to convert the resource catalog to a RAL catalog

ral_catalog = convert_catalog(catalog, @duration, facts, options)

That caused the validate lifecycle method to be called on each type & parameter

provider.validatecmd(self[:command])

Previously we detected the command wasn't absolute and path was omitted, so we raised and the cache was never updated.

I think we want to update the validatecmd method https://github.com/puppetlabs/puppet/blob/26ab7e13daa4569cc62492ef882dce0b2796ef27/lib/puppet/provider/exec.rb#L105C1-L105C182

-    self.fail _("'%{exe}' is not qualified and no path was specified. Please qualify the command or specify a path.") % { exe: exe } if !absolute_path?(exe) and resource[:path].nil?
+    self.fail _("'%{exe}' is not qualified and no path was specified. Please qualify the command or specify a path.") % { exe: exe } if !absolute_path?(exe) && (resource[:path].nil? || resource[:path].empty?)

And then preserve the test as it was.

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 applied your suggestion and undid the test changes, but now it's failing again like it did initially. Maybe I misunderstood your 'preserve the test as it was'. Can you take another look please?

Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

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

Thanks @bastelfreak! I was initially concerned this might affect the PATH for the child process, but I'm fairly certain it only affects puppet's which functionality when resolving an unqualified command. So it should be ok. I just had some minor comments about the tests.

Also could you add a test for the situation where path => '<something>' is specified and overrides the default? Or maybe there is already a test for that?

@@ -223,7 +223,9 @@ def sync
newparam(:path) do
desc "The search path used for command execution.
Commands must be fully qualified if no path is specified. Paths
can be specified as an array or as a '#{File::PATH_SEPARATOR}' separated list."
can be specified as an array or as a '#{File::PATH_SEPARATOR}' separated list. Defaults to the `path` fact."
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR but we shouldn't use PATH_SEPARATOR because reference docs are generated on Linux, so the type reference will be wrong for Windows. I think we call out "use ';' on Windows, otherwise ':' everywhere else" in other doc strings.

@@ -650,32 +650,6 @@ def with_another_agent_running(&block)
.and output(/No more routes to fileserver/).to_stderr
end

it 'preserves the old cached catalog if validation fails with the old one' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add path => '' to preserve the intent of the test?

spec/unit/provider/exec/posix_spec.rb Show resolved Hide resolved
spec/unit/provider/exec_spec.rb Show resolved Hide resolved
@bastelfreak
Copy link
Contributor Author

@joshcooper can you take a look again please?

@bastelfreak bastelfreak force-pushed the issue-9440 branch 2 times, most recently from 56b511a to e2a70e8 Compare September 26, 2024 17:55
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