DDEV Validate DEP: Always set repo_choice if check_root is true#23649
DDEV Validate DEP: Always set repo_choice if check_root is true#23649ddog-nasirthomas wants to merge 2 commits into
Conversation
|
Didn't add a changelog, but let me know if it's needed |
Validation ReportAll 20 validations passed. Show details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 88a7809 | Docs | Datadog PR Page | Give us feedback! |
AAraKKe
left a comment
There was a problem hiding this comment.
Thanks for opening this and for digging into the failure.
I do not think this is the direction we want to take, though. The standard ddev path already resolves the active repo before commands run, through app.repo. That repo is selected from flags, config, env vars, and local overrides. The datadog_checks_dev repo-selection logic is legacy behavior from before the migration, and I do not think we should keep expanding it. Commands should use app.repo as the source of truth instead of re-deriving repo identity from legacy globals like get_root() or from directory names.
The issue with this PR is that it makes initialize_root() infer repo_choice from the root path basename when check_root() is already true. That can work in a narrow case, but it adds another repo-detection path to an area that is already confusing. It is also brittle because it depends on the local checkout directory name. If someone clones integrations-core into a directory with a different name, the proposed logic can infer the wrong repo. It can also be wrong if the old global root is stale or if ddev has already selected a different repo through -e, -m, DDEV_REPO, config, or local overrides.
If this came from a validation failure, I think the better fix is to update that validation to use the repo already selected by ddev. Checks-dev commands that run through the ddev entrypoint receive the Application object as ctx.obj, so they can read the active repo directly:
app = ctx.obj
repo_name = app.repo.name
repo_path = app.repo.path
repo_full_name = app.repo.full_nameFor example, a validation that needs to know whether it is running against integrations-core should check:
is_core = ctx.obj.repo.name == "core"instead of depending on ctx.obj["repo_choice"] or trying to infer the repo from get_root() / the directory name.
There are still legacy datadog_checks_dev commands that are not fully migrated, and some commands invoke other commands internally. That is part of the problem we need to clean up. If one of those paths still needs to support both the old checks-dev context shape and the new ddev Application context, I would rather handle that explicitly in the command or migrate the command than add another repo detection path based on directory names.
If this is not currently blocking work, I would prefer to wait for the migration instead of adding more behavior to the legacy initialization path.
|
Hi @AAraKKe For some reason, I can’t reply directly under your comment. The logic you described makes sense. In that case, I agree it’s better to use the repo selected by ddev via the application object, we don’t really need repo_choice here. In my other PR, I initially considered using I’ll probably close this PR since there’s no work needed here. |
What does this PR do?
When check_root() was true, the repo_choice would never get set for the application config. initialize_root returns immediately when check_root() is true, so it never runs the code that sets config['repo_choice']
This PR makes sure that repo_choice is set even if check_root() is true.
Motivation
Issue found when working through this PR: #23584
Review checklist (to be filled by reviewers)
qa/skip-qalabel if the PR doesn't need to be tested during QA.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged