Implement object deep inspector (#8456)
This commit is contained in:
parent
5737f16663
commit
89ed571d2a
15 changed files with 468 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ import (
|
|||
clientcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/ingress-nginx/internal/ingress/inspector"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
|
|
@ -247,6 +248,7 @@ func New(
|
|||
client clientset.Interface,
|
||||
updateCh *channels.RingChannel,
|
||||
disableCatchAll bool,
|
||||
deepInspector bool,
|
||||
icConfig *ingressclass.IngressClassConfiguration) Storer {
|
||||
|
||||
store := &k8sStore{
|
||||
|
|
@ -426,6 +428,12 @@ func New(
|
|||
|
||||
klog.InfoS("Found valid IngressClass", "ingress", klog.KObj(ing), "ingressclass", ic)
|
||||
|
||||
if deepInspector {
|
||||
if err := inspector.DeepInspect(ing); err != nil {
|
||||
klog.ErrorS(err, "received invalid ingress", "ingress", klog.KObj(ing))
|
||||
return
|
||||
}
|
||||
}
|
||||
if hasCatchAllIngressRule(ing.Spec) && disableCatchAll {
|
||||
klog.InfoS("Ignoring add for catch-all ingress because of --disable-catch-all", "ingress", klog.KObj(ing))
|
||||
return
|
||||
|
|
@ -482,6 +490,13 @@ func New(
|
|||
return
|
||||
}
|
||||
|
||||
if deepInspector {
|
||||
if err := inspector.DeepInspect(curIng); err != nil {
|
||||
klog.ErrorS(err, "received invalid ingress", "ingress", klog.KObj(curIng))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
store.syncIngress(curIng)
|
||||
store.updateSecretIngressMap(curIng)
|
||||
store.syncSecrets(curIng)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -204,6 +205,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -307,6 +309,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -422,6 +425,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
ingressClassconfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -551,6 +555,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
ingressClassconfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -650,6 +655,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -743,6 +749,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -828,6 +835,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -923,6 +931,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -1046,6 +1055,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -1166,6 +1176,7 @@ func TestStore(t *testing.T) {
|
|||
clientSet,
|
||||
updateCh,
|
||||
false,
|
||||
true,
|
||||
DefaultClassConfig)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue