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

[release/v1.2] Cherry pick main to v1.2 #4640

Merged
merged 54 commits into from
Nov 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7bd7db5
Reduce the amount of configuration logging, and make it line-delimete…
evankanderson Oct 26, 2024
a9f383d
feat: enable load backend resources (#4535)
shawnh2 Oct 27, 2024
8467f66
build(deps): bump actions/setup-node from 4.0.4 to 4.1.0 (#4537)
dependabot[bot] Oct 28, 2024
e876413
chore: optimized code (#4514)
zirain Oct 28, 2024
2cf962e
build(deps): bump github/codeql-action from 3.26.13 to 3.27.0 (#4538)
dependabot[bot] Oct 28, 2024
c92ad05
build(deps): bump distroless/static from `26f9b99` to `3a03fc0` in /t…
dependabot[bot] Oct 28, 2024
6dce9f5
build(deps): bump actions/setup-go from 5.0.2 to 5.1.0 in /tools/gith…
dependabot[bot] Oct 28, 2024
8519708
build(deps): bump github.com/replicatedhq/troubleshoot from 0.107.1 t…
dependabot[bot] Oct 28, 2024
495c6c2
build(deps): bump github.com/tsaarni/certyaml from 0.9.3 to 0.10.0 (#…
dependabot[bot] Oct 28, 2024
0cfe664
build(deps): bump actions/checkout from 4.2.1 to 4.2.2 (#4539)
dependabot[bot] Oct 28, 2024
562efa9
build(deps): bump github.com/fatih/color from 1.17.0 to 1.18.0 (#4545)
dependabot[bot] Oct 28, 2024
5514167
e2e test for Gateway with EnvoyProxy (#4548)
zhaohuabing Oct 28, 2024
37018e7
make watching alpha CRDs optional (#4519)
arkodg Oct 29, 2024
9c2faa3
fix: validate proto messages before converting them to anypb.Any (#4499)
zhaohuabing Oct 29, 2024
0b7a230
Fix: xds translation failed when wasm http code source configured wit…
zhaohuabing Oct 29, 2024
eec1048
build(deps): bump sigs.k8s.io/controller-runtime from 0.19.0 to 0.19.…
dependabot[bot] Oct 29, 2024
a1529b8
feat(chart): Make security context configurable (#4536)
tamalsaha Oct 30, 2024
0784f1c
helm: make eg-addons support IPv6 cluster (#4559)
zirain Oct 30, 2024
6e95d8d
ci: cleanup osv-scanner config (#4579)
shahar-h Oct 30, 2024
01e3d7b
fix egctl release artifacts (#4580)
arkodg Oct 31, 2024
569d08d
fix debug level logging for IR (#4584)
arkodg Oct 31, 2024
a4241ce
docs: remove List type (#4585)
zirain Oct 31, 2024
5c8bea9
ci: enable test for dual stack cluster (#4574)
zirain Oct 31, 2024
4227f41
build(deps): bump the k8s-io group across 2 directories with 6 update…
dependabot[bot] Oct 31, 2024
79f128a
chore: remove dump (#4593)
zirain Oct 31, 2024
b9039ea
fix: trigger reconcile for Secret updates referenced by a BackendTLSP…
arkodg Oct 31, 2024
94db773
chore: use net.JoinHostPort (#4599)
zirain Nov 1, 2024
23209b8
fix keycloak ipv6 issue (#4601)
zhaohuabing Nov 1, 2024
ab115fd
fix: Route with multiple parents has incorrect namespace in parentRef…
zhaohuabing Nov 1, 2024
f14503c
add envoy-gateway binary to release artifacts (#4588)
arkodg Nov 1, 2024
c652ff3
[release/v1.1] release v1.1.3 (#4600)
guydc Nov 1, 2024
6fc0b1e
chore: donot use space in short name (#4608)
zirain Nov 2, 2024
d273f64
Move v1.1 docs tag to v1.1.2 (#4615)
arkodg Nov 3, 2024
fe2d621
fix: HTTPRoute status only shows one parent when targeting multiple G…
zhaohuabing Nov 4, 2024
fe913da
direct response docs and tests (#4583)
arkodg Nov 4, 2024
5fb95bd
build(deps): bump github.com/fsnotify/fsnotify from 1.7.0 to 1.8.0 (#…
dependabot[bot] Nov 4, 2024
52e3528
build(deps): bump github.com/bufbuild/buf from 1.45.0 to 1.46.0 in /t…
dependabot[bot] Nov 4, 2024
aadb4b3
remove myself from maintainers (#4624)
Alice-Lilith Nov 4, 2024
59c5315
e2e: move apps to examples and pre-built (#4576)
zirain Nov 4, 2024
93da0f3
fix: wasm oci image source e2e test failed when IP_FAMILY=ipv6 (#4623)
zhaohuabing Nov 4, 2024
9e905a0
workaroud for the flaky oidc e2e test (#4603)
zhaohuabing Nov 4, 2024
d7becd5
build(deps): bump softprops/action-gh-release from 2.0.8 to 2.0.9 (#4…
dependabot[bot] Nov 4, 2024
1047980
Set ignore_health_on_host_removal to true for static clusters (#4612)
arkodg Nov 4, 2024
07ce2f2
build(deps): bump github.com/prometheus/common from 0.60.0 to 0.60.1 …
dependabot[bot] Nov 4, 2024
17f6963
build(deps): bump github.com/replicatedhq/troubleshoot from 0.107.4 t…
dependabot[bot] Nov 4, 2024
b20a551
add docker.io registry name in image name (#4628)
arkodg Nov 4, 2024
f67bfce
docs: Jwt claim based authorization (#4617)
zhaohuabing Nov 4, 2024
970d244
build(deps): bump github.com/ohler55/ojg from 1.24.1 to 1.25.0 (#4618)
dependabot[bot] Nov 5, 2024
0980335
e2e: use grafana alloy instead of fluent-bit (#4525)
zirain Nov 5, 2024
add0183
chore: update site docs link for latest release (#4634)
guydc Nov 5, 2024
5ba0288
fix: push a helm chart without v in ther version (#4636)
zhaohuabing Nov 6, 2024
f9dd033
add envoy-gateway binary to latest release artifacts (#4638)
arkodg Nov 6, 2024
a1fd798
fix: BackendTlsPolicy specify multiple targetRefs of the same service…
zhaohuabing Nov 6, 2024
c35d7a0
fix build
zhaohuabing Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Route with multiple parents has incorrect namespace in parentRef…
… status (#4592)

fix route status wrong ns

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
(cherry picked from commit 7285dda)
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
  • Loading branch information
zhaohuabing committed Nov 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ab115fd3d58dc2716ba22ba4f4adbb623858776f
52 changes: 40 additions & 12 deletions internal/gatewayapi/contexts.go
Original file line number Diff line number Diff line change
@@ -238,21 +238,26 @@ func GetRouteStatus(route RouteContext) *gwapiv1.RouteStatus {
return &rs
}

// GetRouteParentContext returns RouteParentContext by using the Route
// objects' ParentReference.
// GetRouteParentContext returns RouteParentContext by using the Route objects' ParentReference.
// It creates a new RouteParentContext and add a new RouteParentStatus to the Route's Status if the ParentReference is not found.
func GetRouteParentContext(route RouteContext, forParentRef gwapiv1.ParentReference) *RouteParentContext {
rv := reflect.ValueOf(route).Elem()
pr := rv.FieldByName("ParentRefs")

// If the ParentRefs field is nil, initialize it.
if pr.IsNil() {
mm := reflect.MakeMap(reflect.TypeOf(map[gwapiv1.ParentReference]*RouteParentContext{}))
pr.Set(mm)
}

// If the RouteParentContext is already in the RouteContext, return it.
if p := pr.MapIndex(reflect.ValueOf(forParentRef)); p.IsValid() && !p.IsZero() {
ctx := p.Interface().(*RouteParentContext)
return ctx
}

// Verify that the ParentReference is present in the Route.Spec.ParentRefs.
// This is just a sanity check, the parentRef should always be present, otherwise it's a programming error.
var parentRef *gwapiv1.ParentReference
specParentRefs := rv.FieldByName("Spec").FieldByName("ParentRefs")
for i := 0; i < specParentRefs.Len(); i++ {
@@ -266,25 +271,19 @@ func GetRouteParentContext(route RouteContext, forParentRef gwapiv1.ParentRefere
panic("parentRef not found")
}

// Find the parent in the Route's Status.
routeParentStatusIdx := -1
defaultNamespace := gwapiv1.Namespace(metav1.NamespaceDefault)
statusParents := rv.FieldByName("Status").FieldByName("Parents")

for i := 0; i < statusParents.Len(); i++ {
p := statusParents.Index(i).FieldByName("ParentRef").Interface().(gwapiv1.ParentReference)
// For those non-v1 routes, their underlying type of `ParentReference` is v1 as well.
// So we can skip upgrading these routes for simplicity.
if forParentRef.Namespace == nil {
forParentRef.Namespace = &defaultNamespace
}
if p.Namespace == nil {
p.Namespace = &defaultNamespace
}
if reflect.DeepEqual(p, forParentRef) {
if isParentRefEqual(p, *parentRef, route.GetNamespace()) {
routeParentStatusIdx = i
break
}
}

// If the parent is not found in the Route's Status, create a new RouteParentStatus and add it to the Route's Status.
if routeParentStatusIdx == -1 {
rParentStatus := gwapiv1a2.RouteParentStatus{
ControllerName: gwapiv1a2.GatewayController(rv.FieldByName("GatewayControllerName").String()),
@@ -294,6 +293,7 @@ func GetRouteParentContext(route RouteContext, forParentRef gwapiv1.ParentRefere
routeParentStatusIdx = statusParents.Len() - 1
}

// Also add the RouteParentContext to the RouteContext.
ctx := &RouteParentContext{
ParentReference: parentRef,
routeParentStatusIdx: routeParentStatusIdx,
@@ -304,6 +304,34 @@ func GetRouteParentContext(route RouteContext, forParentRef gwapiv1.ParentRefere
return ctx
}

func isParentRefEqual(ref1, ref2 gwapiv1.ParentReference, routeNS string) bool {
defaultGroup := (*gwapiv1.Group)(&gwapiv1.GroupVersion.Group)
if ref1.Group == nil {
ref1.Group = defaultGroup
}
if ref2.Group == nil {
ref2.Group = defaultGroup
}

defaultKind := gwapiv1.Kind(resource.KindGateway)
if ref1.Kind == nil {
ref1.Kind = &defaultKind
}
if ref2.Kind == nil {
ref2.Kind = &defaultKind
}

// If the parent's namespace is not set, default to the namespace of the Route.
defaultNS := gwapiv1.Namespace(routeNS)
if ref1.Namespace == nil {
ref1.Namespace = &defaultNS
}
if ref2.Namespace == nil {
ref2.Namespace = &defaultNS
}
return reflect.DeepEqual(ref1, ref2)
}

// RouteParentContext wraps a ParentReference and provides helper methods for
// setting conditions and other status information on the associated
// HTTPRoute, TLSRoute etc.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway-a
namespace: default
spec:
gatewayClassName: envoy-gateway-class
listeners:
- name: default
port: 80
protocol: HTTP
hostname: '*.a.example.com'
allowedRoutes:
namespaces:
from: All
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway-b
namespace: envoy-gateway
spec:
gatewayClassName: envoy-gateway-class
listeners:
- name: default
port: 80
protocol: HTTP
hostname: '*.b.example.com'
allowedRoutes:
namespaces:
from: All
httpRoutes:
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: targeted-route
namespace: envoy-gateway
spec:
hostnames:
- targeted.a.example.com
- targeted.b.example.com
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: gateway-a
namespace: default
- group: gateway.networking.k8s.io
kind: Gateway
name: gateway-b
rules:
- matches:
- method: GET
path:
type: PathPrefix
value: /toy
Loading