Skip to content

Make annotation based forward action backwards-compatible when numeric port is used. #1507

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

Merged
merged 1 commit into from
Oct 15, 2020
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
2 changes: 1 addition & 1 deletion controllers/ingress/group_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (r *groupReconciler) buildAndDeployModel(ctx context.Context, ingGroup ingr
if err := r.stackDeployer.Deploy(ctx, stack); err != nil {
return nil, nil, err
}
r.logger.Info("successfully deployed model")
r.logger.Info("successfully deployed model", "ingressGroup", ingGroup.ID)
return stack, lb, err
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/service/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (r *serviceReconciler) buildAndDeployModel(ctx context.Context, svc *corev1
if err = r.stackDeployer.Deploy(ctx, stack); err != nil {
return nil, nil, err
}
r.logger.Info("successfully deployed model")
r.logger.Info("successfully deployed model", "service", k8s.NamespacedName(svc))

return stack, lb, nil
}
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/ingress/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Traffic Routing can be controlled with following annotations:
alb.ingress.kubernetes.io/actions.forward-single-tg: >
{"type":"forward","targetGroupARN": "arn-of-your-target-group"}
alb.ingress.kubernetes.io/actions.forward-multiple-tg: >
{"type":"forward","forwardConfig":{"targetGroups":[{"serviceName":"service-1","servicePort":"80","weight":20},{"serviceName":"service-2","servicePort":"80","weight":20},{"targetGroupARN":"arn-of-your-non-k8s-target-group","weight":60}],"targetGroupStickinessConfig":{"enabled":true,"durationSeconds":200}}}
{"type":"forward","forwardConfig":{"targetGroups":[{"serviceName":"service-1","servicePort":"http","weight":20},{"serviceName":"service-2","servicePort":80,"weight":20},{"targetGroupARN":"arn-of-your-non-k8s-target-group","weight":60}],"targetGroupStickinessConfig":{"enabled":true,"durationSeconds":200}}}
spec:
rules:
- http:
Expand Down
49 changes: 49 additions & 0 deletions mocks/ingress/mock_cert_discovery.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions mocks/networking/mock_subnet_resolver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/ingress/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (c *QueryStringKeyValuePair) validate() error {
// Information about a query string condition.
type QueryStringConditionConfig struct {
// One or more key/value pairs or values to find in the query string.
Values []*QueryStringKeyValuePair `json:"values"`
Values []QueryStringKeyValuePair `json:"values"`
}

func (c *QueryStringConditionConfig) validate() error {
Expand Down
12 changes: 12 additions & 0 deletions pkg/ingress/enhanced_backend_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ func (b *defaultEnhancedBackendBuilder) buildActionViaAnnotation(_ context.Conte
}
action.TargetGroupARN = nil
}

// normalize servicePort to be int type if possible.
// this is for backwards-compatibility with old AWSALBIngressController, where ServicePort is defined as Type string.
if action.Type == ActionTypeForward && action.ForwardConfig != nil {
for _, tgt := range action.ForwardConfig.TargetGroups {
if tgt.ServicePort != nil {
normalizedSVCPort := intstr.Parse(tgt.ServicePort.String())
*tgt.ServicePort = normalizedSVCPort
}
}
}

return action, nil
}

Expand Down
Loading