Skip to content

feat(controller): Adding status.alb.canaryTargetGroup.fullName for ALB. Fixes #2589 #2604

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 13 commits into from
Feb 25, 2023
9 changes: 9 additions & 0 deletions manifests/crds/rollout-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3247,30 +3247,39 @@ spec:
properties:
arn:
type: string
fullName:
type: string
name:
type: string
required:
- arn
- fullName
- name
type: object
loadBalancer:
properties:
arn:
type: string
fullName:
type: string
name:
type: string
required:
- arn
- fullName
- name
type: object
stableTargetGroup:
properties:
arn:
type: string
fullName:
type: string
name:
type: string
required:
- arn
- fullName
- name
type: object
type: object
Expand Down
9 changes: 9 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14293,30 +14293,39 @@ spec:
properties:
arn:
type: string
fullName:
type: string
name:
type: string
required:
- arn
- fullName
- name
type: object
loadBalancer:
properties:
arn:
type: string
fullName:
type: string
name:
type: string
required:
- arn
- fullName
- name
type: object
stableTargetGroup:
properties:
arn:
type: string
fullName:
type: string
name:
type: string
required:
- arn
- fullName
- name
type: object
type: object
Expand Down
3 changes: 3 additions & 0 deletions pkg/apiclient/rollout/rollout.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@
},
"arn": {
"type": "string"
},
"fullName": {
"type": "string"
}
}
},
Expand Down
1,027 changes: 534 additions & 493 deletions pkg/apis/rollouts/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/apis/rollouts/v1alpha1/generated.proto

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

9 changes: 8 additions & 1 deletion pkg/apis/rollouts/v1alpha1/openapi_generated.go

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

5 changes: 3 additions & 2 deletions pkg/apis/rollouts/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,9 @@ type ALBStatus struct {
}

type AwsResourceRef struct {
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
ARN string `json:"arn" protobuf:"bytes,2,opt,name=arn"`
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
ARN string `json:"arn" protobuf:"bytes,2,opt,name=arn"`
FullName string `json:"fullName" protobuf:"bytes,3,opt,name=fullName"`
}

// RolloutConditionType defines the conditions of Rollout
Expand Down
19 changes: 19 additions & 0 deletions rollout/trafficrouting/alb/alb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strconv"
"strings"

rolloututil "github.com/argoproj/argo-rollouts/utils/rollout"

Expand Down Expand Up @@ -230,6 +231,12 @@ func (r *Reconciler) VerifyWeight(desiredWeight int32, additionalDestinations ..

r.cfg.Status.ALB.LoadBalancer.Name = *lb.LoadBalancerName
r.cfg.Status.ALB.LoadBalancer.ARN = *lb.LoadBalancerArn
if lbArnParts := strings.Split(*lb.LoadBalancerArn, "/"); len(lbArnParts) > 2 {
r.cfg.Status.ALB.LoadBalancer.FullName = strings.Join(lbArnParts[2:], "/")
} else {
r.cfg.Status.ALB.LoadBalancer.FullName = ""
r.log.Errorf("error parsing load balancer arn: '%s'", *lb.LoadBalancerArn)
}

lbTargetGroups, err := r.aws.GetTargetGroupMetadata(ctx, *lb.LoadBalancerArn)
if err != nil {
Expand All @@ -241,6 +248,12 @@ func (r *Reconciler) VerifyWeight(desiredWeight int32, additionalDestinations ..
if tg.Tags[aws.AWSLoadBalancerV2TagKeyResourceID] == canaryResourceID {
r.cfg.Status.ALB.CanaryTargetGroup.Name = *tg.TargetGroupName
r.cfg.Status.ALB.CanaryTargetGroup.ARN = *tg.TargetGroupArn
if tgArnParts := strings.Split(*tg.TargetGroupArn, "/"); len(tgArnParts) > 1 {
r.cfg.Status.ALB.CanaryTargetGroup.FullName = strings.Join(tgArnParts[1:], "/")
} else {
r.cfg.Status.ALB.CanaryTargetGroup.FullName = ""
r.log.Errorf("error parsing canary target group arn: '%s'", *tg.TargetGroupArn)
}
if tg.Weight != nil {
logCtx := logCtx.WithField("tg", *tg.TargetGroupArn)
logCtx.Infof("canary weight of %s (desired: %d, current: %d)", canaryResourceID, desiredWeight, *tg.Weight)
Expand All @@ -267,6 +280,12 @@ func (r *Reconciler) VerifyWeight(desiredWeight int32, additionalDestinations ..
} else if tg.Tags[aws.AWSLoadBalancerV2TagKeyResourceID] == stableResourceID {
r.cfg.Status.ALB.StableTargetGroup.Name = *tg.TargetGroupName
r.cfg.Status.ALB.StableTargetGroup.ARN = *tg.TargetGroupArn
if tgArnParts := strings.Split(*tg.TargetGroupArn, "/"); len(tgArnParts) > 1 {
r.cfg.Status.ALB.StableTargetGroup.FullName = strings.Join(tgArnParts[1:], "/")
} else {
r.cfg.Status.ALB.StableTargetGroup.FullName = ""
r.log.Errorf("error parsing stable target group arn: '%s'", *tg.TargetGroupArn)
}
}
}
}
Expand Down
Loading