Skip to content

[ACIX-470] Create a top-level invoke task for running all gitlabci linters #37690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Ishirui
Copy link
Contributor

@Ishirui Ishirui commented Jun 5, 2025

What does this PR do?

Building upon the work of #37417, continue refactoring the set of invoke tasks used for linting gitlabci-related in files in the agent repo. Notable refactoring changes include:

  • Moving a lot of the task logic to tasks/libs/linter from the main linter.py file, leaving only the absolutely necessary parts in linter.py
  • Unify the way tasks run on config diffs/full config objects/lists of jobs - before, each task had very different interfaces which was quite confusing. Now they can all be called in the same way and use similarly-built main inputs.
  • Create a more robust system for handling and "bubbling up" linting failures to the top-level task, which allows each task to handle displaying failures as it prefers.

This PR also adds a new top-level task, full-gitlab-ci, that runs all the gitlabci-related linters together, sharing a preconfigured configuration object which takes a while to compute.
This new task is now run both in CI and as a pre-push hook, which increases the safety of gitlabci modifications.

Motivation

We had a few linters for gitlabci that were only run manually, which is wasteful - we should run them in CI and/or as a pre-push. The issue is that a couple of these require a "fully-resolved" gitlabci configuration file as input, and computing that takes a while. Therefore it is critical that we do not compute this configuration file multiple times, which is easier if we use one single task grouping all the "sublinters".

Describe how you validated your changes

Running all linters, also with failing examples + unit tests and in CI.

Possible Drawbacks / Trade-offs

Performance: we are now running more linters, especially as a pre-push, which makes it quite a bit slower. This might make changes to gitlabci files more frustrating to make as the pre-push hook that is run when modifying them is quite a bit slower than it was before.

Additional Notes

@Ishirui Ishirui self-assigned this Jun 5, 2025
@Ishirui Ishirui added changelog/no-changelog qa/no-code-change No code change in Agent code requiring validation labels Jun 5, 2025
@github-actions github-actions bot added the long review PR is complex, plan time to review it label Jun 5, 2025
Copy link

cit-pr-commenter bot commented Jun 5, 2025

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 9a00b51d-1b3a-4a19-a0bc-1e9e7fae362f

Baseline: 9218271
Comparison: 1e9bb89
Diff

Optimization Goals: ✅ Improvement(s) detected

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization -6.01 [-9.00, -3.02] 1 Logs
quality_gate_logs % cpu utilization -7.34 [-10.01, -4.67] 1 Logs bounds checks dashboard

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_idle_all_features memory utilization +0.37 [+0.30, +0.44] 1 Logs bounds checks dashboard
ddot_metrics memory utilization +0.36 [+0.24, +0.47] 1 Logs
file_to_blackhole_0ms_latency egress throughput +0.07 [-0.50, +0.63] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.07 [-0.52, +0.65] 1 Logs
file_to_blackhole_0ms_latency_http1 egress throughput +0.05 [-0.52, +0.62] 1 Logs
uds_dogstatsd_to_api ingress throughput +0.02 [-0.26, +0.29] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.02 [-0.64, +0.67] 1 Logs
otlp_ingest_metrics memory utilization +0.01 [-0.15, +0.17] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.02] 1 Logs
file_to_blackhole_300ms_latency egress throughput -0.00 [-0.60, +0.60] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.03 [-0.62, +0.57] 1 Logs
file_to_blackhole_1000ms_latency_linear_load egress throughput -0.03 [-0.26, +0.20] 1 Logs
file_to_blackhole_0ms_latency_http2 egress throughput -0.08 [-0.68, +0.53] 1 Logs
docker_containers_memory memory utilization -0.13 [-0.21, -0.05] 1 Logs
otlp_ingest_logs memory utilization -0.25 [-0.38, -0.12] 1 Logs
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization -0.30 [-0.34, -0.25] 1 Logs
ddot_logs memory utilization -0.48 [-0.62, -0.34] 1 Logs
tcp_syslog_to_blackhole ingress throughput -0.60 [-0.65, -0.55] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization -0.64 [-1.52, +0.23] 1 Logs
quality_gate_idle memory utilization -0.76 [-0.82, -0.69] 1 Logs bounds checks dashboard
file_tree memory utilization -0.89 [-1.03, -0.76] 1 Logs
docker_containers_cpu % cpu utilization -6.01 [-9.00, -3.02] 1 Logs
quality_gate_logs % cpu utilization -7.34 [-10.01, -4.67] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
docker_containers_cpu simple_check_run 10/10
docker_containers_memory memory_usage 10/10
docker_containers_memory simple_check_run 10/10
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_0ms_latency_http1 lost_bytes 10/10
file_to_blackhole_0ms_latency_http1 memory_usage 10/10
file_to_blackhole_0ms_latency_http2 lost_bytes 10/10
file_to_blackhole_0ms_latency_http2 memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency_linear_load memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_300ms_latency lost_bytes 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10 bounds checks dashboard
quality_gate_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_logs memory_usage 10/10 bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Jun 5, 2025

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 9218271

