-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set SupportedVersion on GatewayClass (#1301)
Problem: NGF does not set the SupportedVersion condition on the GatewayClass. Solution: Set the SupportedVersion condition on the GatewayClass. This PR adds a new controller that watches the metadata of CRDs. CRD events are filtered using a custom predicate that inspects the gateway.networking.k8s.io/bundle-version annotation. CRDs without this annotation will be ignored. Updates to this annotation will trigger a state change and build a new graph. This required some changes to how we determine if the state has changed in the changeTrackingUpdater.
- Loading branch information
1 parent
d27dde5
commit d6bbdba
Showing
35 changed files
with
1,434 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package predicate | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/event" | ||
"sigs.k8s.io/controller-runtime/pkg/predicate" | ||
) | ||
|
||
// AnnotationPredicate implements a predicate function based on the Annotation. | ||
// | ||
// This predicate will skip the following events: | ||
// 1. Create events that do not contain the Annotation. | ||
// 2. Update events where the Annotation value has not changed. | ||
type AnnotationPredicate struct { | ||
predicate.Funcs | ||
Annotation string | ||
} | ||
|
||
// Create filters CreateEvents based on the Annotation. | ||
func (cp AnnotationPredicate) Create(e event.CreateEvent) bool { | ||
if e.Object == nil { | ||
return false | ||
} | ||
|
||
_, ok := e.Object.GetAnnotations()[cp.Annotation] | ||
return ok | ||
} | ||
|
||
// Update filters UpdateEvents based on the Annotation. | ||
func (cp AnnotationPredicate) Update(e event.UpdateEvent) bool { | ||
if e.ObjectOld == nil || e.ObjectNew == nil { | ||
// this case should not happen | ||
return false | ||
} | ||
|
||
oldAnnotationVal := e.ObjectOld.GetAnnotations()[cp.Annotation] | ||
newAnnotationVal := e.ObjectNew.GetAnnotations()[cp.Annotation] | ||
|
||
return oldAnnotationVal != newAnnotationVal | ||
} |
Oops, something went wrong.