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

(#469) Assign correct environment to node groups #479

Merged

Conversation

bastelfreak
Copy link
Collaborator

This checks if a user configured a environment in pe.conf. If that's the case, it will be used for the PEADM-specific node groups. Otherwise we fall back to production.

This fixes a timing issue discovered in #469. In situations where the PE infra isn't running in production, we cannot assume that a production environment exists. And a node group can only reference classes from the environment the node group belongs to.

Summary

Provide a detailed description of all the changes present in this pull request.

Additional Context

Add any additional context about the problem here.

Related Issues (if any)

Mention any related issues or pull requests.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.

Changes include test coverage?

  • Yes
  • Not needed

Have you updated the documentation?

  • Yes, I've updated the appropriate docs
  • Not needed

@bastelfreak bastelfreak self-assigned this Aug 19, 2024
@bastelfreak bastelfreak requested review from a team as code owners August 19, 2024 20:08
@bastelfreak
Copy link
Collaborator Author

This is a proof of concept for my theory in #469 (comment) . This patch works for the described bug. The isn't complete yet and it doesn't have any new tests. Also there are other potential solutions to the problem. For example could we figure out the last used environment on a primary and use that. Or simply call fail() when the production environment is missing. Or we update the specification and say that production always needs to exist, but then the timing issue needs to be fixed (and that's probably the solution where most user with this bug won't be happy with, they are often not allowed to have a production branch due to different regulations).

@bastelfreak bastelfreak force-pushed the issue-469 branch 11 times, most recently from 10594df to 59d865a Compare August 21, 2024 18:51
if $pe_install =~ String[1] {
return $pe_install
} else {
return 'production'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could also return undef and then fallback to the default in the node_manager module: https://github.com/puppetlabs/puppetlabs-node_manager/blob/519bc30e0c68b11c86168868778afc37199fafc1/lib/puppet/type/node_group.rb#L124

return 'production'
}
} else {
fail("pe_install::install::classification::pe_node_group_environment and puppet_enterprise::master::recover_configuration::pe_environment need to be set to the same value, not '${pe_install}' and ${puppet_enterprise}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

please let me know if you prefer fail_plan() over fail() or something else.

Copy link

Choose a reason for hiding this comment

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

I'd say fail_plan() is better for bolt plans (though, good kind name required, which is usually hard)

@@ -94,7 +97,8 @@
server_b_host => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef },
internal_compiler_a_pool_address => $replica_avail_group_letter ? { 'A' => $replica_host, default => undef },
internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef },
peadm_config => $peadm_config
peadm_config => $peadm_config,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that puppet-lint doesn't detect the missing comma is a bug: https://github.com/puppetlabs/puppet-lint/issues/215

@bastelfreak bastelfreak force-pushed the issue-469 branch 6 times, most recently from 7ec995e to 954c50f Compare August 23, 2024 10:12
@bastelfreak bastelfreak changed the title (#469) Assign correct environment to node groups (469) Assign correct environment to node groups Aug 23, 2024
@bastelfreak bastelfreak changed the title (469) Assign correct environment to node groups (#469) Assign correct environment to node groups Aug 23, 2024
This checks if a user configured a environment in pe.conf. If that's the
case, it will be used for the PEADM-specific node groups. Otherwise we
fall back to production.

This fixes a timing issue discovered in puppetlabs#469. In situations where the PE
infra isn't running in production, we cannot assume that a production
environment exists. And a node group can only reference classes from the
environment the node group belongs to.
@bastelfreak
Copy link
Collaborator Author

I added unit tests and everything passes. Can you please review this?

@timidri
Copy link
Contributor

timidri commented Aug 26, 2024

I seem to vaguely remember that production is the mandatory node group for PE infrastructure nodes. Is that no longer the case? @bastelfreak @CoMfUcIoS @ragingra

@bastelfreak
Copy link
Collaborator Author

@timidri I didn't find anything related in the docs about it.

@AaronShannon AaronShannon changed the base branch from main to support-custom-environment August 29, 2024 15:53
@bastelfreak bastelfreak merged commit e6092ff into puppetlabs:support-custom-environment Aug 29, 2024
58 checks passed
@bastelfreak bastelfreak deleted the issue-469 branch August 29, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants