Skip to content

Set timeout fields on agent config model

Issue: Backend: Set timeout fields in DB during agent ... (#427516 - closed)

What does this MR do and why?

This is a follow-up to add migration to include max_hours_before_termi... (!157795 - merged). It adds the workspace timeout fields to the models along with validations to ensure they are correct. This allows the k8s agent to be able to pick up the updated config file and update its workspace timeout fields in the Database.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. On your GDK setup, checkout the master branch of Gitlab k8s agent. The changes on the master are relevant to this MR as it contains schema updates needed to verify functionality
  2. In case you have not set up remote development on your GDK, follow the steps in this doc
  3. After starting GDK and setting up remote development, start a rails console: bin/rails console
  4. Run a query to find your agent config: results = ActiveRecord::Base.connection.execute("SELECT * FROM remote_development_agent_configs") You should have one if you follow the setup above, but if you have more than one on your setup, filter by ID to any desired active agent config.
  5. Run results[0].insepct and take note of default_max_hours_before_termination and max_hours_before_termination_limit. They should be 24 and 120 respectively.
  6. For the selected agent config, go to GDK Gitlab and add the following lines and commit:

Screenshot_2024-07-10_at_12.26.02_AM

  1. Query and inspect the agent config you updated in GitLab GDK by using the rails console again.
  2. The default_max_hours_before_termination and max_hours_before_termination_limit fields should match what was updated in the config file.
  3. For sanity check, check out the logs produced by agentk and ensure there are no error level logs.
Edited by Safwan Ahmed

Merge request reports