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-1.11] Fix an issue where getReadyIngresses was not loading ready ingresses at startup #1081

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions config/300-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ spec:
value: "kourier-system"
- name: ENABLE_SECRET_INFORMER_FILTERING_BY_CERT_UID
value: "false"
# KUBE_API_BURST and KUBE_API_QPS allows to configure maximum burst for throttle and maximum QPS to the server from the client.
# Setting these values using env vars is possible since https://github.com/knative/pkg/pull/2755.
# 200 is an arbitrary value, but it speeds up kourier startup duration, and the whole ingress reconciliation process as a whole.
- name: KUBE_API_BURST
value: "200"
- name: KUBE_API_QPS
value: "200"
ports:
- name: http2-xds
containerPort: 18000
Expand Down
21 changes: 11 additions & 10 deletions pkg/reconciler/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
v1 "k8s.io/client-go/informers/core/v1"
Expand All @@ -35,9 +34,10 @@ import (
"knative.dev/net-kourier/pkg/generator"
rconfig "knative.dev/net-kourier/pkg/reconciler/ingress/config"
"knative.dev/networking/pkg/apis/networking/v1alpha1"
networkingClientSet "knative.dev/networking/pkg/client/clientset/versioned/typed/networking/v1alpha1"
knativeclient "knative.dev/networking/pkg/client/injection/client"
ingressinformer "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/ingress"
v1alpha1ingress "knative.dev/networking/pkg/client/injection/reconciler/networking/v1alpha1/ingress"
ingresslister "knative.dev/networking/pkg/client/listers/networking/v1alpha1"
netconfig "knative.dev/networking/pkg/config"
"knative.dev/networking/pkg/status"
kubeclient "knative.dev/pkg/client/injection/kube/client"
Expand Down Expand Up @@ -71,6 +71,7 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl
logger := logging.FromContext(ctx)

kubernetesClient := kubeclient.Get(ctx)
knativeClient := knativeclient.Get(ctx)
ingressInformer := ingressinformer.Get(ctx)
endpointsInformer := endpointsinformer.Get(ctx)
serviceInformer := serviceinformer.Get(ctx)
Expand Down Expand Up @@ -203,7 +204,7 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl
}

// Get the current list of ingresses that are ready and seed the Envoy config with them.
ingressesToSync, err := getReadyIngresses(ingressInformer.Lister())
ingressesToSync, err := getReadyIngresses(ctx, knativeClient.NetworkingV1alpha1())
if err != nil {
logger.Fatalw("Failed to fetch ready ingresses", zap.Error(err))
}
Expand Down Expand Up @@ -310,16 +311,16 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl
return impl
}

func getReadyIngresses(ingressLister ingresslister.IngressLister) ([]*v1alpha1.Ingress, error) {
ingresses, err := ingressLister.List(labels.SelectorFromSet(map[string]string{
v1alpha1ingress.ClassAnnotationKey: config.KourierIngressClassName,
}))
func getReadyIngresses(ctx context.Context, knativeClient networkingClientSet.NetworkingV1alpha1Interface) ([]*v1alpha1.Ingress, error) {
ingresses, err := knativeClient.Ingresses("").List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
ingressesToWarm := make([]*v1alpha1.Ingress, 0, len(ingresses))
for _, ingress := range ingresses {
if ingress.GetDeletionTimestamp() == nil && // Ignore ingresses that are already marked for deletion.
ingressesToWarm := make([]*v1alpha1.Ingress, 0, len(ingresses.Items))
for i := range ingresses.Items {
ingress := &ingresses.Items[i]
if isKourierIngress(ingress) &&
ingress.GetDeletionTimestamp() == nil && // Ignore ingresses that are already marked for deletion.
ingress.GetStatus().GetCondition(v1alpha1.IngressConditionNetworkConfigured).IsTrue() {
ingressesToWarm = append(ingressesToWarm, ingress)
}
Expand Down
Loading