Adjust frontend to check for 'null' presence and backend to invalidate cache based on branch sha
Summary
See discussion in !101892 (comment 1148745028).
The Run Pipeline form uses reactive cache when sending data to the frontend, likely for performance reasons.
This means that there are times when the user visits the Run Pipeline form and the form is empty. Usually, this is remedied by refreshing the page. This can lead to flaky QA specs or even during manual testing. The current solution is to trigger page.refresh
to ensure the data is sent, but this is not ideal so we try to avoid page refresh to not hide transient behaviors.
This issue is to discuss if there are alternative solutions to either setting up the specs or dealing with the cache implementation.
User Impact
User is sometimes unable to view prefilled variables when these are not yet cached in the backend.
Proposal
-
frontend will work on adapting the Vue code to a similar solution that we had in !47490 (merged)
- The code needs to check if the result is
null
or not. -
null
: the cache is empty, please check later. -
[]
: no variables -
[{...}]
: variables
- The code needs to check if the result is
-
backend will work on invalidating cache based on the branch
sha
.
Frontend
If the frontend queries the API and the API cache is empty, then it will recalculate the predefined variables and populate the cache once more. The form shows a loading icon while we're polling for the updated variables.
In the previous implementation, the form would also stop polling after CONFIG_VARIABLES_TIMEOUT
ms have passed (in this case, 5000
, or 5 seconds). So when frontend receives no variables from the cache after 5 seconds, we default to showing the form anyway without it (either an empty form or a form with variables pulled from the URL parameters, if they exist). This behavior will also be brought back with the frontend MR.
Fetching from the cache
No polling since the values are already cached.
Polling when cache is empty
When switching to the dev
branch, the query polls for updated variables. The loading icon shows up until the poll is done.
Polling when cache is empty after CONFIG_VARIABLES_TIMEOUT
(5 seconds) have passed
Since the cache is still empty after the timeout, the form stops polling and shows an empty form.
See !109663 (merged) for implementation.
Backend
Today, we are receiving "ref" from a client and calculating config variables according to it. We also use this "ref" to decide the cache key. However, "ref" is not a good candidate for a cache key because the name is static but that branch can be changed.
In !109639 (merged), we are starting to calculate and use "sha" of the "ref" for the cache key.
Here, we are also renaming the "sha" parameter to "ref" because we are actually receiving "ref" from client.