Skip to content
代码片段 群组 项目
提交 aa96b02a 编辑于 作者: Halil Coban's avatar Halil Coban 提交者: Ahmed Hemdan
浏览文件

Add logs for ci resource groups

Now logs related to resource group acquisition can be found in
ci_resource_groups_json file

Changelog: added
上级 e4522864
No related branches found
No related tags found
无相关合并请求
...@@ -29,13 +29,19 @@ def assign_resource_to(processable) ...@@ -29,13 +29,19 @@ def assign_resource_to(processable)
partition_id: processable.partition_id partition_id: processable.partition_id
} }
resources.free.limit(1).update_all(attrs) > 0 success = resources.free.limit(1).update_all(attrs) > 0
log_event(success: success, processable: processable, action: "assign resource to processable")
success
end end
def release_resource_from(processable) def release_resource_from(processable)
attrs = { build_id: nil, partition_id: nil } attrs = { build_id: nil, partition_id: nil }
resources.retained_by(processable).update_all(attrs) > 0 success = resources.retained_by(processable).update_all(attrs) > 0
log_event(success: success, processable: processable, action: "release resource from processable")
success
end end
def upcoming_processables def upcoming_processables
...@@ -72,5 +78,14 @@ def ensure_resource ...@@ -72,5 +78,14 @@ def ensure_resource
# belong to the same resource group are executed once at time. # belong to the same resource group are executed once at time.
self.resources.build if self.resources.empty? self.resources.build if self.resources.empty?
end end
def log_event(success:, processable:, action:)
Gitlab::Ci::ResourceGroups::Logger.build.info({
resource_group_id: self.id,
processable_id: processable.id,
message: "attempted to #{action}",
success: success
})
end
end end
end end
...@@ -771,6 +771,24 @@ are recorded in this file. For example: ...@@ -771,6 +771,24 @@ are recorded in this file. For example:
{"severity":"INFO","time":"2020-11-24T02:31:29.329Z","correlation_id":null,"key":"cd_auto_rollback","action":"remove"} {"severity":"INFO","time":"2020-11-24T02:31:29.329Z","correlation_id":null,"key":"cd_auto_rollback","action":"remove"}
``` ```
## `ci_resource_groups_json.log`
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/384180) in GitLab 15.9.
Depending on your installation method, this file is located at:
- Omnibus GitLab: `/var/log/gitlab/gitlab-rails/ci_resource_group_json.log`
- Installations from source: `/home/git/gitlab/log/ci_resource_group_json.log`
It contains information about [resource group](../../ci/resource_groups/index.md) acquisition. For example:
```json
{"severity":"INFO","time":"2023-02-10T23:02:06.095Z","correlation_id":"01GRYS10C2DZQ9J1G12ZVAD4YD","resource_group_id":1,"processable_id":288,"message":"attempted to assign resource to processable","success":true}
{"severity":"INFO","time":"2023-02-10T23:02:08.945Z","correlation_id":"01GRYS138MYEG32C0QEWMC4BDM","resource_group_id":1,"processable_id":288,"message":"attempted to release resource from processable","success":true}
```
The examples show the `resource_group_id`, `processable_id`, `message`, and `success` fields for each entry.
## `auth.log` ## `auth.log`
> Introduced in GitLab 12.0. > Introduced in GitLab 12.0.
......
# frozen_string_literal: true
module Gitlab
module Ci
module ResourceGroups
class Logger < ::Gitlab::JsonLogger
def self.file_name_noext
'ci_resource_groups_json'
end
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册