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
- 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
- In case you have not set up remote development on your GDK, follow the steps in this doc
- After starting GDK and setting up remote development, start a rails console:
bin/rails console
- 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. - Run
results[0].insepct
and take note ofdefault_max_hours_before_termination
andmax_hours_before_termination_limit
. They should be 24 and 120 respectively. - For the selected agent config, go to GDK Gitlab and add the following lines and commit:
- Query and inspect the agent config you updated in GitLab GDK by using the rails console again.
- The
default_max_hours_before_termination
andmax_hours_before_termination_limit
fields should match what was updated in the config file. - For sanity check, check out the logs produced by
agentk
and ensure there are no error level logs.
Edited by Safwan Ahmed