From 4ace3c05d5c2cc55cdb65fde954c9845e00fe429 Mon Sep 17 00:00:00 2001 From: Izaak Lauer <8404559+izaaklauer@users.noreply.github.com> Date: Wed, 25 Jan 2023 17:34:45 -0500 Subject: [PATCH 1/3] Allow bringing your own alb listener MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this, our docs claimed we allowed users to bring their own alb listeners: https://developer.hashicorp.com/waypoint/plugins/aws-ecs#alb-listener_arn But in practice, they would get this error: ``` $ waypoint deploy » Deploying hello-app... ✓ Running deploy v22 ✓ Deployment resources created ✓ Discovered service subnets ✓ Discovered alb subnets ✓ Using external security group hello-app-inbound ✓ Using internal security group hello-app-inbound-internal ✓ Using existing log group waypoint-logs ✓ Using existing execution IAM role "ecr-hello-app" ✓ Registered Task definition: waypoint-hello-app ✓ Using existing ECS cluster waypoint ✓ Created target group hello-app-01GQNGJSKZ557FNN7JPG7 ✓ Modified ALB Listener to introduce target group ✓ Created ECS Service hello-app-01GQNGJSKZ557FNN7JPG7 » Performing operation locally ✓ Finished building report for ecs deployment ✓ Determining status of ecs service hello-app-01GQNGJSKZ557FNN7JPG7 ✓ Found existing ECS cluster: waypoint ⚠️ 1 cluster READY, 1 service READY, 1 task MISSING ⚠️ Waypoint detected that the current deployment is not ready, however your application might be available or still starting up. » Releasing... » Performing operation locally ✓ Running release v17 ! ValidationError: A load balancer ARN must be specified status code: 400, request id: f6328bdb-0616-484e-8654-140b8c2c1ca9 ``` Waypoint hcl contents: ``` project = "hello-app" app "hello-app" { build { use "pack" {} registry { use "aws-ecr" { region = "us-east-1" repository = "waypoint-example" tag = "latest" } } } deploy { use "aws-ecs" { region = "us-east-1" memory = "512" alb { listener_arn = "arn:aws:elasticloadbalancing:us-east-1:863953081260:listener/app/waypoint-ecs-hello-app/3cdb806e2340b21e/1c2034ee6148da78" subnets = ["subnet-0bd08267365065f8e","subnet-04ff6753f3ba35e49","subnet-02c9aaa7732de7eb7","subnet-047d5841370712b24","subnet-086d533750a535ea5","subnet-0f8dd2e1826266538"] } } } } ``` This change brings us in line with our docs. --- builtin/aws/ecs/platform.go | 29 +++- builtin/aws/ecs/plugin.pb.go | 252 ++++++++++++++++++++--------------- builtin/aws/ecs/plugin.proto | 9 +- builtin/aws/ecs/releaser.go | 173 +++++++++++++++--------- 4 files changed, 291 insertions(+), 172 deletions(-) diff --git a/builtin/aws/ecs/platform.go b/builtin/aws/ecs/platform.go index 97a33a4306c..747517711af 100644 --- a/builtin/aws/ecs/platform.go +++ b/builtin/aws/ecs/platform.go @@ -395,7 +395,18 @@ func (p *Platform) Deploy( result.TargetGroupArn = tgState.Arn albState := rm.Resource("application load balancer").State().(*Resource_Alb) - result.LoadBalancerArn = albState.Arn + albListenerState := rm.Resource("alb listener").State().(*Resource_Alb_Listener) + if albState != nil && albState.Arn != "" { + result.LbReference = &Deployment_LoadBalancerArn{ + LoadBalancerArn: albState.Arn, + } + } else if albListenerState != nil && albListenerState.Arn != "" { + result.LbReference = &Deployment_ListenerArn{ + ListenerArn: albListenerState.Arn, + } + } else { + return nil, status.Errorf(codes.FailedPrecondition, "missing an alb and an alb listener - one must be set") + } cState := rm.Resource("cluster").State().(*Resource_Cluster) result.Cluster = cState.Name @@ -1720,7 +1731,6 @@ func (p *Platform) resourceAlbCreate( } state.Arn = *lb.LoadBalancerArn - state.Arn = *lb.LoadBalancerArn state.DnsName = *lb.DNSName state.CanonicalHostedZoneId = *lb.CanonicalHostedZoneId @@ -2514,8 +2524,15 @@ func (p *Platform) loadResourceManagerState( listenerResource.Managed = false log.Debug("Using existing listener", "arn", listenerResource.Arn) } else { + var loadBalancerArn string + if albRef, ok := deployment.LbReference.(*Deployment_LoadBalancerArn); ok { + loadBalancerArn = albRef.LoadBalancerArn + } else { + return status.Errorf(codes.FailedPrecondition, "cannot restore state to release this old deployment - expecting deployment to have an ALB reference, instead got %T. Please deploy again.", deployment.LbReference) + } + listenerResource.Managed = true - s.Update("Describing load balancer %s", deployment.LoadBalancerArn) + s.Update("Describing load balancer %s", loadBalancerArn) sess, err := p.getSession(log) if err != nil { return status.Errorf(codes.Internal, "failed to get aws session: %s", err) @@ -2523,13 +2540,13 @@ func (p *Platform) loadResourceManagerState( elbsrv := elbv2.New(sess) listeners, err := elbsrv.DescribeListenersWithContext(ctx, &elbv2.DescribeListenersInput{ - LoadBalancerArn: &deployment.LoadBalancerArn, + LoadBalancerArn: &loadBalancerArn, }) if err != nil { - return status.Errorf(codes.Internal, "failed to describe listeners for ALB %q: %s", deployment.LoadBalancerArn, err) + return status.Errorf(codes.Internal, "failed to describe listeners for ALB %q: %s", loadBalancerArn, err) } if len(listeners.Listeners) == 0 { - s.Update("No listeners found for ALB %q", deployment.LoadBalancerArn) + s.Update("No listeners found for ALB %q", loadBalancerArn) } else { listenerResource.Arn = *listeners.Listeners[0].ListenerArn s.Update("Found existing listener (ARN: %q)", listenerResource.Arn) diff --git a/builtin/aws/ecs/plugin.pb.go b/builtin/aws/ecs/plugin.pb.go index 4ed6cb8fc12..712212054e8 100644 --- a/builtin/aws/ecs/plugin.pb.go +++ b/builtin/aws/ecs/plugin.pb.go @@ -26,13 +26,20 @@ type Deployment struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` - TaskArn string `protobuf:"bytes,2,opt,name=task_arn,json=taskArn,proto3" json:"task_arn,omitempty"` - ServiceArn string `protobuf:"bytes,3,opt,name=service_arn,json=serviceArn,proto3" json:"service_arn,omitempty"` - TargetGroupArn string `protobuf:"bytes,4,opt,name=target_group_arn,json=targetGroupArn,proto3" json:"target_group_arn,omitempty"` - LoadBalancerArn string `protobuf:"bytes,5,opt,name=load_balancer_arn,json=loadBalancerArn,proto3" json:"load_balancer_arn,omitempty"` - Cluster string `protobuf:"bytes,6,opt,name=cluster,proto3" json:"cluster,omitempty"` - ResourceState *opaqueany.Any `protobuf:"bytes,7,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + TaskArn string `protobuf:"bytes,2,opt,name=task_arn,json=taskArn,proto3" json:"task_arn,omitempty"` + ServiceArn string `protobuf:"bytes,3,opt,name=service_arn,json=serviceArn,proto3" json:"service_arn,omitempty"` + TargetGroupArn string `protobuf:"bytes,4,opt,name=target_group_arn,json=targetGroupArn,proto3" json:"target_group_arn,omitempty"` + // Reference to the load balancer. Either the LB itself (if we created it), + // or the lb listener if the user specified it. + // + // Types that are assignable to LbReference: + // + // *Deployment_LoadBalancerArn + // *Deployment_ListenerArn + LbReference isDeployment_LbReference `protobuf_oneof:"lb_reference"` + Cluster string `protobuf:"bytes,6,opt,name=cluster,proto3" json:"cluster,omitempty"` + ResourceState *opaqueany.Any `protobuf:"bytes,7,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` } func (x *Deployment) Reset() { @@ -95,13 +102,27 @@ func (x *Deployment) GetTargetGroupArn() string { return "" } +func (m *Deployment) GetLbReference() isDeployment_LbReference { + if m != nil { + return m.LbReference + } + return nil +} + func (x *Deployment) GetLoadBalancerArn() string { - if x != nil { + if x, ok := x.GetLbReference().(*Deployment_LoadBalancerArn); ok { return x.LoadBalancerArn } return "" } +func (x *Deployment) GetListenerArn() string { + if x, ok := x.GetLbReference().(*Deployment_ListenerArn); ok { + return x.ListenerArn + } + return "" +} + func (x *Deployment) GetCluster() string { if x != nil { return x.Cluster @@ -116,6 +137,22 @@ func (x *Deployment) GetResourceState() *opaqueany.Any { return nil } +type isDeployment_LbReference interface { + isDeployment_LbReference() +} + +type Deployment_LoadBalancerArn struct { + LoadBalancerArn string `protobuf:"bytes,5,opt,name=load_balancer_arn,json=loadBalancerArn,proto3,oneof"` +} + +type Deployment_ListenerArn struct { + ListenerArn string `protobuf:"bytes,8,opt,name=listener_arn,json=listenerArn,proto3,oneof"` +} + +func (*Deployment_LoadBalancerArn) isDeployment_LbReference() {} + +func (*Deployment_ListenerArn) isDeployment_LbReference() {} + type Release struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1243,7 +1280,7 @@ var file_waypoint_builtin_aws_ecs_plugin_proto_rawDesc = []byte{ 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x65, 0x63, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x65, 0x63, 0x73, 0x1a, 0x13, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x81, 0x02, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x6f, 0x22, 0xb8, 0x02, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x41, 0x72, 0x6e, 0x12, 0x1f, 0x0a, @@ -1251,107 +1288,110 @@ var file_waypoint_builtin_aws_ecs_plugin_proto_rawDesc = []byte{ 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x72, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x6f, 0x61, 0x64, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, 0x12, 0x2c, 0x0a, 0x11, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, - 0x72, 0x41, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x35, - 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, - 0x6e, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x47, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x72, 0x6c, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, - 0x63, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, - 0x6f, 0x61, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x22, 0xb1, - 0x0a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, 0x2f, 0x0a, 0x07, 0x43, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x1a, 0x4f, 0x0a, 0x0d, - 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x12, 0x0a, + 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0f, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x12, 0x23, 0x0a, 0x0c, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, + 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, + 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x42, 0x0e, 0x0a, 0x0c, + 0x6c, 0x62, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x47, 0x0a, 0x07, + 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x6f, 0x61, + 0x64, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, + 0x65, 0x72, 0x41, 0x72, 0x6e, 0x22, 0xb1, 0x0a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x1a, 0x2f, 0x0a, 0x07, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x61, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x4a, 0x0a, - 0x08, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, - 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x49, 0x0a, 0x07, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x61, 0x72, 0x6e, 0x1a, 0x4f, 0x0a, 0x0d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x1a, 0x47, 0x0a, 0x0b, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x30, 0x0a, - 0x08, 0x4c, 0x6f, 0x67, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, - 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x1a, - 0x4d, 0x0a, 0x0d, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x64, 0x1a, 0x4a, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x6f, 0x6c, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, + 0x1a, 0x49, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, + 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x1a, 0x47, 0x0a, 0x0b, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, + 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, + 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x30, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x5e, - 0x0a, 0x16, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x44, 0x0a, 0x0f, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0e, - 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x1a, 0x5e, - 0x0a, 0x16, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x44, 0x0a, 0x0f, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0e, - 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x1a, 0x3d, - 0x0a, 0x0a, 0x41, 0x6c, 0x62, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x07, - 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, - 0x6e, 0x65, 0x74, 0x73, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x1a, 0x41, 0x0a, - 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x12, - 0x2f, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x15, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, - 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, - 0x1a, 0x72, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x12, 0x36, 0x0a, 0x07, 0x73, - 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, - 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, 0x6e, - 0x65, 0x74, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6e, - 0x65, 0x74, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x70, 0x63, 0x49, 0x64, 0x1a, 0x18, 0x0a, 0x06, 0x53, 0x75, - 0x62, 0x6e, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x1a, 0x8f, 0x02, 0x0a, 0x03, 0x41, 0x6c, 0x62, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x1a, 0x4d, 0x0a, 0x0d, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, + 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x5e, 0x0a, 0x16, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, + 0x44, 0x0a, 0x0f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x73, 0x1a, 0x5e, 0x0a, 0x16, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, + 0x44, 0x0a, 0x0f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x73, 0x1a, 0x3d, 0x0a, 0x0a, 0x41, 0x6c, 0x62, 0x53, 0x75, 0x62, 0x6e, + 0x65, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x52, 0x07, 0x73, 0x75, 0x62, + 0x6e, 0x65, 0x74, 0x73, 0x1a, 0x41, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, + 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x52, 0x07, + 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x1a, 0x72, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x6e, 0x65, + 0x74, 0x73, 0x12, 0x36, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x6e, 0x65, + 0x74, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x70, + 0x63, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x70, 0x63, 0x49, + 0x64, 0x1a, 0x18, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x1a, 0x8f, 0x02, 0x0a, 0x03, + 0x41, 0x6c, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x64, 0x6e, 0x73, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x6e, 0x73, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x63, 0x61, 0x6e, 0x6f, 0x6e, 0x69, 0x63, 0x61, + 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x61, 0x6e, 0x6f, 0x6e, 0x69, 0x63, 0x61, + 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x65, 0x64, 0x5a, 0x6f, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x74, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x65, + 0x6e, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x3c, 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x63, + 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0b, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x3c, 0x0a, + 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, + 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x3c, 0x0a, 0x0d, 0x52, + 0x6f, 0x75, 0x74, 0x65, 0x35, 0x33, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, - 0x72, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x64, 0x6e, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, - 0x18, 0x63, 0x61, 0x6e, 0x6f, 0x6e, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x65, - 0x64, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x15, 0x63, 0x61, 0x6e, 0x6f, 0x6e, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x65, 0x64, - 0x5a, 0x6f, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, - 0x1a, 0x74, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, - 0x61, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x3c, - 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, - 0x0b, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x1a, 0x3c, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x65, - 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x72, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, - 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x3c, 0x0a, 0x0d, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x35, 0x33, 0x52, - 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x7a, 0x6f, 0x6e, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x7a, 0x6f, 0x6e, 0x65, - 0x49, 0x64, 0x22, 0x1a, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x42, 0x1a, - 0x5a, 0x18, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, - 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x65, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x12, 0x17, 0x0a, 0x07, 0x7a, 0x6f, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x7a, 0x6f, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x1a, 0x0a, 0x08, 0x54, 0x61, 0x73, + 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x42, 0x1a, 0x5a, 0x18, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x65, 0x63, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1665,6 +1705,10 @@ func file_waypoint_builtin_aws_ecs_plugin_proto_init() { } } } + file_waypoint_builtin_aws_ecs_plugin_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Deployment_LoadBalancerArn)(nil), + (*Deployment_ListenerArn)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/builtin/aws/ecs/plugin.proto b/builtin/aws/ecs/plugin.proto index bca41f7ed2c..63e36c1d378 100644 --- a/builtin/aws/ecs/plugin.proto +++ b/builtin/aws/ecs/plugin.proto @@ -11,7 +11,14 @@ message Deployment { string task_arn = 2; string service_arn = 3; string target_group_arn = 4; - string load_balancer_arn = 5; + + // Reference to the load balancer. Either the LB itself (if we created it), + // or the lb listener if the user specified it. + oneof lb_reference { + string load_balancer_arn = 5; + string listener_arn = 8; + } + string cluster = 6; opaqueany.Any resource_state = 7; } diff --git a/builtin/aws/ecs/releaser.go b/builtin/aws/ecs/releaser.go index bd7ce4c50f2..a7c36870636 100644 --- a/builtin/aws/ecs/releaser.go +++ b/builtin/aws/ecs/releaser.go @@ -7,6 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elbv2" "github.com/hashicorp/go-hclog" + "github.com/pkg/errors" + "github.com/hashicorp/waypoint-plugin-sdk/component" "github.com/hashicorp/waypoint-plugin-sdk/docs" "github.com/hashicorp/waypoint-plugin-sdk/terminal" @@ -37,8 +39,9 @@ func (r *Releaser) Release( ui terminal.UI, target *Deployment, ) (*Release, error) { - if target.LoadBalancerArn == "" && target.TargetGroupArn == "" { - log.Info("No load-balancer configured") + + if target.TargetGroupArn == "" { + log.Info("No target group configured, skipping release") return &Release{}, nil } @@ -51,30 +54,11 @@ func (r *Releaser) Release( } elbsrv := elbv2.New(sess) - dlb, err := elbsrv.DescribeLoadBalancers(&elbv2.DescribeLoadBalancersInput{ - LoadBalancerArns: []*string{&target.LoadBalancerArn}, - }) - if err != nil { - return nil, err - } - - var lb *elbv2.LoadBalancer - - if len(dlb.LoadBalancers) == 0 { - return nil, fmt.Errorf("No load balancers returned by DescribeLoadBalancers") - } - - lb = dlb.LoadBalancers[0] - - listeners, err := elbsrv.DescribeListeners(&elbv2.DescribeListenersInput{ - LoadBalancerArn: lb.LoadBalancerArn, - }) - if err != nil { - return nil, err + var hostname string + if r.p.config.ALB != nil && r.p.config.ALB.FQDN != "" { + hostname = r.p.config.ALB.FQDN } - var listener *elbv2.Listener - tgs := []*elbv2.TargetGroupTuple{ { TargetGroupArn: &target.TargetGroupArn, @@ -82,12 +66,107 @@ func (r *Releaser) Release( }, } - log.Debug("configuring weight 100 for target group", "arn", target.TargetGroupArn) + // existingListener, if discovered, will be modified to introduce the new target group. + var existingListener *elbv2.Listener + var lbArn string + + switch lbRef := target.LbReference.(type) { + case *Deployment_LoadBalancerArn: + // We have a load balancer. Either discover the existing listener, or create a new one. + lbArn = lbRef.LoadBalancerArn + + dlb, err := elbsrv.DescribeLoadBalancers(&elbv2.DescribeLoadBalancersInput{ + LoadBalancerArns: []*string{&lbRef.LoadBalancerArn}, + }) + if err != nil { + return nil, errors.Wrapf(err, "failed to describe load balancer %q", lbRef.LoadBalancerArn) + } + + var lb *elbv2.LoadBalancer + + if len(dlb.LoadBalancers) == 0 { + return nil, fmt.Errorf("no load balancers returned by DescribeLoadBalancers") + } - if len(listeners.Listeners) > 0 { - listener = listeners.Listeners[0] + lb = dlb.LoadBalancers[0] - def := listener.DefaultActions + // Now that we have the LB, set the hostname if necessary + if hostname == "" { + hostname = *lb.DNSName + } + + listeners, err := elbsrv.DescribeListeners(&elbv2.DescribeListenersInput{ + LoadBalancerArn: lb.LoadBalancerArn, + }) + if err != nil { + return nil, errors.Wrapf(err, "failed to describe listener for lb %q", lb.LoadBalancerArn) + } + + if len(listeners.Listeners) > 0 { + if len(listeners.Listeners) > 1 { + log.Warn("ALB has multiple listeners - only modifying the first listaner and ignoring all others") + } + existingListener = listeners.Listeners[0] + } else { + log.Info("load-balancer defined", "dns-name", *lb.DNSName) + + _, err := elbsrv.CreateListener(&elbv2.CreateListenerInput{ + LoadBalancerArn: lb.LoadBalancerArn, + Port: aws.Int64(80), + Protocol: aws.String("HTTP"), + DefaultActions: []*elbv2.Action{ + { + ForwardConfig: &elbv2.ForwardActionConfig{ + TargetGroups: tgs, + }, + Type: aws.String("forward"), + }, + }, + }) + + if err != nil { + return nil, errors.Wrapf(err, "failed to create listener") + } + + // Do not set existingListener + } + + case *Deployment_ListenerArn: + lo, err := elbsrv.DescribeListeners(&elbv2.DescribeListenersInput{ + ListenerArns: []*string{&lbRef.ListenerArn}, + }) + if err != nil { + return nil, errors.Wrapf(err, "failed to describe listener %q", lbRef.ListenerArn) + } + if len(lo.Listeners) == 0 { + return nil, errors.Errorf("listener %q not found", lbRef.ListenerArn) + } + existingListener = lo.Listeners[0] + lbArn = *existingListener.LoadBalancerArn + + if hostname == "" { + // We need to get the hostname from the existing alb + + dlb, err := elbsrv.DescribeLoadBalancers(&elbv2.DescribeLoadBalancersInput{ + LoadBalancerArns: []*string{existingListener.LoadBalancerArn}, + }) + if err != nil { + return nil, errors.Wrapf(err, "failed to describe load balancer for listener %q", *existingListener.LoadBalancerArn) + } + + if len(dlb.LoadBalancers) == 0 { + return nil, fmt.Errorf("no load balancers returned by DescribeLoadBalancers") + } + + hostname = *dlb.LoadBalancers[0].DNSName + } + + } + + if existingListener != nil { + log.Debug("configuring weight 100 for target group", "arn", target.TargetGroupArn) + + def := existingListener.DefaultActions if len(def) > 0 && def[0].ForwardConfig != nil { for _, tg := range def[0].ForwardConfig.TargetGroups { @@ -104,9 +183,9 @@ func (r *Releaser) Release( log.Debug("modifying load balancer", "tgs", len(tgs)) _, err = elbsrv.ModifyListener(&elbv2.ModifyListenerInput{ - ListenerArn: listener.ListenerArn, - Port: listener.Port, - Protocol: listener.Protocol, + ListenerArn: existingListener.ListenerArn, + Port: existingListener.Port, + Protocol: existingListener.Protocol, DefaultActions: []*elbv2.Action{ { ForwardConfig: &elbv2.ForwardActionConfig{ @@ -117,41 +196,13 @@ func (r *Releaser) Release( }, }) if err != nil { - return nil, err + return nil, errors.Wrapf(err, "failed to modify listener %q to introduce new target group", existingListener.ListenerArn) } - } else { - log.Info("load-balancer defined", "dns-name", *lb.DNSName) - - lo, err := elbsrv.CreateListener(&elbv2.CreateListenerInput{ - LoadBalancerArn: lb.LoadBalancerArn, - Port: aws.Int64(80), - Protocol: aws.String("HTTP"), - DefaultActions: []*elbv2.Action{ - { - ForwardConfig: &elbv2.ForwardActionConfig{ - TargetGroups: tgs, - }, - Type: aws.String("forward"), - }, - }, - }) - - if err != nil { - return nil, err - } - - listener = lo.Listeners[0] - } - - hostname := *lb.DNSName - - if r.p.config.ALB != nil && r.p.config.ALB.FQDN != "" { - hostname = r.p.config.ALB.FQDN } return &Release{ Url: "http://" + hostname, - LoadBalancerArn: *lb.LoadBalancerArn, + LoadBalancerArn: lbArn, }, nil } From bdca39ab19ad2ec4e9a87bbfedb42cef87386e5a Mon Sep 17 00:00:00 2001 From: Izaak Lauer <8404559+izaaklauer@users.noreply.github.com> Date: Wed, 25 Jan 2023 17:53:07 -0500 Subject: [PATCH 2/3] changelog --- .changelog/4453.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/4453.txt diff --git a/.changelog/4453.txt b/.changelog/4453.txt new file mode 100644 index 00000000000..64b68faaaf0 --- /dev/null +++ b/.changelog/4453.txt @@ -0,0 +1,3 @@ +```release-note:bug +plugin/aws-ecs: Fix bringing your own alb listener to ecs deployments. +``` From d7134a16f3e9b9874946c3edf64f93a51e04cc9e Mon Sep 17 00:00:00 2001 From: Izaak Lauer <8404559+izaaklauer@users.noreply.github.com> Date: Wed, 25 Jan 2023 17:53:14 -0500 Subject: [PATCH 3/3] docs --- embedJson/gen/platform-aws-ecs.json | 4 ++-- website/content/partials/components/platform-aws-ecs.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/embedJson/gen/platform-aws-ecs.json b/embedJson/gen/platform-aws-ecs.json index 037f55d3d25..d3a95ffa249 100644 --- a/embedJson/gen/platform-aws-ecs.json +++ b/embedJson/gen/platform-aws-ecs.json @@ -334,8 +334,8 @@ "SubFields": null }, { - "Field": "load_balancer_arn", - "Type": "string", + "Field": "lb_reference", + "Type": "ecs.isDeployment_LbReference", "Synopsis": "", "Summary": "", "Optional": false, diff --git a/website/content/partials/components/platform-aws-ecs.mdx b/website/content/partials/components/platform-aws-ecs.mdx index 60b10eb2125..ba415281f88 100644 --- a/website/content/partials/components/platform-aws-ecs.mdx +++ b/website/content/partials/components/platform-aws-ecs.mdx @@ -387,9 +387,9 @@ Output attributes can be used in your `waypoint.hcl` as [variables](/waypoint/do - Type: **string** -#### load_balancer_arn +#### lb_reference -- Type: **string** +- Type: **ecs.isDeployment_LbReference** #### resource_state