diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-22 06:15:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-22 06:15:20 +0300 |
commit | dc93436903cbc2e9deeadc620f2075941d71c559 (patch) | |
tree | 426ef8405ae2814299cb28a358afa9448c4a6fd5 /app/models/clusters | |
parent | 4314202d9dcdac226e0ea7f3d7f669ab1d8bb6e2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/clusters')
-rw-r--r-- | app/models/clusters/agent.rb | 4 | ||||
-rw-r--r-- | app/models/clusters/agent_token.rb | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/app/models/clusters/agent.rb b/app/models/clusters/agent.rb index 98490a13351..8705c0fbec4 100644 --- a/app/models/clusters/agent.rb +++ b/app/models/clusters/agent.rb @@ -36,8 +36,8 @@ module Clusters requested_project == project end - def active? - agent_tokens.where("last_used_at > ?", INACTIVE_AFTER.ago).exists? + def connected? + agent_tokens.active.where("last_used_at > ?", INACTIVE_AFTER.ago).exists? end end end diff --git a/app/models/clusters/agent_token.rb b/app/models/clusters/agent_token.rb index 87dba50cd69..d4f6beb045a 100644 --- a/app/models/clusters/agent_token.rb +++ b/app/models/clusters/agent_token.rb @@ -23,13 +23,18 @@ module Clusters scope :order_last_used_at_desc, -> { order(::Gitlab::Database.nulls_last_order('last_used_at', 'DESC')) } + enum status: { + active: 0, + revoked: 1 + } + def track_usage track_values = { last_used_at: Time.current.utc } cache_attributes(track_values) if can_update_track_values? - log_activity_event!(track_values[:last_used_at]) unless agent.active? + log_activity_event!(track_values[:last_used_at]) unless agent.connected? # Use update_column so updated_at is skipped update_columns(track_values) |