DataDog/datadog-ci

Mix of pipeline and job level tags does not tag GHA job

jmeickle-theaiinstitute opened this issue ยท 4 comments

Bug description

In Github Actions, when running this command in a job:

datadog-ci tag --level=pipeline --tags repro:dockerless &&
datadog-ci tag --level=job --tags jobrepro:dockerless-job

The Github Actions step output is:

Run datadog-ci tag --level=pipeline --tags repro:dockerless &&
  datadog-ci tag --level=pipeline --tags repro:dockerless &&
  datadog-ci tag --level=job --tags jobrepro:dockerless-job
  shell: bash --noprofile --norc -e -o pipefail {0}
  env:
   [REDACTED]
    DATADOG_API_KEY: ***
Run '/home/runner/k8s/index.js'
  shell: /home/runner/externals/node16/bin/node {0}
Tags sent
Tags sent

(That is, it runs twice successfully)

This is a case where we have one pipeline with two parallel jobs, both running these tagging commands. Using the example above, repro shows up as a tag on the pipeline but jobrepro does not show up as a tag on the job (in any run).

Describe what you expected

Either the datadog-ci tool should tag the data, or it should fail if this is an invalid usage

Steps to reproduce the issue

No response

Additional context

v2.33.1 of datadog-ci

Command

tag

Hi @jmeickle-theaiinstitute ! There are some limitations around adding custom tags to GitHub jobs.

We have some docs related to this. The TLDR is that if the job name is changed using the name property OR you're using a matrix strategy to define jobs you need to make expose a DD_GITHUB_JOB_NAME env variable pointing to the real job name.

Could this be whats going on here? ๐Ÿ‘€

datadog-ci tag --level job --tags pr_owner:<REDACTED>
  shell: /usr/bin/bash -e {0}
  env:
    PR_COMMENTS_ENABLED: false
    TAG: <REDACTED>
    DD_CIVISIBILITY_AGENTLESS_ENABLED: true
    DD_ENV: ci
    DD_SERVICE: fullstack
    DD_API_KEY: ***
    DD_GITHUB_JOB_NAME: Run e2e tests / Run E2E desktop on node 0
    DD_TAGS: pr_owner:<REDACTED>
    DATADOG_API_KEY: ***
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 59.2M  100 59.2M    0     0  [8]<REDACTED>
Tags sent

I've tried every possible combination of job name appearing anywhere in datadog or CICD. It's also silently failing to send tags to jobs which are not part of a matrix run. Both when tags are set as env variables, and when tags are attempted to be sent via datadog-ci, regardless of whether DD_GITHUB_JOB_NAME is provided or not provided.

[edit] Worth noting, my jobs are part of a reusable workflow triggered by a parent job

Hi @benjamin-cribb-jane , we recently had a bug that caused GitHub jobs' custom tags not to be added. We think that what might've happened is this:

  1. The first issue was due to the missing DD_GITHUB_JOB_NAME variable.
  2. We introduced a bug causing the GitHub jobs' custom tags behavior to break.
  3. You tried using the DD_GITHUB_JOB_NAME variable and it didn't work (likely due to the bug introduced at step 2).
  4. We fixed the bug introduced in step 2.
  • Could you try doing this one more time with the DD_GITHUB_JOB_NAME variable?
  • If you could also provide us an Org ID to look into this it'd be great.

Hopefully it works now! ๐Ÿคž

hey did you try those steps @benjamin-cribb-jane ? ๐Ÿ˜„