Successful checks

Info

Quality gate Delta On disk size (MiB) Delta On wire size (MiB)
agent_deb_amd64 $${0}$$ $${696.14}$$ < $${752.99}$$ $${+0.02}$$ $${175.98}$$ < $${187.44}$$
agent_deb_amd64_fips $${0}$$ $${694.36}$$ < $${751.36}$$ $${-0.01}$$ $${175.55}$$ < $${187.06}$$
agent_heroku_amd64 $${0}$$ $${358.51}$$ < $${369.68}$$ $${-0}$$ $${96.49}$$ < $${99.55}$$
agent_msi $${0}$$ $${958.04}$$ < $${987.01}$$ $${+0.01}$$ $${146.2}$$ < $${150.72}$$
agent_rpm_amd64 $${0}$$ $${696.13}$$ < $${752.98}$$ $${-0}$$ $${177.58}$$ < $${190.03}$$
agent_rpm_amd64_fips $${0}$$ $${694.35}$$ < $${751.35}$$ $${+0.06}$$ $${177.51}$$ < $${189.81}$$
agent_rpm_arm64 $${0}$$ $${686.15}$$ < $${739.42}$$ $${-0}$$ $${161.06}$$ < $${171.23}$$
agent_rpm_arm64_fips $${0}$$ $${684.49}$$ < $${737.91}$$ $${+0.01}$$ $${160.12}$$ < $${170.22}$$
agent_suse_amd64 $${0}$$ $${696.13}$$ < $${752.98}$$ $${-0}$$ $${177.58}$$ < $${190.03}$$
agent_suse_amd64_fips $${0}$$ $${694.35}$$ < $${751.35}$$ $${+0.06}$$ $${177.51}$$ < $${189.81}$$
agent_suse_arm64 $${0}$$ $${686.15}$$ < $${739.42}$$ $${-0}$$ $${161.06}$$ < $${171.23}$$
agent_suse_arm64_fips $${0}$$ $${684.49}$$ < $${737.91}$$ $${+0.01}$$ $${160.12}$$ < $${170.22}$$
docker_agent_amd64 $${+0}$$ $${779.93}$$ < $${849.39}$$ $${-0}$$ $${268.61}$$ < $${288.34}$$
docker_agent_arm64 $${0}$$ $${793.4}$$ < $${858.97}$$ $${-0}$$ $${255.99}$$ < $${274.36}$$
docker_agent_jmx_amd64 $${+0}$$ $${971.12}$$ < $${1040.59}$$ $${+0}$$ $${337.56}$$ < $${357.3}$$
docker_agent_jmx_arm64 $${+0}$$ $${973.19}$$ < $${1038.77}$$ $${+0}$$ $${320.93}$$ < $${339.32}$$
docker_agent_windows1809 $${-0}$$ $${1486.18}$$ < $${1557.19}$$ $${-0.01}$$ $${487.77}$$ < $${507.33}$$
docker_agent_windows1809_core $${+0.01}$$ $${6216.15}$$ < $${6287.46}$$ $${0}$$ $${2048.0}$$ < $${2067.76}$$
docker_agent_windows1809_core_jmx $${+0}$$ $${6337.71}$$ < $${6409.04}$$ $${0}$$ $${2048.0}$$ < $${2067.76}$$
docker_agent_windows1809_jmx $${-0}$$ $${1607.81}$$ < $${1679.14}$$ $${+0.03}$$ $${530.04}$$ < $${550.27}$$
docker_agent_windows2022 $${-0.15}$$ $${1505.32}$$ < $${1576.85}$$ $${-0.05}$$ $${500.47}$$ < $${520.76}$$
docker_agent_windows2022_core $${+0.06}$$ $${6189.26}$$ < $${6260.53}$$ $${0}$$ $${2048.0}$$ < $${2067.76}$$
docker_agent_windows2022_core_jmx $${+0.27}$$ $${6311.11}$$ < $${6382.17}$$ $${0}$$ $${2048.0}$$ < $${2067.76}$$
docker_agent_windows2022_jmx $${+0.33}$$ $${1627.2}$$ < $${1698.2}$$ $${-0.02}$$ $${542.76}$$ < $${562.99}$$
docker_cluster_agent_amd64 $${-0}$$ $${212.79}$$ < $${259.73}$$ $${-0}$$ $${72.36}$$ < $${103.68}$$
docker_cluster_agent_arm64 $${0}$$ $${228.68}$$ < $${274.24}$$ $${+0}$$ $${68.64}$$ < $${98.45}$$
docker_cws_instrumentation_amd64 $${0}$$ $${7.08}$$ < $${7.12}$$ $${+0}$$ $${2.95}$$ < $${3.29}$$
docker_cws_instrumentation_arm64 $${0}$$ $${6.69}$$ < $${6.92}$$ $${+0}$$ $${2.7}$$ < $${3.07}$$
docker_dogstatsd_amd64 $${-0}$$ $${39.21}$$ < $${39.57}$$ $${-0}$$ $${15.11}$$ < $${15.76}$$
docker_dogstatsd_arm64 $${-0}$$ $${37.88}$$ < $${38.2}$$ $${-0}$$ $${14.54}$$ < $${14.83}$$
dogstatsd_deb_amd64 $${0}$$ $${30.44}$$ < $${31.52}$$ $${-0}$$ $${7.99}$$ < $${8.97}$$
dogstatsd_deb_arm64 $${0}$$ $${29.01}$$ < $${30.08}$$ $${+0}$$ $${6.94}$$ < $${7.92}$$
dogstatsd_rpm_amd64 $${0}$$ $${30.44}$$ < $${31.52}$$ $${+0}$$ $${8.0}$$ < $${8.98}$$
dogstatsd_suse_amd64 $${0}$$ $${30.44}$$ < $${31.52}$$ $${+0}$$ $${8.0}$$ < $${8.98}$$
iot_agent_deb_amd64 $${0}$$ $${50.31}$$ < $${60.17}$$ $${-0}$$ $${12.8}$$ < $${15.82}$$
iot_agent_deb_arm64 $${0}$$ $${47.78}$$ < $${56.94}$$ $${-0}$$ $${11.11}$$ < $${13.86}$$
iot_agent_deb_armhf $${0}$$ $${47.35}$$ < $${56.41}$$ $${+0}$$ $${11.18}$$ < $${13.86}$$
iot_agent_rpm_amd64 $${0}$$ $${50.31}$$ < $${60.18}$$ $${+0}$$ $${12.83}$$ < $${15.84}$$
iot_agent_rpm_arm64 $${0}$$ $${47.78}$$ < $${56.94}$$ $${-0}$$ $${11.13}$$ < $${13.76}$$
iot_agent_suse_amd64 $${0}$$ $${50.31}$$ < $${60.18}$$ $${+0}$$ $${12.83}$$ < $${15.84}$$

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Jun 5, 2025

