Skip to content

Commit

Permalink
Merge pull request #21157 from chaodaiG/fix-invalid-label
Browse files Browse the repository at this point in the history
Gerrit label processing: include job name and id in debug logs
  • Loading branch information
k8s-ci-robot authored Mar 4, 2021
2 parents 2ee80ae + 8e40e43 commit 1913db7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions prow/pod-utils/decorate/podspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ func PodUtilsContainerNames() sets.String {
// User-provided extraLabels and extraAnnotations values will take precedence over auto-provided values.
func LabelsAndAnnotationsForSpec(spec prowapi.ProwJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string) {
jobNameForLabel := spec.Job
log := logrus.WithFields(logrus.Fields{
"job": spec.Job,
"id": extraLabels[kube.ProwBuildIDLabel],
})
if len(jobNameForLabel) > validation.LabelValueMaxLength {
// TODO(fejta): consider truncating middle rather than end.
jobNameForLabel = strings.TrimRight(spec.Job[:validation.LabelValueMaxLength], ".-")
logrus.WithFields(logrus.Fields{
"job": spec.Job,
log.WithFields(logrus.Fields{
"key": kube.ProwJobAnnotation,
"value": spec.Job,
"truncated": jobNameForLabel,
Expand Down Expand Up @@ -128,7 +131,7 @@ func LabelsAndAnnotationsForSpec(spec prowapi.ProwJobSpec, extraLabels, extraAnn
labels[key] = base
continue
}
logrus.WithFields(logrus.Fields{
log.WithFields(logrus.Fields{
"key": key,
"value": value,
"errors": errs,
Expand Down

0 comments on commit 1913db7

Please sign in to comment.