You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "Marco-De-Stefani (via GitHub)" <gi...@apache.org> on 2023/09/28 07:06:19 UTC
[GitHub] [incubator-devlake] Marco-De-Stefani opened a new pull request, #6167: feat(gitlab) fetch trigger jobs
Marco-De-Stefani opened a new pull request, #6167:
URL: https://github.com/apache/incubator-devlake/pull/6167
### Summary
Add the trigger jobs to the jobs already fetched from GitLab
### Does this close any open issues?
Closes 6135
### Screenshots
data fetched from a real GitLab instance:
<img width="1858" alt="image" src="https://github.com/apache/incubator-devlake/assets/10463940/5141dec2-b53e-407f-be8d-21264b1560bc">
The processing of the data after the collection is tested with the `trigger_job_test.go`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(gitlab) fetch trigger jobs [incubator-devlake]
Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on PR #6167:
URL: https://github.com/apache/incubator-devlake/pull/6167#issuecomment-1914533073
@Marco-De-Stefani I encounter a problem when running the latest main branch and the log is
```
time="2024-01-29 19:39:08" level=info msg=" [pipeline service] [pipeline #8] [task #59] finished step: 17 / 35"
time="2024-01-29 19:39:08" level=info msg=" [pipeline service] [pipeline #8] [task #59] executing subtask collectApiTriggerJobs"
time="2024-01-29 19:39:08" level=info msg="\x1b[31;1m/Users/houlinwei/Code/go/src/github.com/merico-dev/lake-feat-6854/backend/impls/dalgorm/dalgorm.go:188 \x1b[35;1mError 1146 (42S02): Table 'lake._raw_gitlab_api_trigger_job' doesn't exist\n\x1b[0m\x1b[33m[2.624ms] \x1b[34;1m[rows:-]\x1b[0m SELECT gp.gitlab_id, gp.gitlab_id as iid FROM _tool_gitlab_pipelines gp WHERE gp.project_id = 50751699 and gp.connection_id = 1 and gp.gitlab_id not in (select json_extract(tj.input, '$.GitlabId') as gitlab_id from _raw_gitlab_api_trigger_job tj)"
time="2024-01-29 19:39:08" level=error msg=" [pipeline service] [pipeline #8] [task #59] subtask collectApiTriggerJobs ended unexpectedly\n\tWraps: (2) Error 1146 (42S02): Table 'lake._raw_gitlab_api_trigger_job' doesn't exist (500)\n\tWraps: (3) Error 1146 (42S02): Table 'lake._raw_gitlab_api_trigger_job' doesn't exist\n\tError types: (1) *hintdetail.withDetail (2) *hintdetail.withDetail (3) *mysql.MySQLError"
time="2024-01-29 19:39:08" level=info msg=" [task service] run task #61 in background "
```
And I think SQL in function `GetAllPipelinesIterator` is the root cause. Please check the codes.
cc @abeizn
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(gitlab) fetch trigger jobs [incubator-devlake]
Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on code in PR #6167:
URL: https://github.com/apache/incubator-devlake/pull/6167#discussion_r1469476457
##########
backend/plugins/gitlab/tasks/trigger_job_collector.go:
##########
@@ -0,0 +1,92 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+ "github.com/apache/incubator-devlake/core/dal"
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+ helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+ "reflect"
+ "time"
+)
+
+func init() {
+ RegisterSubtaskMeta(&CollectApiTriggerJobsMeta)
+}
+
+const RAW_TRIGGER_JOB_TABLE = "gitlab_api_trigger_job"
+
+var CollectApiTriggerJobsMeta = plugin.SubTaskMeta{
+ Name: "collectApiTriggerJobs",
+ EntryPoint: CollectApiTriggerJobs,
+ EnabledByDefault: true,
+ Description: "Collect job data from gitlab api, supports both timeFilter and diffSync.",
+ DomainTypes: []string{plugin.DOMAIN_TYPE_CICD},
+ Dependencies: []*plugin.SubTaskMeta{&ExtractApiPipelineDetailsMeta},
+}
+
+func CollectApiTriggerJobs(taskCtx plugin.SubTaskContext) errors.Error {
+ rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_TRIGGER_JOB_TABLE)
+ collectorWithState, err := helper.NewStatefulApiCollector(*rawDataSubTaskArgs, data.TimeAfter)
+ tickInterval, err := helper.CalcTickInterval(200, 1*time.Minute)
+ incremental := collectorWithState.IsIncremental()
+
+ iterator, err := GetAllPipelinesIterator(taskCtx, collectorWithState)
+
+ err = collectorWithState.InitCollector(helper.ApiCollectorArgs{
+ //RawDataSubTaskArgs: *rawDataSubTaskArgs,
+ ApiClient: data.ApiClient,
+ MinTickInterval: &tickInterval,
+ PageSize: 100,
+ Incremental: incremental,
+ Input: iterator,
+ UrlTemplate: "projects/{{ .Params.ProjectId }}/pipelines/{{ .Input.GitlabId }}/bridges",
+ ResponseParser: GetRawMessageFromResponse,
+ AfterResponse: ignoreHTTPStatus403, // ignore 403 for CI/CD disable
+ })
+
+ if err != nil {
+ return err
+ }
+
+ return collectorWithState.Execute()
+}
+
+func GetAllPipelinesIterator(taskCtx plugin.SubTaskContext, collectorWithState *helper.ApiCollectorStateManager) (*helper.DalCursorIterator, errors.Error) {
+ db := taskCtx.GetDal()
+ data := taskCtx.GetData().(*GitlabTaskData)
+ clauses := []dal.Clause{
+ dal.Select("gp.gitlab_id, gp.gitlab_id as iid"),
+ dal.From("_tool_gitlab_pipelines gp"),
+ dal.Where(
+ `gp.project_id = ? and gp.connection_id = ? and gp.gitlab_id not in (select json_extract(tj.input, '$.GitlabId') as gitlab_id from _raw_gitlab_api_trigger_job tj)`,
Review Comment:
When running this SQL, table `_raw_gitlab_api_trigger_job` doesn't exist.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(gitlab) fetch trigger jobs [incubator-devlake]
Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn commented on PR #6167:
URL: https://github.com/apache/incubator-devlake/pull/6167#issuecomment-1878047006
I will merge it after the issue https://github.com/apache/incubator-devlake/issues/5920
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(gitlab) fetch trigger jobs [incubator-devlake]
Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn commented on PR #6167:
URL: https://github.com/apache/incubator-devlake/pull/6167#issuecomment-1905491859
LGTM, to be merged after v0.21-beta1 released
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(gitlab) fetch trigger jobs [incubator-devlake]
Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn merged PR #6167:
URL: https://github.com/apache/incubator-devlake/pull/6167
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org