Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9d3473a
oss changes for build worker status
ayu-devtron Jan 24, 2025
56d3a3b
wip
kartik-579 Jan 24, 2025
ad4f89f
oss code changes for ent
ayu-devtron Jan 27, 2025
bbec402
update sql script number
ayu-devtron Jan 27, 2025
063a657
update sql script
ayu-devtron Jan 27, 2025
74adbb7
add flag to enable new workflow stage history
ayu-devtron Jan 28, 2025
11c2f50
save workflow before stage in saving
ayu-devtron Jan 28, 2025
249ae53
return cancelled for wf status in case of aborted
ayu-devtron Jan 28, 2025
fe0250b
add in terminal state for cancelled
ayu-devtron Jan 28, 2025
7e83ea3
default check
prkhrkat Jan 28, 2025
941a95d
add comment and flag description
ayu-devtron Jan 28, 2025
3d22e4b
default check SMTP
prkhrkat Jan 28, 2025
a71d16f
fix for aborted and cancelled
ayu-devtron Jan 28, 2025
2bdc693
add cancel in terminal status
ayu-devtron Jan 28, 2025
0e8c54e
import cycle fix
ayu-devtron Jan 28, 2025
d9995c3
bug fix for cancel and abort
ayu-devtron Jan 28, 2025
279a3de
bug fix updating workflow
ayu-devtron Jan 28, 2025
3cf2966
Merge branch 'develop' into sql-injection-fix-2
kartik-579 Jan 29, 2025
4617e21
develop sync change
kartik-579 Jan 29, 2025
eb125b9
Merge pull request #6334 from devtron-labs/sql-injection-fix-2
kartik-579 Jan 29, 2025
27e8cc5
role grouplisting fix (#6343)
Shivam-nagar23 Jan 31, 2025
2d4a33c
common-lib change
prkhrkat Jan 31, 2025
302f92b
review comments -1
ayu-devtron Jan 31, 2025
71b3cff
common-lib change
prkhrkat Jan 31, 2025
987fbbe
Merge branch 'develop' into notif-default
prkhrkat Jan 31, 2025
1e7491a
ci refactor flow to ci service
ayu-devtron Feb 2, 2025
6cfcda5
move cd functions to cdworkflow runner service
ayu-devtron Feb 2, 2025
5c07fc7
status_type to status_for
ayu-devtron Feb 3, 2025
2630542
Merge branch 'develop' of github.com:devtron-labs/devtron into build-…
ayu-devtron Feb 3, 2025
41ac873
Merge branch 'develop' into env-labels-fix
prkhrkat Feb 3, 2025
e7b1858
Merge pull request #6347 from devtron-labs/env-labels-fix
prkhrkat Feb 3, 2025
013e292
Merge branch 'develop' into notif-default
prkhrkat Feb 3, 2025
67ed0de
feat: sql script changes for operation audit (#6342)
Shivam-nagar23 Feb 4, 2025
4741208
Merge branch 'main' of github.com:devtron-labs/devtron into build-wor…
ayu-devtron Feb 4, 2025
06d4e95
merge conflicts + code refactor
ayu-devtron Feb 4, 2025
b77075f
main sync develop
vikramdevtron Feb 5, 2025
e245d53
Merge pull request #6358 from devtron-labs/main-sync-develop-5feb
vikramdevtron Feb 5, 2025
f91859d
Merge branch 'develop' of github.com:devtron-labs/devtron into build-…
ayu-devtron Feb 5, 2025
d414d6f
handle failure cases before scheduling
ayu-devtron Feb 7, 2025
1d68416
updated sql scripts number
ayu-devtron Feb 7, 2025
2a3a987
merge fix
ayu-devtron Feb 7, 2025
24b1ac3
eso secret data clone fix
prakash100198 Feb 7, 2025
9e9856f
Merge pull request #6366 from devtron-labs/eso-secret-clone-fix
prakash100198 Feb 7, 2025
a87f334
Merge branch 'develop' into notif-default
prkhrkat Feb 7, 2025
cb3ca49
notification fixes
prkhrkat Feb 7, 2025
a1f79f1
default flag true & avoid already commited log
ayu-devtron Feb 7, 2025
ae42e7b
Merge pull request #6331 from devtron-labs/notif-default
prkhrkat Feb 7, 2025
0ed86d5
update error message
ayu-devtron Feb 7, 2025
361cab8
Merge branch 'develop' into build-worker-status
ayu-devtron Feb 7, 2025
ecd0d33
fix: ignore handling of the cd workflow status update event no state …
gireesh-naidu Feb 7, 2025
e537e28
Merge pull request #6320 from devtron-labs/build-worker-status
ayu-devtron Feb 7, 2025
0b9749b
Merge branch 'develop' into fix-ci-cd-workflow-status-oss
gireesh-naidu Feb 10, 2025
71c8fea
Merge pull request #6370 from devtron-labs/fix-ci-cd-workflow-status-oss
gireesh-naidu Feb 10, 2025
49754c7
main sync develop
vikramdevtron Feb 10, 2025
c7f511a
main sync develop and vendor update
vikramdevtron Feb 10, 2025
10d9e90
Merge pull request #6375 from devtron-labs/main-sync-develop-10feb
vikramdevtron Feb 10, 2025
f988b39
column name fixed
vikramdevtron Feb 10, 2025
dd968f0
Merge pull request #6378 from devtron-labs/workflow_execution_stage-fix
vikramdevtron Feb 10, 2025
0e1da1a
fix: workflow status fix
gireesh-naidu Feb 12, 2025
1e0393c
fix: oss no notify fix
gireesh-naidu Feb 12, 2025
6276f82
Merge pull request #6386 from devtron-labs/workerstatus-update-notify…
gireesh-naidu Feb 12, 2025
3838e38
handling of skipped event
ayu-devtron Feb 12, 2025
fe58be5
Merge pull request #6387 from devtron-labs/unknown-event-fix
ayu-devtron Feb 12, 2025
91a905b
sequence change
Shivam-nagar23 Feb 13, 2025
c10cf2d
Merge pull request #6391 from devtron-labs/fix-sql-sequence
vikramdevtron Feb 13, 2025
d3b423d
main sync rc
vikramdevtron Feb 13, 2025
761978b
vendor update on rc29
vikramdevtron Feb 13, 2025
6c244a0
vendor update on rc
vikramdevtron Feb 13, 2025
1379d34
Merge pull request #6392 from devtron-labs/main-sync-rc29
vikramdevtron Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ import (
repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
repository5 "github.com/devtron-labs/devtron/pkg/pipeline/repository"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/pipeline/workflowStatus"
repository6 "github.com/devtron-labs/devtron/pkg/pipeline/workflowStatus/repository"
"github.com/devtron-labs/devtron/pkg/plugin"
"github.com/devtron-labs/devtron/pkg/policyGovernance"
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
Expand Down Expand Up @@ -471,6 +473,11 @@ func InitializeApp() (*App, error) {
pipeline.NewCiServiceImpl,
wire.Bind(new(pipeline.CiService), new(*pipeline.CiServiceImpl)),

workflowStatus.NewWorkflowStageFlowStatusServiceImpl,
wire.Bind(new(workflowStatus.WorkFlowStageStatusService), new(*workflowStatus.WorkFlowStageStatusServiceImpl)),
repository6.NewWorkflowStageRepositoryImpl,
wire.Bind(new(repository6.WorkflowStageRepository), new(*repository6.WorkflowStageRepositoryImpl)),

pipelineConfig.NewCiWorkflowRepositoryImpl,
wire.Bind(new(pipelineConfig.CiWorkflowRepository), new(*pipelineConfig.CiWorkflowRepositoryImpl)),

Expand Down
38 changes: 38 additions & 0 deletions api/bean/UserRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package bean
import (
"encoding/json"
"github.com/devtron-labs/devtron/pkg/auth/user/bean"
"github.com/devtron-labs/devtron/pkg/sql"
"time"
)

Expand Down Expand Up @@ -168,3 +169,40 @@ type BulkDeleteRequest struct {
type UserRoleGroup struct {
RoleGroup *RoleGroup `json:"roleGroup"`
}

type GroupPermissionsAuditDto struct {
RoleGroupInfo *RoleGroup `json:"roleGroupInfo,omitempty"`
EntityAudit sql.AuditLog `json:"entityAudit,omitempty"`
}

func NewGroupPermissionsAuditDto() *GroupPermissionsAuditDto {
return &GroupPermissionsAuditDto{}
}

func (pa *GroupPermissionsAuditDto) WithRoleGroupInfo(roleGroupInfo *RoleGroup) *GroupPermissionsAuditDto {
pa.RoleGroupInfo = roleGroupInfo
return pa
}
func (pa *GroupPermissionsAuditDto) WithEntityAudit(entityAudit sql.AuditLog) *GroupPermissionsAuditDto {
pa.EntityAudit = entityAudit
return pa
}

type UserPermissionsAuditDto struct {
UserInfo *UserInfo `json:"userInfo,omitempty"`
EntityAudit sql.AuditLog `json:"entityAudit,omitempty"`
}

func NewUserPermissionsAuditDto() *UserPermissionsAuditDto {
return &UserPermissionsAuditDto{}
}

func (pa *UserPermissionsAuditDto) WithUserInfo(userInfo *UserInfo) *UserPermissionsAuditDto {
pa.UserInfo = userInfo
return pa
}

func (pa *UserPermissionsAuditDto) WithEntityAudit(entityAudit sql.AuditLog) *UserPermissionsAuditDto {
pa.EntityAudit = entityAudit
return pa
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/devtron-labs/devtron/internal/sql/constants"
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
bean2 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
constants2 "github.com/devtron-labs/devtron/pkg/pipeline/constants"
"github.com/devtron-labs/devtron/util/stringsUtil"
"golang.org/x/exp/maps"
"io"
Expand All @@ -45,7 +46,6 @@ import (
"github.com/devtron-labs/devtron/internal/util"
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/bean"
"github.com/devtron-labs/devtron/pkg/pipeline"
bean1 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
resourceGroup "github.com/devtron-labs/devtron/pkg/resourceGroup"
Expand Down Expand Up @@ -663,7 +663,7 @@ func (handler *PipelineConfigRestHandlerImpl) validateCiTriggerRBAC(token string
// This is being done for jobs, jobs execute in default-env (devtron-ci) namespace by default. so considering DefaultCiNamespace as env for rbac enforcement
envName := ""
if triggerEnvironmentId == 0 {
envName = pipeline.DefaultCiWorkflowNamespace
envName = constants2.DefaultCiWorkflowNamespace
}
appObject := handler.enforcerUtil.GetAppRBACNameByAppId(ciPipeline.AppId)
workflowObject := handler.enforcerUtil.GetWorkflowRBACByCiPipelineId(ciPipelineId, workflowName)
Expand Down
2 changes: 1 addition & 1 deletion env_gen.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions env_gen.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
| DEFAULT_TARGET_PLATFORM | string | | | | false |
| DOCKER_BUILD_CACHE_PATH | string |/var/lib/docker | | | false |
| ENABLE_BUILD_CONTEXT | bool |false | | | false |
| ENABLE_WORKFLOW_EXECUTION_STAGE | bool |true | if enabled then we will display build stages separately for CI/Job/Pre-Post CD | true | false |
| EXTERNAL_BLOB_STORAGE_CM_NAME | string |blob-storage-cm | | | false |
| EXTERNAL_BLOB_STORAGE_SECRET_NAME | string |blob-storage-secret | | | false |
| EXTERNAL_CD_NODE_LABEL_SELECTOR | | | | | false |
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect

replace (
github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250130075053-69cdda98e3e2
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250130075053-69cdda98e3e2
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250213074742-042aeadc9d72
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250213074742-042aeadc9d72
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
k8s.io/api => k8s.io/api v0.29.7
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU=
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250130075053-69cdda98e3e2 h1:8QjRav7pCDb32Pz8HwbS1P8QQJ1QSDb3wJgAmNYkNeU=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250130075053-69cdda98e3e2/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250130075053-69cdda98e3e2 h1:8VByFEk14t2z2DDaD/7pTgwSM7zFYEMqfthLWpt2M3w=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250130075053-69cdda98e3e2/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250213074742-042aeadc9d72 h1:BEFuaGkJgvu+8H+To2sMJQusaD3PZwQbxn0ikIpkWbE=
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250213074742-042aeadc9d72/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250213074742-042aeadc9d72 h1:hPVJuggt+zZjcf3PFaXy7ZrBV7VPB8+ztMVUErmHX3Y=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250213074742-042aeadc9d72/go.mod h1:1QJJLpgJSkb5Jm9xPeKAk+kXb0QgBOOOgJj0cgYhAVA=
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys=
Expand Down
4 changes: 2 additions & 2 deletions internal/sql/repository/AppListingRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ func (impl AppListingRepositoryImpl) FetchAppsByEnvironmentV2(appListingFilter h

// if any pipeline found get the latest deployment time
if len(pipelineIds) > 0 {
query := impl.appListingRepositoryQueryBuilder.BuildAppListingQueryLastDeploymentTimeV2(pipelineIds)
query, queryParams := impl.appListingRepositoryQueryBuilder.BuildAppListingQueryLastDeploymentTimeV2(pipelineIds)
impl.Logger.Debugw("basic app detail query: ", query)
start := time.Now()
_, err := impl.dbConnection.Query(&lastDeployedTimeDTO, query)
_, err := impl.dbConnection.Query(&lastDeployedTimeDTO, query, queryParams...)
middleware.AppListingDuration.WithLabelValues("buildAppListingQueryLastDeploymentTime", "devtron").Observe(time.Since(start).Seconds())
if err != nil {
impl.Logger.Errorw("error in getting latest deployment time for given pipelines", "err", err, "pipelines", pipelineIds, "query", query)
Expand Down
4 changes: 2 additions & 2 deletions internal/sql/repository/CiArtifactRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ func (impl CiArtifactRepositoryImpl) GetArtifactsByCDPipelineV3(listingFilterOpt
artifactsResp := make([]*CiArtifactWithExtraData, 0, listingFilterOpts.Limit)
var artifacts []*CiArtifact
totalCount := 0
finalQuery := BuildQueryForParentTypeCIOrWebhook(*listingFilterOpts)
_, err := impl.dbConnection.Query(&artifactsResp, finalQuery)
finalQuery, finalQueryParams := BuildQueryForParentTypeCIOrWebhook(*listingFilterOpts)
_, err := impl.dbConnection.Query(&artifactsResp, finalQuery, finalQueryParams...)
if err != nil {
return nil, totalCount, err
}
Expand Down
31 changes: 20 additions & 11 deletions internal/sql/repository/CiArtifactsListingQueryBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@ import (
"fmt"
"github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
"github.com/go-pg/pg"
)

const EmptyLikeRegex = "%%"

func BuildQueryForParentTypeCIOrWebhook(listingFilterOpts bean.ArtifactsListFilterOptions) string {
commonPaginatedQueryPart := fmt.Sprintf(" cia.image LIKE '%v'", listingFilterOpts.SearchString)
func BuildQueryForParentTypeCIOrWebhook(listingFilterOpts bean.ArtifactsListFilterOptions) (string, []interface{}) {
commonPaginatedQueryPart, commonPaginatedQueryParams := " cia.image LIKE ?", []interface{}{listingFilterOpts.SearchString}
orderByClause := " ORDER BY cia.id DESC"
limitOffsetQueryPart := fmt.Sprintf(" LIMIT %v OFFSET %v", listingFilterOpts.Limit, listingFilterOpts.Offset)
limitOffsetQueryPart, limitOffsetQueryParams := fmt.Sprintf(" LIMIT ? OFFSET ?"), []interface{}{listingFilterOpts.Limit, listingFilterOpts.Offset}
finalQuery := ""
var finalQueryParams []interface{}
var remainingQueryParams []interface{}
if listingFilterOpts.ParentStageType == bean.CI_WORKFLOW_TYPE {
selectQuery := " SELECT cia.* "
remainingQuery := " FROM ci_artifact cia" +
" INNER JOIN ci_pipeline cp ON (cp.id=cia.pipeline_id or (cp.id=cia.component_id and cia.data_source='post_ci' ) )" +
" INNER JOIN pipeline p ON (p.ci_pipeline_id = cp.id and p.id=%v )" +
" INNER JOIN pipeline p ON (p.ci_pipeline_id = cp.id and p.id=? )" +
" WHERE "
remainingQuery = fmt.Sprintf(remainingQuery, listingFilterOpts.PipelineId)
remainingQueryParams = []interface{}{listingFilterOpts.PipelineId}
if len(listingFilterOpts.ExcludeArtifactIds) > 0 {
remainingQuery += fmt.Sprintf("cia.id NOT IN (%s) AND ", helper.GetCommaSepratedString(listingFilterOpts.ExcludeArtifactIds))
remainingQuery += "cia.id NOT IN (?) AND "
remainingQueryParams = append(remainingQueryParams, pg.In(listingFilterOpts.ExcludeArtifactIds))
}

countQuery := " SELECT count(cia.id) as total_count"
Expand All @@ -47,19 +51,24 @@ func BuildQueryForParentTypeCIOrWebhook(listingFilterOpts bean.ArtifactsListFilt
} else if listingFilterOpts.ParentStageType == bean.WEBHOOK_WORKFLOW_TYPE {
selectQuery := " SELECT cia.* "
remainingQuery := " FROM ci_artifact cia " +
" WHERE cia.external_ci_pipeline_id = %v AND "
remainingQuery = fmt.Sprintf(remainingQuery, listingFilterOpts.ParentId)
" WHERE cia.external_ci_pipeline_id = ? AND "
remainingQueryParams = []interface{}{listingFilterOpts.ParentId}
if len(listingFilterOpts.ExcludeArtifactIds) > 0 {
remainingQuery += fmt.Sprintf("cia.id NOT IN (%s) AND ", helper.GetCommaSepratedString(listingFilterOpts.ExcludeArtifactIds))
remainingQuery += "cia.id NOT IN (?) AND "
remainingQueryParams = append(remainingQueryParams, pg.In(listingFilterOpts.ExcludeArtifactIds))
}

countQuery := " SELECT count(cia.id) as total_count"
totalCountQuery := countQuery + remainingQuery + commonPaginatedQueryPart
selectQuery = fmt.Sprintf("%s,(%s) ", selectQuery, totalCountQuery)
finalQuery = selectQuery + remainingQuery + commonPaginatedQueryPart + orderByClause + limitOffsetQueryPart

}
return finalQuery
finalQueryParams = append(finalQueryParams, remainingQueryParams...)
finalQueryParams = append(finalQueryParams, commonPaginatedQueryParams...)
finalQueryParams = append(finalQueryParams, remainingQueryParams...)
finalQueryParams = append(finalQueryParams, commonPaginatedQueryParams...)
finalQueryParams = append(finalQueryParams, limitOffsetQueryParams...)
return finalQuery, finalQueryParams
}

func BuildQueryForArtifactsForCdStage(listingFilterOptions bean.ArtifactsListFilterOptions) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,17 @@ func (impl AppListingRepositoryQueryBuilder) TestForCommonAppFilter(appListingFi
return query, queryParams
}

func (impl AppListingRepositoryQueryBuilder) BuildAppListingQueryLastDeploymentTimeV2(pipelineIDs []int) string {
func (impl AppListingRepositoryQueryBuilder) BuildAppListingQueryLastDeploymentTimeV2(pipelineIDs []int) (string, []interface{}) {
whereCondition := ""
queryParams := []interface{}{}
if len(pipelineIDs) > 0 {
whereCondition += fmt.Sprintf(" Where pco.pipeline_id IN (%s) ", GetCommaSepratedString(pipelineIDs))
whereCondition += " Where pco.pipeline_id IN (?) "
queryParams = append(queryParams, pg.In(pipelineIDs))
}
query := "select pco.pipeline_id , MAX(pco.created_on) as last_deployed_time" +
" from pipeline_config_override pco" + whereCondition +
" GROUP BY pco.pipeline_id;"
return query
return query, queryParams
}

func (impl AppListingRepositoryQueryBuilder) GetAppIdsQueryWithPaginationForLastDeployedSearch(appListingFilter AppListingFilter) (string, []interface{}) {
Expand Down
18 changes: 8 additions & 10 deletions internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package pipelineConfig
import (
"context"
"errors"
"fmt"
apiBean "github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/client/gitSensor"
"github.com/devtron-labs/devtron/internal/sql/repository"
Expand All @@ -41,8 +40,8 @@ type CdWorkflowRepository interface {
FindCdWorkflowMetaByEnvironmentId(appId int, environmentId int, offset int, size int) ([]CdWorkflowRunner, error)
FindCdWorkflowMetaByPipelineId(pipelineId int, offset int, size int) ([]CdWorkflowRunner, error)
FindArtifactByPipelineIdAndRunnerType(pipelineId int, runnerType apiBean.WorkflowType, limit int, runnerStatuses []string) ([]CdWorkflowRunner, error)
SaveWorkFlowRunner(wfr *CdWorkflowRunner) (*CdWorkflowRunner, error)
UpdateWorkFlowRunner(wfr *CdWorkflowRunner) error
SaveWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) (*CdWorkflowRunner, error)
UpdateWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) error
UpdateIsArtifactUploaded(wfrId int, isArtifactUploaded workflow.ArtifactUploadedType) error
GetPreviousQueuedRunners(cdWfrId, pipelineId int) ([]*CdWorkflowRunner, error)
UpdateRunnerStatusToFailedForIds(errMsg string, triggeredBy int32, cdWfrIds ...int) error
Expand Down Expand Up @@ -452,14 +451,14 @@ func (impl *CdWorkflowRepositoryImpl) FindLastPreOrPostTriggeredByEnvironmentId(
return wfr, err
}

func (impl *CdWorkflowRepositoryImpl) SaveWorkFlowRunner(wfr *CdWorkflowRunner) (*CdWorkflowRunner, error) {
err := impl.dbConnection.Insert(wfr)
func (impl *CdWorkflowRepositoryImpl) SaveWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) (*CdWorkflowRunner, error) {
err := tx.Insert(wfr)
return wfr, err
}

func (impl *CdWorkflowRepositoryImpl) UpdateWorkFlowRunner(wfr *CdWorkflowRunner) error {
func (impl *CdWorkflowRepositoryImpl) UpdateWorkFlowRunnerWithTx(wfr *CdWorkflowRunner, tx *pg.Tx) error {
wfr.Message = util.GetTruncatedMessage(wfr.Message, 1000)
err := impl.dbConnection.Update(wfr)
err := tx.Update(wfr)
return err
}

Expand Down Expand Up @@ -539,10 +538,9 @@ func (impl *CdWorkflowRepositoryImpl) FindBasicWorkflowRunnerById(wfrId int) (*C

func (impl *CdWorkflowRepositoryImpl) FindRetriedWorkflowCountByReferenceId(wfrId int) (int, error) {
retryCount := 0
query := fmt.Sprintf("select count(id) "+
"from cd_workflow_runner where ref_cd_workflow_runner_id = %v", wfrId)
query := "select count(id) from cd_workflow_runner where ref_cd_workflow_runner_id = ?"

_, err := impl.dbConnection.Query(&retryCount, query)
_, err := impl.dbConnection.Query(&retryCount, query, wfrId)
return retryCount, err
}

Expand Down
24 changes: 10 additions & 14 deletions internal/sql/repository/pipelineConfig/CiWorkflowRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
package pipelineConfig

import (
"fmt"
"github.com/devtron-labs/devtron/internal/sql/constants"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
"github.com/go-pg/pg"
Expand All @@ -28,9 +26,9 @@ import (
)

type CiWorkflowRepository interface {
SaveWorkFlow(wf *CiWorkflow) error
SaveWorkFlowWithTx(wf *CiWorkflow, tx *pg.Tx) error
FindLastTriggeredWorkflow(pipelineId int) (*CiWorkflow, error)
UpdateWorkFlow(wf *CiWorkflow) error
UpdateWorkFlowWithTx(wf *CiWorkflow, tx *pg.Tx) error
UpdateArtifactUploaded(id int, isUploaded workflow.ArtifactUploadedType) error
FindByStatusesIn(activeStatuses []string) ([]*CiWorkflow, error)
FindByPipelineId(pipelineId int, offset int, size int) ([]WorkflowWithArtifact, error)
Expand Down Expand Up @@ -236,10 +234,9 @@ func (impl *CiWorkflowRepositoryImpl) FindById(id int) (*CiWorkflow, error) {

func (impl *CiWorkflowRepositoryImpl) FindRetriedWorkflowCountByReferenceId(id int) (int, error) {
retryCount := 0
query := fmt.Sprintf("select count(*) "+
"from ci_workflow where ref_ci_workflow_id = %v", id)
query := "select count(*) from ci_workflow where ref_ci_workflow_id = ?"

_, err := impl.dbConnection.Query(&retryCount, query)
_, err := impl.dbConnection.Query(&retryCount, query, id)
return retryCount, err
}

Expand All @@ -266,13 +263,13 @@ func (impl *CiWorkflowRepositoryImpl) FindCiWorkflowGitTriggersByIds(ids []int)
return workflows, err
}

func (impl *CiWorkflowRepositoryImpl) SaveWorkFlow(wf *CiWorkflow) error {
err := impl.dbConnection.Insert(wf)
func (impl *CiWorkflowRepositoryImpl) SaveWorkFlowWithTx(wf *CiWorkflow, tx *pg.Tx) error {
err := tx.Insert(wf)
return err
}

func (impl *CiWorkflowRepositoryImpl) UpdateWorkFlow(wf *CiWorkflow) error {
err := impl.dbConnection.Update(wf)
func (impl *CiWorkflowRepositoryImpl) UpdateWorkFlowWithTx(wf *CiWorkflow, tx *pg.Tx) error {
err := tx.Update(wf)
return err
}

Expand Down Expand Up @@ -339,9 +336,8 @@ func (impl *CiWorkflowRepositoryImpl) FindLastTriggeredWorkflowGitTriggersByArti
}
query := "SELECT cw.git_triggers,cw.id,cw.triggered_by,cw.ci_pipeline_id,cia.id as ci_artifact_id" +
" FROM ci_workflow cw INNER JOIN ci_artifact cia on cia.ci_workflow_id = cw.id " +
" WHERE cia.id IN (%s)"
query = fmt.Sprintf(query, helper.GetCommaSepratedString(ciArtifactIds))
_, err := impl.dbConnection.Query(&workflows, query)
" WHERE cia.id IN (?)"
_, err := impl.dbConnection.Query(&workflows, query, pg.In(ciArtifactIds))
return workflows, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/devtron-labs/devtron/client/argocdServer/bean"
)

var WfrTerminalStatusList = []string{WorkflowAborted, WorkflowFailed, WorkflowSucceeded, bean.HIBERNATING, string(health.HealthStatusHealthy), string(health.HealthStatusDegraded)}
var WfrTerminalStatusList = []string{WorkflowAborted, WorkflowFailed, WorkflowSucceeded, bean.HIBERNATING, string(health.HealthStatusHealthy), string(health.HealthStatusDegraded), WorkflowTimedOut, WorkflowCancel}

type WorkflowStatus int

Expand Down Expand Up @@ -34,6 +34,7 @@ const (
WorkflowTypeDeploy = "DEPLOY"
WorkflowTypePre = "PRE"
WorkflowTypePost = "POST"
WorkflowWaitingToStart = "WaitingToStart"
)

func (a WorkflowStatus) String() string {
Expand All @@ -60,3 +61,6 @@ type CdWorkflowRunnerArtifactMetadata struct {
ParentCiArtifact int `pg:"parent_ci_artifact"`
Scanned bool `pg:"scanned"`
}

const WorkflowCancel = "CANCELLED"
const POD_DELETED_MESSAGE = "pod deleted"
10 changes: 10 additions & 0 deletions internal/util/adapter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package util

func GetApiErrorAdapter(httpStatusCode int, code, userMessage, internalMessage string) *ApiError {
return &ApiError{
HttpStatusCode: httpStatusCode,
Code: code,
UserMessage: userMessage,
InternalMessage: internalMessage,
}
}
Loading
Loading