Gitlab CI Configuration Changes

Added Jobs

test_and_lint_gitlab_configuration
test_and_lint_gitlab_configuration:
  image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-17-x64$CI_IMAGE_LINUX_GLIBC_2_17_X64_SUFFIX:$CI_IMAGE_LINUX_GLIBC_2_17_X64
  needs:
  - compute_gitlab_ci_config
  rules:
  - if: $CI_COMMIT_BRANCH == "main"
    when: never
  - if: $CI_COMMIT_BRANCH =~ /^[0-9]+\.[0-9]+\.x$/
    when: never
  - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
    when: never
  - if: $CI_COMMIT_TAG != null
    when: never
  - when: on_success
  script:
  - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_TOKEN write_api)
    || exit $?; export GITLAB_TOKEN
  - dda inv -- -e linter.full-gitlab-ci --configs-or-diff-file artifacts/after.gitlab-ci.yml
  - dda inv -- -e linter.ssm-parameters
  stage: .pre
  tags:
  - arch:amd64

Removed Jobs

  • lint_gitlab_ci_shellcheck
  • lint_gitlab_ci_jobs_codeowners
  • lint_gitlab_ci
  • test_gitlab_configuration

Changes Summary

Removed Modified Added Renamed
4 0 1 0

ℹ️ Diff available in the job log.

