Skip to content

Commit

Permalink
feat(controller): Adding status.alb.canaryTargetGroup.fullName for ALB.
Browse files Browse the repository at this point in the history
Fixes #2589 (#2604)

* Adding status.alb.canaryTargetGroup.fullName for ALB

Signed-off-by: Danil Smirnov <[email protected]>

* Fixes

Signed-off-by: Danil Smirnov <[email protected]>

* Formatting fix

Signed-off-by: Danil Smirnov <[email protected]>

* Fixes

Signed-off-by: Danil Smirnov <[email protected]>

* Fixes

Signed-off-by: Danil Smirnov <[email protected]>

* Fixes

Signed-off-by: Danil Smirnov <[email protected]>

* Formatting fix

Signed-off-by: Danil Smirnov <[email protected]>

* run make codegen

Signed-off-by: zachaller <[email protected]>

* run make codegen

Signed-off-by: zachaller <[email protected]>

* ALB tests fix

Signed-off-by: Danil Smirnov <[email protected]>

* ALB tests fix

Signed-off-by: Danil Smirnov <[email protected]>

* Fixes

Signed-off-by: Danil Smirnov <[email protected]>

* Adding unit test

Signed-off-by: Danil Smirnov <[email protected]>

---------

Signed-off-by: Danil Smirnov <[email protected]>
Signed-off-by: zachaller <[email protected]>
Co-authored-by: zachaller <[email protected]>
  • Loading branch information
danil-smirnov and zachaller authored Feb 25, 2023
1 parent e912c71 commit cef5f06
Show file tree
Hide file tree
Showing 10 changed files with 673 additions and 519 deletions.
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

0 comments on commit cef5f06

Please sign in to comment.