Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
6 changes: 0 additions & 6 deletions pkg/i2gw/emitters/envoygateway/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ func (e *Emitter) EmitBuffer(ir emitterir.EmitterIR, gwResources *i2gw.GatewayRe
backendTrafficPolicy.Spec.RequestBuffer = &egapiv1a1.RequestBuffer{
Limit: *bufferVal,
}

ruleInfo := ""
if sectionName != nil {
ruleInfo = fmt.Sprintf(" rule %s", *sectionName)
}
e.notify(notifications.InfoNotification, fmt.Sprintf("applied Buffer feature for HTTPRoute%s", ruleInfo), &ctx.HTTPRoute)
}

// mark Buffer IR as processed
Expand Down
9 changes: 0 additions & 9 deletions pkg/i2gw/emitters/envoygateway/iprange.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ limitations under the License.
package envoygateway_emitter

import (
"fmt"

egapiv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
emitterir "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/emitter_intermediate"
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
"github.com/samber/lo"
"k8s.io/utils/ptr"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down Expand Up @@ -70,12 +67,6 @@ func (e *Emitter) EmitIPRangeControl(ir emitterir.EmitterIR, gwResources *i2gw.G
DefaultAction: ptr.To(defaultAction),
Rules: rules,
}

ruleInfo := ""
if sectionName != nil {
ruleInfo = fmt.Sprintf(" rule %s", *sectionName)
}
e.notify(notifications.InfoNotification, fmt.Sprintf("applied IP Range Control feature for HTTPRoute%s", ruleInfo), &ctx.HTTPRoute)
}

// mark IP Range Control IR as processed
Expand Down
11 changes: 0 additions & 11 deletions pkg/i2gw/emitters/kgateway/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ func (e *Emitter) EmitBuffer(ir emitterir.EmitterIR) {
trafficPolicy.Spec.Buffer = &kgateway.Buffer{
MaxRequestSize: bufferVal,
}

ruleInfo := e.formatRuleInfo(sectionName)
e.notify(notifications.InfoNotification, fmt.Sprintf("applied Buffer feature for HTTPRoute%s", ruleInfo), &ctx.HTTPRoute)
}
}
}
Expand All @@ -77,11 +74,3 @@ func (e *Emitter) selectBufferValue(bs *emitterir.BodySize, httpRoute *gatewayv1
}
return bs.BufferSize
}

