Skip to content

Commit

Permalink
[#3624] Worker monitor should not get LogGroup from Rack API service
Browse files Browse the repository at this point in the history
### What is the feature/fix?

Since the Monitor and Web API had their name changed to include in the beginning, the worker was mistakenly assuming that the stack was from an app.

The monitor worker should only get the LogGroup from service apps.

### Does it has a breaking change?

No.

### How to use/test it?

Install the RC and run `convox rack logs`, it shouldn't show any error.

### Checklist
- [ ] New coverage tests
- [x] Unit tests passing
- [ ] E2E tests passing
- [ ] E2E downgrade/update test passing
- [ ] Documentation updated
- [x] No warnings or errors on Deepsource/Codecov
  • Loading branch information
Twsouza committed Dec 16, 2022
1 parent 5205432 commit 8036200
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Provider struct {
Private bool
PrivateBuild bool
Rack string
RackApiServiceName string
SecurityGroup string
SettingsBucket string
SshKey string
Expand Down Expand Up @@ -166,6 +167,7 @@ func (p *Provider) loadParams() error {
p.OnDemandMinCount = intParam(labels["rack.OnDemandMinCount"], 2)
p.Private = labels["rack.Private"] == "Yes"
p.PrivateBuild = labels["rack.PrivateBuild"] == "Yes"
p.RackApiServiceName = strings.ReplaceAll(labels["rack.RackApiServiceName"], ",", "|")
p.SecurityGroup = labels["rack.SecurityGroup"]
p.SettingsBucket = labels["rack.SettingsBucket"]
p.SpotInstances = labels["rack.SpotInstances"] == "Yes"
Expand Down
1 change: 1 addition & 0 deletions provider/aws/formation/rack.json
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,7 @@
"rack.OnDemandMinCount": { "Ref": "OnDemandMinCount" },
"rack.Private": { "Ref": "Private" },
"rack.PrivateBuild": { "Ref": "PrivateBuild" },
"rack.RackApiServiceName": "ServiceMonitorApi,ServiceWebApi",
"rack.SecurityGroup": { "Fn::If": [ "BlankInstanceSecurityGroup", { "Ref": "InstancesSecurity" }, { "Ref": "InstanceSecurityGroup" } ] },
"rack.SettingsBucket": { "Ref": "Settings" },
"rack.SpotInstances": { "Fn::If": [ "SpotInstances", "Yes", "No" ] },
Expand Down
4 changes: 3 additions & 1 deletion provider/aws/workers_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"regexp"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -173,6 +174,7 @@ func (p *Provider) handleECSEvents() {

func (p *Provider) pollECSEvents() error {
prefix := fmt.Sprintf("%s-", p.Rack)
isRackApiServiceRegex := regexp.MustCompile(p.RackApiServiceName)

lreq := &ecs.ListServicesInput{
Cluster: aws.String(p.Cluster),
Expand All @@ -195,7 +197,7 @@ func (p *Provider) pollECSEvents() error {
for _, s := range sres.Services {
name := *s.ServiceName

if !strings.HasPrefix(name, prefix) || !strings.Contains(name, "-Service") {
if !strings.HasPrefix(name, prefix) || !strings.Contains(name, "-Service") || isRackApiServiceRegex.MatchString(name) {
continue
}

Expand Down

0 comments on commit 8036200

Please sign in to comment.