diff --git a/cmd/daemon/kubernetes/kubernetes.go b/cmd/daemon/kubernetes/kubernetes.go index 99a8c2c8..39b51bb9 100644 --- a/cmd/daemon/kubernetes/kubernetes.go +++ b/cmd/daemon/kubernetes/kubernetes.go @@ -81,6 +81,7 @@ const ( artifactIDAnnotationKey = "lunarway.com/artifact-id" authorAnnotationKey = "lunarway.com/author" controlledAnnotationKey = "lunarway.com/controlled-by-release-manager" + squadLabelKey = "squad" ) func observe(annotations map[string]string) { diff --git a/cmd/daemon/kubernetes/pods.go b/cmd/daemon/kubernetes/pods.go index 2ea2545e..17d49203 100644 --- a/cmd/daemon/kubernetes/pods.go +++ b/cmd/daemon/kubernetes/pods.go @@ -70,8 +70,7 @@ func (p *PodInformer) handle(e interface{}) { pod.Name) return } - - log.Infof("Pod: %s is in CrashLoopBackOff", pod.Name) + log.Infof("Pod: %s is in CrashLoopBackOff owned by squad %s", pod.Name, getCodeOwnerSquad) restartCount := pod.Status.ContainerStatuses[0].RestartCount if math.Mod(float64(restartCount), p.moduloCrashReportNotif) != 1 { return @@ -99,6 +98,7 @@ func (p *PodInformer) handle(e interface{}) { Errors: errorContainers, ArtifactID: pod.Annotations[artifactIDAnnotationKey], AuthorEmail: pod.Annotations[authorAnnotationKey], + Squad: getCodeOwnerSquad(pod.Annotations), }) if err != nil { log.Errorf("Failed to send crash loop backoff event: %v", err) @@ -265,3 +265,10 @@ func parseToJSONAray(str string) ([]ContainerLog, error) { } return logs, nil } + +func getCodeOwnerSquad(annotations map[string]string) string { + if squad, ok := annotations[squadLabelKey]; ok { + return squad + } + return "no-one" +} diff --git a/internal/http/types.go b/internal/http/types.go index 5e19040e..c7634540 100644 --- a/internal/http/types.go +++ b/internal/http/types.go @@ -96,6 +96,7 @@ type PodErrorEvent struct { AuthorEmail string `json:"authorEmail,omitempty"` Environment string `json:"environment,omitempty"` ArtifactID string `json:"artifactId,omitempty"` + Squad string `json:"squad,omitempty"` } type JobConditionError struct {