// formatRuleInfo formats the rule information for notification messages.
func (e *Emitter) formatRuleInfo(sectionName *gatewayv1.SectionName) string {
if sectionName != nil {
return fmt.Sprintf(" rule %s", *sectionName)
}
return ""
}
4 changes: 3 additions & 1 deletion pkg/i2gw/emitters/standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ func NewEmitter(conf *i2gw.EmitterConf) i2gw.Emitter {
// Emit converts the provider intermediate representation to Gateway API resources.
func (e *Emitter) Emit(ir emitterir.EmitterIR) (i2gw.GatewayResources, field.ErrorList) {
utils.LogUnparsedErrors(ir, e.notify)
return utils.ToGatewayResources(ir)
e.notify(notifications.WarningNotification, "Gateway API does not support configuring URL normalization (RFC 3986, Section 6). Please check if this matters for your use case and consult implementation-specific details.")
resources, err := utils.ToGatewayResources(ir)
return resources, err
}
3 changes: 2 additions & 1 deletion pkg/i2gw/emitters/standard/standard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
emitterir "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/emitter_intermediate"
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -288,7 +289,7 @@ func Test_ToGatewayResources(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
emitter := Emitter{}
emitter := Emitter{notify: notifications.NoopNotify}
gatewayResouces, errs := emitter.Emit(tc.ir)

if len(errs) != len(tc.expectedErrors) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/i2gw/emitters/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func LogUnparsedErrors(ir emitterir.EmitterIR, notify notifications.NotifyFunc)
message := unparsedExtension.FailureMessage()

notify(notifications.WarningNotification,
fmt.Sprintf("failed to parse %s from Ingress %s: %s", source, strings.TrimSuffix(paths.String(), ", "), message),
fmt.Sprintf("Failed to apply %s from %s: %s", strings.TrimSuffix(paths.String(), ", "), source, message),
&httpRouteContext.HTTPRoute,
)
}
Expand Down
16 changes: 0 additions & 16 deletions pkg/i2gw/providers/ingressnginx/backend_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ func createBackendTLSPolicies(_ notifications.NotifyFunc, ingresses []networking
if serviceName == "" {
continue
}

// TODO: implement proxy-ssl annotations
// policyName := fmt.Sprintf("%s-tls-policy", serviceName)
// policyKey := types.NamespacedName{Namespace: rg.Namespace, Name: policyName}

// if _, exists := ir.BackendTLSPolicies[policyKey]; !exists {
// policy := common.CreateBackendTLSPolicy(rg.Namespace, policyName, serviceName)
// ir.BackendTLSPolicies[policyKey] = policy
// notify(notifications.InfoNotification, fmt.Sprintf("Created BackendTLSPolicy %s/%s for service %s due to backend-protocol %q",
// policy.Namespace, policy.Name, serviceName, protocolType), &policy)
// } else {
// // Policy already exists, this means another Ingress or rule group already requested it.
// // We should notify that this host is also requesting it.
// notify(notifications.InfoNotification, fmt.Sprintf("Service %s already has BackendTLSPolicy %s/%s (requested by host %q with protocol %q)",
// serviceName, rg.Namespace, policyName, rg.Host, protocolType), nil)
// }
}
}
}
Expand Down
38 changes: 10 additions & 28 deletions pkg/i2gw/providers/ingressnginx/bodysize.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ func convertNginxSizeToK8sQuantity(nginxSize string) (string, error) {
// Currently supported annotations are:
// - nginx.ingress.kubernetes.io/proxy-body-size
// - nginx.ingress.kubernetes.io/client-body-buffer-size
func applyBodySizeToEmitterIR(notify notifications.NotifyFunc, pIR providerir.ProviderIR, eIR *emitterir.EmitterIR) field.ErrorList {
var errs field.ErrorList
func (p *Provider) applyBodySizeToEmitterIR(pIR providerir.ProviderIR, eIR *emitterir.EmitterIR) {

for key, pRouteCtx := range pIR.HTTPRoutes {
eRouteCtx, ok := eIR.HTTPRoutes[key]
Expand Down Expand Up @@ -112,21 +111,15 @@ func applyBodySizeToEmitterIR(notify notifications.NotifyFunc, pIR providerir.Pr
parsedAnnotations = append(parsedAnnotations, ProxyBodySizeAnnotation)
k8sSize, err := convertNginxSizeToK8sQuantity(val)
if err != nil {
errs = append(errs, field.Invalid(
field.NewPath("ingress", ing.Namespace, ing.Name, "metadata", "annotations"),
ing.Annotations,
fmt.Sprintf("failed to parse proxy-body-size configuration: %v", err),
))
p.notify(notifications.ErrorNotification, fmt.Sprintf("Invalid proxy-body-size annotation %q: %v, skipping body size",
val, err), ing)
continue
}

quantity, err := resource.ParseQuantity(k8sSize)
if err != nil {
errs = append(errs, field.Invalid(
field.NewPath("ingress", ing.Namespace, ing.Name, "metadata", "annotations"),
ing.Annotations,
fmt.Sprintf("failed to parse proxy-body-size configuration: %v", err),
))
p.notify(notifications.ErrorNotification, fmt.Sprintf("Invalid proxy-body-size annotation %q: %v, skipping body size",
val, err), ing)
continue
}
maxSize = &quantity
Expand All @@ -137,21 +130,15 @@ func applyBodySizeToEmitterIR(notify notifications.NotifyFunc, pIR providerir.Pr
parsedAnnotations = append(parsedAnnotations, ClientBodyBufferSizeAnnotation)
k8sSize, err := convertNginxSizeToK8sQuantity(val)
if err != nil {
errs = append(errs, field.Invalid(
field.NewPath("ingress", ing.Namespace, ing.Name, "metadata", "annotations"),
ing.Annotations,
fmt.Sprintf("failed to parse client-body-buffer-size configuration: %v", err),
))
p.notify(notifications.WarningNotification, fmt.Sprintf("Invalid client-body-buffer-size annotation %q: %v, skipping buffer size",
val, err), ing)
continue
}

quantity, err := resource.ParseQuantity(k8sSize)
if err != nil {
errs = append(errs, field.Invalid(
field.NewPath("ingress", ing.Namespace, ing.Name, "metadata", "annotations"),
ing.Annotations,
fmt.Sprintf("failed to parse client-body-buffer-size configuration: %v", err),
))
p.notify(notifications.WarningNotification, fmt.Sprintf("Invalid client-body-buffer-size annotation %q: %v, skipping buffer size",
val, err), ing)
continue
}
bufferSize = &quantity
Expand All @@ -171,7 +158,7 @@ func applyBodySizeToEmitterIR(notify notifications.NotifyFunc, pIR providerir.Pr
message := "Most Gateway API implementations have reasonable body size and buffering defaults"
paths := make([]*field.Path, len(parsedAnnotations))
for i, ann := range parsedAnnotations {
paths[i] = field.NewPath("ingress", ing.Namespace, ing.Name, "metadata", "annotations", ann)
paths[i] = field.NewPath(ing.Namespace, ing.Name, "metadata", "annotations", fmt.Sprintf("%q", ann))
}
bodySizeIR.Metadata = emitterir.NewExtensionFeatureMetadata(
source,
Expand All @@ -182,19 +169,14 @@ func applyBodySizeToEmitterIR(notify notifications.NotifyFunc, pIR providerir.Pr

if maxSize != nil {
bodySizeIR.MaxSize = maxSize
notify(notifications.InfoNotification, fmt.Sprintf("parsed proxy-body-size annotation of ingress %s/%s and set %s to HTTPRoute rule index %d",
ing.Namespace, ing.Name, maxSize.String(), ruleIdx), &eRouteCtx.HTTPRoute)
}
if bufferSize != nil {
bodySizeIR.BufferSize = bufferSize
notify(notifications.InfoNotification, fmt.Sprintf("parsed client-body-buffer-size annotation of ingress %s/%s and set %s to HTTPRoute rule index %d",
ing.Namespace, ing.Name, bufferSize.String(), ruleIdx), &eRouteCtx.HTTPRoute)
}

eRouteCtx.BodySizeByRuleIdx[ruleIdx] = &bodySizeIR
}

eIR.HTTPRoutes[key] = eRouteCtx
}
return errs
}
15 changes: 6 additions & 9 deletions pkg/i2gw/providers/ingressnginx/bodysize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ func TestApplyBodySizeToEmitterIR_SetMaxSize(t *testing.T) {
}
pIR, eIR := setupBodySizeTest(key, annotations)

if err := applyBodySizeToEmitterIR(notifications.NoopNotify, pIR, &eIR); err != nil {
t.Fatalf("unexpected error applying body size: %v", err)
}
p := &Provider{notify: notifications.NoopNotify}
p.applyBodySizeToEmitterIR(pIR, &eIR)

bodySizeIR := eIR.HTTPRoutes[key].BodySizeByRuleIdx[0]
if bodySizeIR == nil {
Expand All @@ -126,9 +125,8 @@ func TestApplyBodySizeToEmitterIR_SetBufferSize(t *testing.T) {
}
pIR, eIR := setupBodySizeTest(key, annotations)

if err := applyBodySizeToEmitterIR(notifications.NoopNotify, pIR, &eIR); err != nil {
t.Fatalf("unexpected error applying body size: %v", err)
}
p := &Provider{notify: notifications.NoopNotify}
p.applyBodySizeToEmitterIR(pIR, &eIR)

bodySizeIR := eIR.HTTPRoutes[key].BodySizeByRuleIdx[0]
if bodySizeIR == nil {
Expand All @@ -147,9 +145,8 @@ func TestApplyBodySizeToEmitterIR_SetMaxAndBufferSize(t *testing.T) {
}
pIR, eIR := setupBodySizeTest(key, annotations)

if err := applyBodySizeToEmitterIR(notifications.NoopNotify, pIR, &eIR); err != nil {
t.Fatalf("unexpected error applying body size: %v", err)
}
p := &Provider{notify: notifications.NoopNotify}
p.applyBodySizeToEmitterIR(pIR, &eIR)

bodySizeIR := eIR.HTTPRoutes[key].BodySizeByRuleIdx[0]
if bodySizeIR == nil {
Expand Down
Loading