@Ishirui Ishirui marked this pull request as ready for review June 5, 2025 16:39
@Ishirui Ishirui requested a review from a team as a code owner June 5, 2025 16:39
@Ishirui Ishirui force-pushed the pierrelouis.veyrenc/ACIX-470-add-gitlab-ci-linters-to-pre-commit branch 2 times, most recently from e943537 to 8ca3a96 Compare June 6, 2025 12:50
@Ishirui Ishirui requested a review from CelianR June 10, 2025 16:48
Copy link
Contributor

@CelianR CelianR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gg! Minor suggestions

@Ishirui Ishirui force-pushed the pierrelouis.veyrenc/ACIX-470-add-gitlab-ci-linters-to-pre-commit branch from cdf7ace to 0b1b239 Compare June 11, 2025 12:32
@Ishirui Ishirui force-pushed the pierrelouis.veyrenc/ACIX-470-add-gitlab-ci-linters-to-pre-commit branch from d635800 to 80faed4 Compare June 11, 2025 13:14
Ishirui added 9 commits June 12, 2025 13:39
…ct_gitlab_ci_jobs`

We remove all the file loading functionality from this method and move it into the tasks themselves. This allows for better separation of concerns and also allows the new method to have a more clear purpose.
…full config

Since we will end up precomputing the diff anyway, this will make this check faster (less jobs to look through)
This also allows use to use non-task functions to accomplish linting on already-loaded config objects, which will be useful for creating the top-level linting task.
…if needed

fix(gitlab): Properly check for `diff is None`
…ists

This simplifies the logic of this function and also brings its interface in line with the rest of the linting methods, which take in lists of jobs instead of full config objects.

refactor(linter): Rename `check_change_paths_gitlab_ci_jobs` and `check_change_paths_gitlab_ci_config`

Make it clearer what the difference between the two is, and correctly say the second one handles jobs, not a full config
…ailures

The idea is to use Exceptions to make linting failures go back to top-level, that way each top-level task can customize how it handles/displays linting errors, instead of having `print` statements buried in "plumbing" functions (like the ones in `libs/`

feat(linter): Use new exception-based failure reporting mechanism for all linting tasks
When using the individual linting tasks we'll probably want to check all the jobs and not have to worry about the diff (it wouldn't really save much time anyway, generating the config or diff is what takes long)
Ishirui and others added 20 commits June 12, 2025 13:39
This allows us to centralize config options for linters near the actual method definition, and automatically register those linters for usage in `full_gitlab_ci`
- Minor code changes
- Remove CRITICAL failure level
- Add `--pre-push-linters` flag
- Run pre-push linters with `--fail-fast`
The tool is not installed on our runners yet, so it always fails
Co-authored-by: Célian Raimbault <161456554+CelianR@users.noreply.github.com>
@Ishirui Ishirui force-pushed the pierrelouis.veyrenc/ACIX-470-add-gitlab-ci-linters-to-pre-commit branch from 80faed4 to 1e9bb89 Compare June 12, 2025 11:41
@Ishirui
Copy link
Contributor Author

Ishirui commented Jun 12, 2025

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jun 12, 2025

View all feedbacks in Devflow UI.

2025-06-12 13:28:55 UTC ℹ️ Start processing command /merge


2025-06-12 13:29:09 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 52m (p90).


2025-06-12 14:09:38 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit 1101e86 into main Jun 12, 2025
273 checks passed
@dd-mergequeue dd-mergequeue bot deleted the pierrelouis.veyrenc/ACIX-470-add-gitlab-ci-linters-to-pre-commit branch June 12, 2025 14:09
@github-actions github-actions bot added this to the 7.68.0 milestone Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog long review PR is complex, plan time to review it qa/no-code-change No code change in Agent code requiring validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants