-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
- I'd be willing to implement this feature (contributing guide)
Describe the user story
As a developer, I want to create an environment variable called ATLANTIS_AZUREDEVOPS_LEGACY_URL_ISSUE to convert the Azure Devops Organization name to lower case in all type of service hooks (v1.0 & v2.0)
Describe the problem in detail
Not moving to the new Azure DevOps URL causes the Atlantis service hooks to have different folder names on these 2 scenarios:
A)Pull Request Comments (Using Service hook v2.0)
B)Pull Request Updates/Creates (Using Service hook v1.0)
Evidence:
1)Pull request commented on (version 2.0)
2)Pull request updated (version 1.0)
3)Pull request created (version 1.0)
1)https://dev.azure.com/MYCompany/1234567-abcd-abcd-abcd-987654321/_apis/git/repositories/1234abcd-9876-1234-a123-123456789/pullRequests/000001
2)https://mycompany.visualstudio.com/1234567-abcd-abcd-abcd-987654321/_apis/git/repositories/1234abcd-9876-1234-a123-123456789/pullRequests/000001
3)https://mycompany.visualstudio.com/1234567-abcd-abcd-abcd-987654321/_apis/git/repositories/1234abcd-9876-1234-a123-123456789/pullRequests/000001
This is creating 2 different folders for the plans:
/home/atlantis/.atlantis/repos/MYCompany/terraform-modules/terraform-live/000001/default/c1/us-east-01/base
/home/atlantis/.atlantis/repos/mycompany/terraform-modules/terraform-live/000001/default/c1/us-east-01/base
So the plan triggered by opening the Pull request on "3)PullRequestCreated" creates the auto-plan at /mycompany/ and when i run atlantis apply it tries to find apply the plan at /MYCompany/, which it doesn't exist at that moment
Checking some old issues, it seems that this is related to a previous migration where Azure Devops changed the URL and preserved the old name to use in the different service hooks.
Describe why this is important to have
We are doing this because of the impact that other pipelines/webhooks/CICD/and others could have if we turn on the setting "Use the new URL"
Describe the solution you'd like
-As this is only affecting a reduced number of users, the idea is to put some logic on the current code to convert the Azure Devops Organization Name to lowercase so the plans coming from both service hooks (v1.0 & v2.0) can be saved in the same folder. In order to achieve this, the plan is to have an environment variable called ATLANTIS_AZUREDEVOPS_LEGACY_URL_ISSUE = true (I'm totally open to suggestions to change this name if needed) and the users affected will have this value on true.
-For unaffected users the variable value will be false by default if it's not specified.
-We'll include some logic to do the conversion of the ADOrganization to lowercase, if it's on false, nothing will happen.(I'll update the ticket with more details when I get to the Azure Controller Code, didn't explore it yet)
Describe the drawbacks of your solution
The drawback is that this effort won't be useful if Azure forces the migration to the new url in the future. The migration was announced back on 2018 (Article here) but more than 6 years passed and there is no official date where they are going to enforce the usage of the new url. Since that is not going to happen in the near future it seems like a really small risk. Also this feature could and should be easily removed if that happens in the near future.
Describe alternatives you've considered
Alternatives to this issue are enabling the New URL Setting on the Azure Devops Organization but this is a big risk since it can affect:
1. Git remotes
2. CI/CD pipelines
3. Service connections (OAuth or service connections that use hardcoded repository/project URLs may break or need manual updates)
4. Webhooks and integrations
5. Manual bookmarks, documentation, or wikis
6. API consumers / scripts
7. Azure Repos badges
8. Git submodules
The Current Hotfix:
If you are being affected by this issue, the best thing to do is disabling the 2)Pull request updated (version 1.0) and 3)Pull request created (version 1.0) service hooks.
Considerations: you will loose the ability to auto-plan and auto-unlock the PRs automatically. But you can easily solve this by running atlantis plan when the PR is created, and atlantis unlock after you applied and merged your PR
What happens when I disable service hooks for v1.0?
Atlantis uses the same folder for all operations /home/atlantis/.atlantis/repos/MYCompany/ to save the plans and doesn't have any errors
How this feature will be developed
1)I will rely on the Atlantis community, first looking and understanding the code and the controllers that could help on solving this issue
2)I will propose 1 or more ideas to solve this issue
3)I will create a Pull Request to get reviews and feedback
4)I will test this issue before merging the PR on 1 Azure Devops Organization that is having this issue with a testing connected repository to create a terraform resource and confirm that the solution works as expected