Skip to content

Address polling edge cases in runner registration

Miguel Rincon requested to merge 383139-handle-timing-edge-cases into master

What does this MR do and why?

This change addresses two cases which may happen during the display of the runner registration page.

  • After the token is no longer available (1 hour) the runner token disappears from the screen, leaving the user unable to copy the token.
  • If the runner is deleted (in another screen) the page stops updating the runner information.

While currently the 1 hour time seems long, it may be shortened to a few minutes as the feature is refined, so these cases may become more common.

Screenshots or screen recordings

To test this, I simulated the runner registration availability running out by replacing the code, after the 30 seconds without registering, the runner page is preserved:

before after
Screenshot_2023-03-15_at_15.30.23 image

How to set up and validate locally

  1. Enable the feature flag: in your console rails c, and then Feature.enable(:create_runner_workflow_for_admin)

Edge case 1: The token is no longer available

  1. Change the current REGISTRATION_AVAILABILITY_TIME to a very short duration, like 30 seconds
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index eacb3ab8cd6e..3bb69cbae060 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -58,7 +58,7 @@ class Runner < Ci::ApplicationRecord
     STALE_TIMEOUT = 3.months
 
     # Only allow authentication token to be visible for a short while
-    REGISTRATION_AVAILABILITY_TIME = 1.hour
+    REGISTRATION_AVAILABILITY_TIME = 30.seconds
 
     AVAILABLE_TYPES_LEGACY = %w[specific shared].freeze
     AVAILABLE_TYPES = runner_types.keys.freeze
  1. Enable the feature flag: in your console rails c, and then Feature.enable(:create_runner_workflow_for_admin)
  2. Follow the runner creation instructions from http://gdk.test:3000/admin/runners
  3. Wait 30 seconds at the registration page e.g. http://gdk.test:3000/admin/runners/398/register?platform=linux
  4. The registration page should not change

Edge case 2: The runner is deleted

  1. Follow the runner creation instructions from http://gdk.test:3000/admin/runners
  2. Open a new tab, and delete the runner
  3. In the original tab, the registration page should not change

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #383139 (closed)

Edited by Miguel Rincon

Merge request reports

Loading