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

Cr group kind fixes #879

Conversation

timothysmith0609
Copy link
Contributor

@timothysmith0609 timothysmith0609 commented Mar 9, 2022

What are you trying to accomplish with this PR?
Fixes the problem whereby custom resources can not discriminate between the same kind in different groups. This actually involved changes to #predeploy_sequence and CustomResource(Definition)

Note this doesn't solve the wider problem of multiple kinds among different standard API groups: that will require more changes than what's here

@timothysmith0609 timothysmith0609 requested a review from a team as a code owner March 9, 2022 18:14
@timothysmith0609 timothysmith0609 requested review from JamesOwenHall and camteasdale143 and removed request for a team March 9, 2022 18:14
Copy link
Contributor Author

@timothysmith0609 timothysmith0609 left a comment

Choose a reason for hiding this comment

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

The test fixes are just to deal with the fact that Custom Resources are now represented by $kind.$group, not just kind.

@@ -74,7 +74,7 @@ def predeploy_sequence
Pod
).map { |r| [r, default_group] }

crs = cluster_resource_discoverer.crds.select(&:predeployed?).map { |cr| [cr.kind, { group: cr.group }] }
crs = cluster_resource_discoverer.crds.select(&:predeployed?).map { |cr| [cr.group_kind, { group: cr.group }] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the redundancy of duplicating group information makes this fix much easier to implement, and is really just an internal consideration, anyway, so it felt like it was worth it.

@@ -241,7 +241,7 @@ def discover_resources
crds_by_group_kind = cluster_resource_discoverer.crds.group_by(&:group_kind)
@template_sets.with_resource_definitions(current_sha: @current_sha, bindings: @bindings) do |r_def|
group, kind = group_kind_for_r_def(r_def)
crd = crds_by_group_kind[group + "/" + kind]&.first
crd = crds_by_group_kind["#{kind}.#{group}"]&.first
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 adopted the convention of displaying group-kind information as $KIND.$GROUP, which mirrors how tools like kubectl, etc. work. e.g. deployments.apps

@@ -96,6 +96,7 @@ def test_cr_instance_fails_validation_when_rollout_conditions_for_crd_invalid
logger: @logger, statsd_tags: @statsd_tags, crd: crd,
definition: {
"kind" => "UnitTest",
"apiVersion" => "stable.example.io/v1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

apiVersion is required of any k8s resource, so it makes more sense to add it here than try to code around its absence

@timothysmith0609 timothysmith0609 merged commit 2c7fafd into grouping_cluster_resources_by_group_and_kind Mar 10, 2022
@timothysmith0609 timothysmith0609 deleted the cr_group_kind_fixes branch March 10, 2022 15:50
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.

2 participants