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

feat: support populating KongUpstreamPolicy status for ServiceFacade #5428

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

czeslavo
Copy link
Contributor

@czeslavo czeslavo commented Jan 11, 2024

What this PR does / why we need it:

As KongUpstreamPolicy can be attached to KongServiceFacade as well as to a Service, we should support populating status for it. This PR adds support for Accepted condition.

Programmed condition for KongServiceFacade will be added along with Service in #5249.

Which issue this PR fixes:

Adding KongServiceFacade parity before #5249.

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@czeslavo czeslavo self-assigned this Jan 11, 2024
@czeslavo czeslavo changed the title feat: support ServiceFacade as KongUpstreamPolicy ancestor [WIP] feat: support ServiceFacade as KongUpstreamPolicy ancestor Jan 11, 2024
@czeslavo czeslavo added area/feature New feature or request do not merge let the author merge this, don't merge for them. and removed size/L labels Jan 11, 2024
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 46 lines in your changes are missing coverage. Please review.

Comparison is base (b8b543c) 0.0% compared to head (ceb39c6) 69.6%.
Report is 1 commits behind head on main.

Files Patch % Lines
...ers/configuration/kongupstreampolicy_controller.go 60.3% 19 Missing and 6 partials ⚠️
...trollers/configuration/kongupstreampolicy_utils.go 86.8% 14 Missing and 7 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           main   #5428      +/-   ##
=======================================
+ Coverage      0   69.6%   +69.6%     
=======================================
  Files         0     176     +176     
  Lines         0   22507   +22507     
=======================================
+ Hits          0   15670   +15670     
- Misses        0    5912    +5912     
- Partials      0     925     +925     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@czeslavo czeslavo force-pushed the feat/support-service-facade-ancestor branch from 835bc6d to 37b16f8 Compare January 12, 2024 18:25
@czeslavo czeslavo force-pushed the feat/support-service-facade-ancestor branch 2 times, most recently from 3a1e0ff to e327869 Compare January 12, 2024 18:40
@czeslavo czeslavo removed the do not merge let the author merge this, don't merge for them. label Jan 12, 2024
@czeslavo czeslavo added this to the KIC v3.1.x milestone Jan 12, 2024
@czeslavo czeslavo changed the title [WIP] feat: support ServiceFacade as KongUpstreamPolicy ancestor feat: support ServiceFacade as KongUpstreamPolicy ancestor Jan 12, 2024
@czeslavo czeslavo changed the title feat: support ServiceFacade as KongUpstreamPolicy ancestor feat: support populating KongUpstreamPolicy status for ServiceFacade Jan 12, 2024
@czeslavo czeslavo marked this pull request as ready for review January 12, 2024 18:53
@czeslavo czeslavo requested a review from a team as a code owner January 12, 2024 18:53
@czeslavo czeslavo force-pushed the feat/support-service-facade-ancestor branch from e327869 to 7287d8b Compare January 15, 2024 18:09
@czeslavo czeslavo enabled auto-merge (squash) January 16, 2024 10:24
@czeslavo czeslavo merged commit 3936d7d into main Jan 16, 2024
37 checks passed
@czeslavo czeslavo deleted the feat/support-service-facade-ancestor branch January 16, 2024 10:24
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Some minor comments but overall 👍

groupIsCoreOrNil := br.Group == nil || *br.Group == "core"
kindIsServiceOrNil := br.Kind == nil || *br.Kind == "Service"
// We only support core Services.
return groupIsCoreOrNil && kindIsServiceOrNil
Copy link
Member

Choose a reason for hiding this comment

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

This will return true for br.Group == nil and br.Kind == nil (and also for pairs like br.Group == "core" and br.Kind == nil). Is that expected?

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 nil case for Kind should never happen as it defaults on the API level to Service. I think that we can safely consider nil to be treated as Service if it would happen for any reason.

For Group, the specification says When unspecified or empty string, core API group is inferred. so we also consider the nil case to be core API group.

Copy link
Member

Choose a reason for hiding this comment

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

It makes sense reading your comment 👍 But without that comment I wouldn't be so sure about it 🙃 Do you think it might be worth adding it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to #5444 as well. 👍

sort.Slice(ancestorsStatus, func(i, j int) bool {
return ancestorsStatus[i].creationTimestamp.Before(&ancestorsStatus[j].creationTimestamp)
})
if len(ancestorsStatus) > maxNAncestors {
Copy link
Member

Choose a reason for hiding this comment

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

maxNAncestors feels like an implementation detail that users should be aware of. We're not documenting this but this is being enforced on the Gateway API level in gatewayv1alpha2.PolicyStatus. Perhaps it's worth documenting it in a comment and in the log message?

// -----------------------------------------------------------------------------
// KongUpstreamPolicy Controller - Helpers
// -----------------------------------------------------------------------------
func (r *KongUpstreamPolicyReconciler) buildPolicyStatus(
Copy link
Member

Choose a reason for hiding this comment

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

How about a godoc for this func?

@czeslavo
Copy link
Contributor Author

@pmalek Thanks for the comments. 🙇 I'm addressing them in the next PR that adds Programmed condition to the picture: #5444.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature New feature or request size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants