Skip to content
Snippets Groups Projects

Add runner token expiration interval settings

All threads resolved!
9 files
+ 293
1
Compare changes
  • Side-by-side
  • Inline
Files
9
+ 17
0
@@ -37,6 +37,7 @@ class Project < ApplicationRecord
@@ -37,6 +37,7 @@ class Project < ApplicationRecord
include EachBatch
include EachBatch
include GitlabRoutingHelper
include GitlabRoutingHelper
include BulkMemberAccessLoad
include BulkMemberAccessLoad
 
include RunnerTokenExpirationInterval
extend Gitlab::Cache::RequestCache
extend Gitlab::Cache::RequestCache
extend Gitlab::Utils::Override
extend Gitlab::Utils::Override
@@ -452,6 +453,7 @@ def self.integration_association_name(name)
@@ -452,6 +453,7 @@ def self.integration_association_name(name)
delegate :job_token_scope_enabled, :job_token_scope_enabled=, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :job_token_scope_enabled, :job_token_scope_enabled=, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :keep_latest_artifact, :keep_latest_artifact=, to: :ci_cd_settings, allow_nil: true
delegate :keep_latest_artifact, :keep_latest_artifact=, to: :ci_cd_settings, allow_nil: true
delegate :restrict_user_defined_variables, :restrict_user_defined_variables=, to: :ci_cd_settings, allow_nil: true
delegate :restrict_user_defined_variables, :restrict_user_defined_variables=, to: :ci_cd_settings, allow_nil: true
 
delegate :runner_token_expiration_interval, :runner_token_expiration_interval=, :runner_token_expiration_interval_human_readable, :runner_token_expiration_interval_human_readable=, to: :ci_cd_settings, allow_nil: true
delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true
delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true
delegate :allow_merge_on_skipped_pipeline, :allow_merge_on_skipped_pipeline?,
delegate :allow_merge_on_skipped_pipeline, :allow_merge_on_skipped_pipeline?,
:allow_merge_on_skipped_pipeline=, :has_confluence?, :has_shimo?,
:allow_merge_on_skipped_pipeline=, :has_confluence?, :has_shimo?,
@@ -2703,6 +2705,10 @@ def keep_latest_artifact?
@@ -2703,6 +2705,10 @@ def keep_latest_artifact?
ci_cd_settings.keep_latest_artifact?
ci_cd_settings.keep_latest_artifact?
end
end
 
def runner_token_expiration_interval
 
ci_cd_settings&.runner_token_expiration_interval
 
end
 
def group_runners_enabled?
def group_runners_enabled?
return false unless ci_cd_settings
return false unless ci_cd_settings
@@ -2734,6 +2740,17 @@ def remove_project_authorizations(user_ids, per_batch = 1000)
@@ -2734,6 +2740,17 @@ def remove_project_authorizations(user_ids, per_batch = 1000)
end
end
end
end
 
enforced_runner_token_expiration_interval do
 
all_parent_groups = Gitlab::ObjectHierarchy.new(Group.where(id: group)).base_and_ancestors
 
all_group_settings = NamespaceSetting.where(namespace_id: all_parent_groups)
 
group_interval = all_group_settings.where.not(project_runner_token_expiration_interval: nil).minimum(:project_runner_token_expiration_interval)&.seconds
 
 
[
 
Gitlab::CurrentSettings.project_runner_token_expiration_interval&.seconds,
 
group_interval
 
].compact.min
 
end
 
private
private
# overridden in EE
# overridden in EE
Loading