Skip to content
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

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

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
4 changes: 4 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,7 @@ func (r *Reconciler) VerifyWeight(desiredWeight int32, additionalDestinations ..

r.cfg.Status.ALB.LoadBalancer.Name = *lb.LoadBalancerName
r.cfg.Status.ALB.LoadBalancer.ARN = *lb.LoadBalancerArn
r.cfg.Status.ALB.LoadBalancer.FullName = strings.Join(strings.Split(*lb.LoadBalancerArn, "/")[2:], "/")
danil-smirnov marked this conversation as resolved.
Show resolved Hide resolved

lbTargetGroups, err := r.aws.GetTargetGroupMetadata(ctx, *lb.LoadBalancerArn)
if err != nil {
Expand All @@ -241,6 +243,7 @@ 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
r.cfg.Status.ALB.CanaryTargetGroup.FullName = strings.Join(strings.Split(*tg.TargetGroupArn, "/")[1:], "/")
danil-smirnov marked this conversation as resolved.
Show resolved Hide resolved
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 +270,7 @@ 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
r.cfg.Status.ALB.StableTargetGroup.FullName = strings.Join(strings.Split(*tg.TargetGroupArn, "/")[1:], "/")
}
}
}
Expand Down
54 changes: 29 additions & 25 deletions rollout/trafficrouting/alb/alb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"

elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
Expand Down Expand Up @@ -455,16 +456,19 @@ func (f *fakeAWSClient) GetTargetGroupHealth(ctx context.Context, targetGroupARN
func (f *fakeAWSClient) getAlbStatus() *v1alpha1.ALBStatus {
return &v1alpha1.ALBStatus{
LoadBalancer: v1alpha1.AwsResourceRef{
Name: *f.loadBalancer.LoadBalancerName,
ARN: *f.loadBalancer.LoadBalancerArn,
Name: *f.loadBalancer.LoadBalancerName,
ARN: *f.loadBalancer.LoadBalancerArn,
FullName: strings.Join(strings.Split(*f.loadBalancer.LoadBalancerArn, "/")[2:], "/"),
},
CanaryTargetGroup: v1alpha1.AwsResourceRef{
Name: *f.targetGroups[0].TargetGroupName,
ARN: *f.targetGroups[0].TargetGroupArn,
Name: *f.targetGroups[0].TargetGroupName,
ARN: *f.targetGroups[0].TargetGroupArn,
FullName: strings.Join(strings.Split(*f.targetGroups[0].TargetGroupArn, "/")[1:], "/"),
},
StableTargetGroup: v1alpha1.AwsResourceRef{
Name: *f.targetGroups[len(f.targetGroups)-1].TargetGroupName,
ARN: *f.targetGroups[len(f.targetGroups)-1].TargetGroupArn,
Name: *f.targetGroups[len(f.targetGroups)-1].TargetGroupName,
ARN: *f.targetGroups[len(f.targetGroups)-1].TargetGroupArn,
FullName: strings.Join(strings.Split(*f.targetGroups[len(f.targetGroups)-1].TargetGroupArn, "/")[1:], "/"),
},
}
}
Expand Down Expand Up @@ -545,14 +549,14 @@ func TestVerifyWeight(t *testing.T) {
r, fakeClient := newFakeReconciler(&status)
fakeClient.loadBalancer = &elbv2types.LoadBalancer{
LoadBalancerName: pointer.StringPtr("lb-abc123-name"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn/456/789"),
danil-smirnov marked this conversation as resolved.
Show resolved Hide resolved
DNSName: pointer.StringPtr("verify-weight-test-abc-123.us-west-2.elb.amazonaws.com"),
}
fakeClient.targetGroups = []aws.TargetGroupMeta{
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("canary-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(11),
Tags: map[string]string{
Expand All @@ -562,7 +566,7 @@ func TestVerifyWeight(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("stable-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(89),
Tags: map[string]string{
Expand All @@ -583,14 +587,14 @@ func TestVerifyWeight(t *testing.T) {
r, fakeClient := newFakeReconciler(&status)
fakeClient.loadBalancer = &elbv2types.LoadBalancer{
LoadBalancerName: pointer.StringPtr("lb-abc123-name"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn/456/789"),
DNSName: pointer.StringPtr("verify-weight-test-abc-123.us-west-2.elb.amazonaws.com"),
}
fakeClient.targetGroups = []aws.TargetGroupMeta{
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("canary-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(10),
Tags: map[string]string{
Expand All @@ -600,7 +604,7 @@ func TestVerifyWeight(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("stable-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(11),
Tags: map[string]string{
Expand Down Expand Up @@ -721,14 +725,14 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
r, fakeClient := newFakeReconciler(&status)
fakeClient.loadBalancer = &elbv2types.LoadBalancer{
LoadBalancerName: pointer.StringPtr("lb-abc123-name"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn/456/789"),
DNSName: pointer.StringPtr("verify-weight-test-abc-123.us-west-2.elb.amazonaws.com"),
}
fakeClient.targetGroups = []aws.TargetGroupMeta{
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("canary-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(10),
Tags: map[string]string{
Expand All @@ -738,7 +742,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("stable-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(90),
Tags: map[string]string{
Expand All @@ -759,14 +763,14 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
r, fakeClient := newFakeReconciler(&status)
fakeClient.loadBalancer = &elbv2types.LoadBalancer{
LoadBalancerName: pointer.StringPtr("lb-abc123-name"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn/456/789"),
DNSName: pointer.StringPtr("verify-weight-test-abc-123.us-west-2.elb.amazonaws.com"),
}
fakeClient.targetGroups = []aws.TargetGroupMeta{
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("canary-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(10),
Tags: map[string]string{
Expand All @@ -776,7 +780,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("ex-svc-1-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("ex-svc-1-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("ex-svc-1-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(100),
Tags: map[string]string{
Expand All @@ -786,7 +790,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("ex-svc-2-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("ex-svc-2-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("ex-svc-2-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(100),
Tags: map[string]string{
Expand All @@ -796,7 +800,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("stable-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(85),
Tags: map[string]string{
Expand All @@ -817,14 +821,14 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
r, fakeClient := newFakeReconciler(&status)
fakeClient.loadBalancer = &elbv2types.LoadBalancer{
LoadBalancerName: pointer.StringPtr("lb-abc123-name"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn"),
LoadBalancerArn: pointer.StringPtr("lb-abc123-arn/456/789"),
DNSName: pointer.StringPtr("verify-weight-test-abc-123.us-west-2.elb.amazonaws.com"),
}
fakeClient.targetGroups = []aws.TargetGroupMeta{
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("canary-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("canary-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(10),
Tags: map[string]string{
Expand All @@ -834,7 +838,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("ex-svc-1-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("ex-svc-1-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("ex-svc-1-tg-abc123-arn/456"),
},
Weight: &weightDestinations[0].Weight,
Tags: map[string]string{
Expand All @@ -844,7 +848,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("ex-svc-2-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("ex-svc-2-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("ex-svc-2-tg-abc123-arn/456"),
},
Weight: &weightDestinations[1].Weight,
Tags: map[string]string{
Expand All @@ -854,7 +858,7 @@ func TestVerifyWeightWithAdditionalDestinations(t *testing.T) {
{
TargetGroup: elbv2types.TargetGroup{
TargetGroupName: pointer.StringPtr("stable-tg-abc123-name"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn"),
TargetGroupArn: pointer.StringPtr("stable-tg-abc123-arn/456"),
},
Weight: pointer.Int32Ptr(85),
Tags: map[string]string{
Expand Down
6 changes: 6 additions & 0 deletions ui/src/models/rollout/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ export interface GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1AwsResource
* @memberof GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1AwsResourceRef
*/
arn?: string;
/**
*
* @type {string}
* @memberof GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1AwsResourceRef
*/
fullName?: string;
}
/**
*
Expand Down