Delete the obsolete Open Environment Button in MR diffs
What is broken?
A long time ago, we introduced a feature to jump to an associated environment URL from a MR diff. As an example, you can take a look at the button below (surrounded by red square):
In short, this feature is NOT working as expected today. The button only appears after an MR has been merged, which supposed to be visible at any time/state. Here is the overview of the internal process:
- User visits the
diffs_batch
endpoint. -
@compare.diffs_in_batch
(accidentally?) alters themerge_request.merge_request_diff
from the actual commit diff (diff_type: "regular"
) to auto-generated/prospective merge diff (diff_type: "merge_head"
). This process change was introduced over a year ago by devopscreate . -
@merge_request.environments_for
tries to fetch an environment from themerge_head
SHA, but it fails. Because it's NOT the SHA that the deployments/environments ran for the merge requests. As a correction, it must be fetched fromregular
SHA. This is the first bug. - Let's say somewhat the environment was able to be fetched.
PaginatedDiffSerializer
serializes diffs including the environment, butDiffFileEntity#external_url
becomes alwaysnull
, becausediff_file.content_sha
also points themerge_head
SHA (again, this should beregular
SHA). Since thismerge_head
SHA is auto-generated by the system and not publicly accessible,external_url_for
fails. This is the second bug.
And this implementation is causing a performance issue
As you can see in this issue, we're still executing database queries to try fetching the associated environments even if it's not properly used. This query optimization requires significant effort, that at least takes a month to complete.
Proposal
Given that this feature is already unfunctional for over a year and requires a decent effort for the performance optimization, we should delete this implementation in order for resolving this significant ~"technical debt" and ~performance debt. We already have a dedicated environment section in merge request widgets, instead of diffs, and that's the main development/improvement area nowadays.