-
Notifications
You must be signed in to change notification settings - Fork 193
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 stdlib 9 compatibility #657
Conversation
manifests/params.pp
Outdated
# Instead check for the `is_pe` fact or if a PE provided function is available | ||
$_is_pe = (getvar('::is_pe') or is_function_available('pe_compiling_server_version')) | ||
if $_is_pe { | ||
if $facts['is_pe'] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah derp, the fact is only available on PE primaries/compilers.
7d73255
to
e969c7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some in-line comments. I will push some local changes to your branch to see if it helps.
manifests/params.pp
Outdated
$_is_pe = (getvar('::is_pe') or is_function_available('pe_compiling_server_version')) | ||
# To determine if this is a PE installation or not, we check if the `pe_anchor` resource type exists | ||
# it's provided by the puppet_enterprise module | ||
$_is_pe = defined('pe_anchor') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the test suite rely on the is_pe
variable and removing it from the condition break the test suite. This PR being about updating dependencies, I think we can ignore this compatibility thing for now (assuming we trust the comments), and only focus on supporting recent stdlib?
puppetlabs/puppetlabs-stdlib#1386 might be useful to keep the current behavior (see bellow).
@@ -237,7 +237,7 @@ def global_facts(facts, os) | |||
before(:each) do | |||
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' } | |||
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' } | |||
Puppet::Parser::Functions.newfunction(:pe_compiling_server_version, type: :rvalue) { |_args| '2.20.200' } | |||
Puppet::Parser::Functions.newfunction(:defined, type: :rvalue) { |_args| true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mocking defined
to return true might break things. According to the tests I did with the module it seems to be fine, but it feel fragile 😨.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why this is getting mocked here; @bastelfreak can you shed some light?
manifests/params.pp
Outdated
@@ -44,7 +44,7 @@ | |||
# and greping for "puppet enterprise". With Puppet 4 and PE 2015.2, there | |||
# is no longer a "PE Puppet", and so that fact will no longer work. | |||
# Instead check for the `is_pe` fact or if a PE provided function is available | |||
$_is_pe = (getvar('::is_pe') or is_function_available('pe_compiling_server_version')) | |||
$_is_pe = (getvar('::is_pe') or stdlib::has_function('pe_compiling_server_version')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this, but we need to keep in mind that it now requires stdlib 9.3. with my defined()
it works on all stdlib versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am not happy with this neither… 😭
I am currently fighting with bolt to use apply
with modules that support stdlib ">= 9" but Bolt's apply
rely on this module which currently only support stdlib "< 9".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I rolled out my code with defined()
at a few customers and that works fine as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fragile but avoids the need for bumping the minimum version of stdlib. I have no PE anywhere around, so I am not really concerned about this fragility, if it is okay, then it is fine! I'll rework the commits I added to take this into account. If it fix CI and you can test this in the field to validate the change, I think we will be good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rework the commits I added to take this into account. If it fix CI and you can test this in the field to validate the change, I think we will be good to go.
Code pushed. CI failures are related to my commit messages on the commits that need merging, so if you can confirm it fix your issue on PE, you can merge the commits (fixup/squash) and I think CI will be all green 😁
18b09d1
to
669bfc0
Compare
I have squashed my changes in your commits, and CI seems happy with it. @bastelfreak had you the opportunity to check that the behavior was not broken by my change in the real world with PE? Is this PR ready for review 😁 😉 😉? |
@smortex yes it's working fine :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me: the minor "issues" are not blockers and given the bad situation of the module (prevent usage of latest stdlib), this is a move in the right direction. As it is now, it is still compatible with previous versions of stdlib so AFAIAC this is 💯!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @bastelfreak! We're heads down working on upcoming releases and can take a look at this next week. In the meantime could you update the summary to describe why this change is needed? I think I understand, but I admit I haven't been paying complete attention to the strict & stdlib deprecated functions issues.
stdlib 9 dropped the is_function_available() function. I reworked the code to check if `pe_anchor` is defined. The code now works with Puppet core functions and is compatible with Puppet 7/8, probably 6, and does not rely on stdlib.
@joshcooper I updated the git commit with the description and added it to the PR title as well. I want to point out that puppetlabs/stdlib 9 was released almost 2 months ago. PE customers were not able to upgrade because this module isn't compatible. The CAT team worked hard to upgrade all of their modules. I still don't understand why the puppetdb and puppet_agent module are not owned by them / the CAT team isn't listed as code owners. From my point of view (also also from the PE customers I represent) this doesn't make sense. I pointed it out multiple times in the past years and never got a proper explanation for this. Also this wasn't changed. There was zero activity from the current owners about making puppet_agent compatible with stdlib 9. It took quite a long time to get a response here. I fail to understand why some modules are not maintained at all / maintained by other teams instead of the module with the main focus on maintaining modules. I would love to see a migration to the CAT team to ship enhancements faster to customers and to have a single source of configuration/guidelines/team for modules. |
Hi @bastelfreak, I understand your frustration, the current approach is not working for anyone. I've been advocating for moving these and |
@tvpartytonight thanks for merging <3 |
stdlib 9 dropped the
is_function_available()
function. I reworked the code to check ifpe_anchor
is defined. The code now works with Puppet core functions and is compatible with Puppet 7/8, probably 6, and does not rely on stdlib.