Class: Clusters::Agent
Constant Summary
collapse
- INACTIVE_AFTER =
1.hour.freeze
- ACTIVITY_EVENT_LIMIT =
200
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Method Summary
collapse
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#sharding_organization
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Instance Method Details
#activity_event_deletion_cutoff ⇒ Object
61
62
63
64
65
66
|
# File 'app/models/clusters/agent.rb', line 61
def activity_event_deletion_cutoff
activity_events
.offset(ACTIVITY_EVENT_LIMIT - 1)
.pick(:recorded_at)
end
|
#ci_access_authorized_for?(user) ⇒ Boolean
72
73
74
75
76
77
|
# File 'app/models/clusters/agent.rb', line 72
def ci_access_authorized_for?(user)
return false unless user
all_ci_access_authorized_projects_for(user).exists? ||
all_ci_access_authorized_namespaces_for(user).exists?
end
|
#connected? ⇒ Boolean
57
58
59
|
# File 'app/models/clusters/agent.rb', line 57
def connected?
agent_tokens.connected.exists?
end
|
#has_access_to?(requested_project) ⇒ Boolean
53
54
55
|
# File 'app/models/clusters/agent.rb', line 53
def has_access_to?(requested_project)
requested_project == project
end
|
#resource_management_enabled? ⇒ Boolean
99
100
101
|
# File 'app/models/clusters/agent.rb', line 99
def resource_management_enabled?
false end
|
#to_ability_name ⇒ Object
68
69
70
|
# File 'app/models/clusters/agent.rb', line 68
def to_ability_name
:cluster
end
|
#user_access_authorizations ⇒ Object
92
93
94
95
96
97
|
# File 'app/models/clusters/agent.rb', line 92
def user_access_authorizations
self.class.from_union(
user_access_project_authorizations.select('config').limit(1),
user_access_group_authorizations.select('config').limit(1)
).select('config').compact.first
end
|
#user_access_authorized_for?(user) ⇒ Boolean
79
80
81
82
83
84
|
# File 'app/models/clusters/agent.rb', line 79
def user_access_authorized_for?(user)
return false unless user
Clusters::Agents::Authorizations::UserAccess::Finder
.new(user, agent: self, preload: false, limit: 1).execute.any?
end
|
#user_access_config ⇒ Object
As of today, all config values of associated authorization rows have the same value. See UserAccess::RefreshService for more information.
88
89
90
|
# File 'app/models/clusters/agent.rb', line 88
def user_access_config
user_access_authorizations&.config
end
|