Skip to content

Commit

Permalink
pipeline: include shard name in holiday message
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Jan 16, 2024
1 parent ea2278b commit 9d3ed8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions internal/pipeline/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (xfagg *aggregator) notifyAboutHoliday(day *schedule.Day) {
}

err = ss.Info(ctx, &notify.Message{
Contents: formatHolidayMessage(day),
Contents: formatHolidayMessage(day, xfagg.shard.Name),
})
if err != nil {
logger.Error().LogErrorf("ERROR sending holiday notification: %v", err)
Expand All @@ -404,15 +404,19 @@ func (xfagg *aggregator) notifyAboutHoliday(day *schedule.Day) {
}
}

func formatHolidayMessage(day *schedule.Day) string {
func formatHolidayMessage(day *schedule.Day, shardName string) string {
name := "is a holiday"
if day != nil && day.Holiday != nil {
name = fmt.Sprintf("(%s) is a holiday", day.Holiday.Name)
}

hostname, _ := os.Hostname()

return fmt.Sprintf("%s %s so %s will skip processing", day.Time.Format("Jan 02"), name, hostname)
if shardName != "" {
shardName = fmt.Sprintf("for %s", shardName)
}

return strings.TrimSpace(fmt.Sprintf("%s %s so %s will skip processing %s", day.Time.Format("Jan 02"), name, hostname, shardName))
}

func (xfagg *aggregator) alertOnError(err error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/pipeline/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ func TestHolidayMessage(t *testing.T) {
}

hostname, _ := os.Hostname()
expected := fmt.Sprintf("Dec 25 (Christmas Day) is a holiday so %s will skip processing", hostname)
expected := fmt.Sprintf("Dec 25 (Christmas Day) is a holiday so %s will skip processing for sd-live", hostname)

message := formatHolidayMessage(day)
message := formatHolidayMessage(day, "sd-live")
require.Equal(t, expected, message)
}

0 comments on commit 9d3ed8b

Please sign in to comment.