Skip to content

Commit 916a9c1

Browse files
committed
Merge branch 'main' into project_field_cli_helm_apps
# Conflicts: # api/router/AppListingRouter.go
2 parents ddfd982 + c0a9030 commit 916a9c1

File tree

87 files changed

+6140
-1286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+6140
-1286
lines changed

.github/workflows/create-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,5 @@ jobs:
8484
then
8585
echo "Not sending notification due to beta"
8686
fi
87+
env:
88+
RELEASE_BRANCH: ${{ secrets.RELEASE_BRANCH }}

CHANGELOG/release-notes-v0.6.10.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## v0.6.10
2+
3+
## Bugs
4+
- fix: safe check added if cell value is not found in resource list (#2839)
5+
## Enhancements
6+
- feat: Resource viewer implementation for a cluster (#2811)
7+
- feat: Deployment status restructuring (#2806)
8+
9+
10+
## v0.6.10-rc.1
11+
12+
## Bugs
13+
- fix: cluster name passed in node metadata list (#2804)
14+
- fix: Chart with nested directory (#2797)
15+
## Enhancements
16+
- feat: added support for node-[delete, cordon, drain, taint edit] (#2805)
17+
- feat: Cluster terminal multiple image support (#2815)
18+
## Documentation
19+
- docs: minor correction in ingress yaml (#2819)
20+
- docs: updated cluster server url (#2816)
21+
- docs: minor updates (#2800)
22+
- docs: updated-global-configs (#2712)
23+
- docs: added deployment status shows failed or degraded in troubleshooting section (#2795)
24+
- docs: uninstall minor updates (#2788)
25+
- docs: Updated devtron admin password reset doc (#2785)
26+
27+
28+
## v0.6.10-rc.0
29+
30+
## Bugs
31+
- fix: Authenticator updated - handling api token (#2745)
32+
- fix: Ci workflow status update when workflow stuck. (#2726)
33+
- fix: Update Chart.yaml for security integration chart fix (#2771)
34+
- fix: Helm app proxy chart auto fix (#2754)
35+
- fix: No need to bounce orchestrator if SSO config are added/updated (#2753)
36+
- fix: ArgoCD Connection Manager connection handling (#2702)
37+
## Enhancements
38+
- feat: added new chart for job and cronjob with keda scaledjob support (#2749)
39+
## Documentation
40+
- docs: deployment updates (#2769)
41+
- docs: deployment template doc (#2770)
42+
- docs: install command corrected (#2775)
43+
- docs: broken links fixed in doc v0.6 (#2776)
44+
45+
46+

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ GIT_COMMIT =$(shell sh -c 'git log --pretty=format:'%h' -n 1')
1515
BUILD_TIME= $(shell sh -c 'date -u '+%Y-%m-%dT%H:%M:%SZ'')
1616
SERVER_MODE_FULL= FULL
1717
SERVER_MODE_EA_ONLY=EA_ONLY
18+
#TEST_BRANCH=PUT_YOUR_BRANCH_HERE
19+
#LATEST_HASH=PUT_YOUR_HASH_HERE
1820
include $(ENV_FILE)
1921
export
2022

21-
build: clean wire test
23+
build: clean wire test-all
2224
$(ENVVAR) GOOS=$(GOOS) go build -o devtron \
2325
-ldflags="-X 'github.com/devtron-labs/devtron/util.GitCommit=${GIT_COMMIT}' \
2426
-X 'github.com/devtron-labs/devtron/util.BuildTime=${BUILD_TIME}' \
@@ -30,9 +32,17 @@ wire:
3032
clean:
3133
rm -f devtron
3234

33-
test:
35+
test-all: test-unit
36+
echo 'test cases ran successfully'
37+
38+
test-unit:
3439
go test ./pkg/pipeline
3540

41+
test-integration:
42+
export INTEGRATION_TEST_ENV_ID=$(docker run --env TEST_BRANCH=$TEST_BRANCH --env LATEST_HASH=$LATEST_HASH --privileged -d --name dind-test -v $PWD/tests/integrationTesting/:/tmp/ docker:dind)
43+
docker exec ${INTEGRATION_TEST_ENV_ID} sh /tmp/create-test-env.sh
44+
docker exec ${INTEGRATION_TEST_ENV_ID} sh /tests/integrationTesting/run-integration-test.sh
45+
3646
run: build
3747
./devtron
3848

Wire.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ import (
9191
"github.com/devtron-labs/devtron/pkg/git"
9292
"github.com/devtron-labs/devtron/pkg/gitops"
9393
jira2 "github.com/devtron-labs/devtron/pkg/jira"
94+
"github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs"
95+
repository7 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository"
9496
"github.com/devtron-labs/devtron/pkg/notifier"
9597
"github.com/devtron-labs/devtron/pkg/pipeline"
9698
history3 "github.com/devtron-labs/devtron/pkg/pipeline/history"
@@ -169,7 +171,7 @@ func InitializeApp() (*App, error) {
169171

170172
restHandler.NewPipelineRestHandler,
171173
wire.Bind(new(restHandler.PipelineTriggerRestHandler), new(*restHandler.PipelineTriggerRestHandlerImpl)),
172-
174+
app.GetAppStatusConfig,
173175
app.NewAppService,
174176
wire.Bind(new(app.AppService), new(*app.AppServiceImpl)),
175177

@@ -745,15 +747,14 @@ func InitializeApp() (*App, error) {
745747
wire.Bind(new(argo.ArgoUserService), new(*argo.ArgoUserServiceImpl)),
746748
util2.GetDevtronSecretName,
747749
// AuthWireSet,
748-
cron.GetAppStatusConfig,
750+
749751
cron.NewCdApplicationStatusUpdateHandlerImpl,
750752
wire.Bind(new(cron.CdApplicationStatusUpdateHandler), new(*cron.CdApplicationStatusUpdateHandlerImpl)),
751753

752754
cron.GetCiWorkflowStatusUpdateConfig,
753755
cron.NewCiStatusUpdateCronImpl,
754756
wire.Bind(new(cron.CiStatusUpdateCron), new(*cron.CiStatusUpdateCronImpl)),
755757

756-
757758
restHandler.NewPipelineStatusTimelineRestHandlerImpl,
758759
wire.Bind(new(restHandler.PipelineStatusTimelineRestHandler), new(*restHandler.PipelineStatusTimelineRestHandlerImpl)),
759760

@@ -793,6 +794,22 @@ func InitializeApp() (*App, error) {
793794
wire.Bind(new(chartRepoRepository.GlobalStrategyMetadataRepository), new(*chartRepoRepository.GlobalStrategyMetadataRepositoryImpl)),
794795
chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl,
795796
wire.Bind(new(chartRepoRepository.GlobalStrategyMetadataChartRefMappingRepository), new(*chartRepoRepository.GlobalStrategyMetadataChartRefMappingRepositoryImpl)),
797+
798+
app.NewPipelineStatusTimelineResourcesServiceImpl,
799+
wire.Bind(new(app.PipelineStatusTimelineResourcesService), new(*app.PipelineStatusTimelineResourcesServiceImpl)),
800+
pipelineConfig.NewPipelineStatusTimelineResourcesRepositoryImpl,
801+
wire.Bind(new(pipelineConfig.PipelineStatusTimelineResourcesRepository), new(*pipelineConfig.PipelineStatusTimelineResourcesRepositoryImpl)),
802+
803+
app.NewPipelineStatusSyncDetailServiceImpl,
804+
wire.Bind(new(app.PipelineStatusSyncDetailService), new(*app.PipelineStatusSyncDetailServiceImpl)),
805+
pipelineConfig.NewPipelineStatusSyncDetailRepositoryImpl,
806+
wire.Bind(new(pipelineConfig.PipelineStatusSyncDetailRepository), new(*pipelineConfig.PipelineStatusSyncDetailRepositoryImpl)),
807+
808+
repository7.NewK8sResourceHistoryRepositoryImpl,
809+
wire.Bind(new(repository7.K8sResourceHistoryRepository), new(*repository7.K8sResourceHistoryRepositoryImpl)),
810+
811+
kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl,
812+
wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)),
796813
)
797814
return &App{}, nil
798815
}

api/restHandler/AppListingRestHandler.go

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/devtron-labs/devtron/client/argocdServer/application"
3131
"github.com/devtron-labs/devtron/client/cron"
3232
"github.com/devtron-labs/devtron/internal/constants"
33+
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
3334
"github.com/devtron-labs/devtron/internal/util"
3435
"github.com/devtron-labs/devtron/pkg/app"
3536
service1 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
@@ -61,6 +62,8 @@ type AppListingRestHandler interface {
6162
FetchOtherEnvironment(w http.ResponseWriter, r *http.Request)
6263
RedirectToLinkouts(w http.ResponseWriter, r *http.Request)
6364
GetHostUrlsByBatch(w http.ResponseWriter, r *http.Request)
65+
66+
ManualSyncAcdPipelineDeploymentStatus(w http.ResponseWriter, r *http.Request)
6467
}
6568

6669
type AppListingRestHandlerImpl struct {
@@ -80,6 +83,7 @@ type AppListingRestHandlerImpl struct {
8083
k8sApplicationService k8s.K8sApplicationService
8184
installedAppService service1.InstalledAppService
8285
cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler
86+
pipelineRepository pipelineConfig.PipelineRepository
8387
}
8488

8589
type AppStatus struct {
@@ -99,7 +103,8 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient,
99103
deploymentGroupService deploymentGroup.DeploymentGroupService, userService user.UserService,
100104
helmAppClient client.HelmAppClient, clusterService cluster.ClusterService, helmAppService client.HelmAppService,
101105
argoUserService argo.ArgoUserService, k8sApplicationService k8s.K8sApplicationService, installedAppService service1.InstalledAppService,
102-
cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler) *AppListingRestHandlerImpl {
106+
cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler,
107+
pipelineRepository pipelineConfig.PipelineRepository) *AppListingRestHandlerImpl {
103108
appListingHandler := &AppListingRestHandlerImpl{
104109
application: application,
105110
appListingService: appListingService,
@@ -117,6 +122,7 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient,
117122
k8sApplicationService: k8sApplicationService,
118123
installedAppService: installedAppService,
119124
cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler,
125+
pipelineRepository: pipelineRepository,
120126
}
121127
return appListingHandler
122128
}
@@ -703,12 +709,23 @@ func (handler AppListingRestHandlerImpl) getAppDetails(appIdParam, installedAppI
703709
return appDetail, err, appId
704710
}
705711

712+
// TODO: move this to service
706713
func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter, r *http.Request, appId int, envId int, appDetail bean.AppDetailContainer) bean.AppDetailContainer {
707714
if len(appDetail.AppName) > 0 && len(appDetail.EnvironmentName) > 0 && util.IsAcdApp(appDetail.DeploymentAppType) {
708715
//RBAC enforcer Ends
709-
acdAppName := appDetail.AppName + "-" + appDetail.EnvironmentName
716+
cdPipelines, err := handler.pipelineRepository.FindActiveByAppIdAndEnvironmentId(appId, envId)
717+
if err != nil {
718+
handler.logger.Errorw("error in getting cdPipeline by appId and envId", "err", err, "appid", appId, "envId", envId)
719+
common.WriteJsonResp(w, err, "", http.StatusInternalServerError)
720+
return appDetail
721+
}
722+
if len(cdPipelines) != 1 {
723+
common.WriteJsonResp(w, err, "", http.StatusInternalServerError)
724+
return appDetail
725+
}
726+
cdPipeline := cdPipelines[0]
710727
query := &application2.ResourcesQuery{
711-
ApplicationName: &acdAppName,
728+
ApplicationName: &cdPipeline.DeploymentAppName,
712729
}
713730
ctx, cancel := context.WithCancel(r.Context())
714731
if cn, ok := w.(http.CloseNotifier); ok {
@@ -761,7 +778,7 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter
761778
}
762779
appDetail.ResourceTree = util2.InterfaceToMapAdapter(resp)
763780
if resp.Status == string(health.HealthStatusHealthy) {
764-
err = handler.cdApplicationStatusUpdateHandler.SyncPipelineStatusForResourceTreeCall(acdAppName, appId, envId)
781+
err = handler.cdApplicationStatusUpdateHandler.SyncPipelineStatusForResourceTreeCall(cdPipeline)
765782
if err != nil {
766783
handler.logger.Errorw("error in syncing pipeline status", "err", err)
767784
}
@@ -794,3 +811,45 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter
794811
}
795812
return appDetail
796813
}
814+
815+
func (handler AppListingRestHandlerImpl) ManualSyncAcdPipelineDeploymentStatus(w http.ResponseWriter, r *http.Request) {
816+
token := r.Header.Get("token")
817+
vars := mux.Vars(r)
818+
userId, err := handler.userService.GetLoggedInUser(r)
819+
if userId == 0 || err != nil {
820+
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
821+
return
822+
}
823+
appId, err := strconv.Atoi(vars["appId"])
824+
if err != nil {
825+
handler.logger.Errorw("request err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "appId", appId)
826+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
827+
return
828+
}
829+
envId, err := strconv.Atoi(vars["envId"])
830+
if err != nil {
831+
handler.logger.Errorw("request err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "envId", envId)
832+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
833+
return
834+
}
835+
app, err := handler.pipeline.GetApp(appId)
836+
if err != nil {
837+
handler.logger.Errorw("bad request", "err", err)
838+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
839+
return
840+
}
841+
// RBAC enforcer applying
842+
object := handler.enforcerUtil.GetAppRBACName(app.AppName)
843+
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, object); !ok {
844+
common.WriteJsonResp(w, err, "unauthorized user", http.StatusForbidden)
845+
return
846+
}
847+
//RBAC enforcer Ends
848+
err = handler.cdApplicationStatusUpdateHandler.ManualSyncPipelineStatus(appId, envId, userId)
849+
if err != nil {
850+
handler.logger.Errorw("service err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "appId", appId, "envId", envId)
851+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
852+
return
853+
}
854+
common.WriteJsonResp(w, nil, "App synced successfully.", http.StatusOK)
855+
}

api/restHandler/ArgoApplicationRestHandler.go

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import (
2626
"github.com/devtron-labs/devtron/api/restHandler/common"
2727
"github.com/devtron-labs/devtron/client/argocdServer/application"
2828
"github.com/devtron-labs/devtron/pkg/cluster"
29+
"github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs"
2930
"github.com/devtron-labs/devtron/pkg/team"
3031
"github.com/devtron-labs/devtron/pkg/terminal"
32+
"github.com/devtron-labs/devtron/pkg/user"
3133
"github.com/devtron-labs/devtron/pkg/user/casbin"
3234
"github.com/devtron-labs/devtron/util"
3335
"github.com/devtron-labs/devtron/util/argo"
@@ -63,15 +65,17 @@ type ArgoApplicationRestHandler interface {
6365
}
6466

6567
type ArgoApplicationRestHandlerImpl struct {
66-
client application.ServiceClient
67-
logger *zap.SugaredLogger
68-
pump connector.Pump
69-
enforcer casbin.Enforcer
70-
teamService team.TeamService
71-
environmentService cluster.EnvironmentService
72-
enforcerUtil rbac.EnforcerUtil
73-
terminalSessionHandler terminal.TerminalSessionHandler
74-
argoUserService argo.ArgoUserService
68+
client application.ServiceClient
69+
logger *zap.SugaredLogger
70+
pump connector.Pump
71+
enforcer casbin.Enforcer
72+
teamService team.TeamService
73+
environmentService cluster.EnvironmentService
74+
enforcerUtil rbac.EnforcerUtil
75+
terminalSessionHandler terminal.TerminalSessionHandler
76+
argoUserService argo.ArgoUserService
77+
K8sResourceHistoryService kubernetesResourceAuditLogs.K8sResourceHistoryService
78+
userService user.UserService
7579
}
7680

7781
func NewArgoApplicationRestHandlerImpl(client application.ServiceClient,
@@ -82,17 +86,21 @@ func NewArgoApplicationRestHandlerImpl(client application.ServiceClient,
8286
logger *zap.SugaredLogger,
8387
enforcerUtil rbac.EnforcerUtil,
8488
terminalSessionHandler terminal.TerminalSessionHandler,
85-
argoUserService argo.ArgoUserService) *ArgoApplicationRestHandlerImpl {
89+
argoUserService argo.ArgoUserService,
90+
K8sResourceHistoryService kubernetesResourceAuditLogs.K8sResourceHistoryService,
91+
userService user.UserService) *ArgoApplicationRestHandlerImpl {
8692
return &ArgoApplicationRestHandlerImpl{
87-
client: client,
88-
logger: logger,
89-
pump: pump,
90-
enforcer: enforcer,
91-
teamService: teamService,
92-
environmentService: environmentService,
93-
enforcerUtil: enforcerUtil,
94-
terminalSessionHandler: terminalSessionHandler,
95-
argoUserService: argoUserService,
93+
client: client,
94+
logger: logger,
95+
pump: pump,
96+
enforcer: enforcer,
97+
teamService: teamService,
98+
environmentService: environmentService,
99+
enforcerUtil: enforcerUtil,
100+
terminalSessionHandler: terminalSessionHandler,
101+
argoUserService: argoUserService,
102+
K8sResourceHistoryService: K8sResourceHistoryService,
103+
userService: userService,
96104
}
97105
}
98106

@@ -604,6 +612,14 @@ func (impl ArgoApplicationRestHandlerImpl) PatchResource(w http.ResponseWriter,
604612
}
605613

606614
func (impl ArgoApplicationRestHandlerImpl) DeleteResource(w http.ResponseWriter, r *http.Request) {
615+
616+
userId, err := impl.userService.GetLoggedInUser(r)
617+
618+
if err != nil {
619+
// not returning err because userId is only needed for audit logs and not impacting delete functionality.
620+
impl.logger.Errorw("error in getting logged in user for audit logs of k8s resource")
621+
}
622+
607623
vars := mux.Vars(r)
608624
appNameACD := vars["appNameACD"]
609625
name := vars["name"]
@@ -677,6 +693,14 @@ func (impl ArgoApplicationRestHandlerImpl) DeleteResource(w http.ResponseWriter,
677693
ctx = context.WithValue(ctx, "token", acdToken)
678694
defer cancel()
679695
recv, err := impl.client.DeleteResource(ctx, query)
696+
697+
if err == nil {
698+
ResourceHistoryErr := impl.K8sResourceHistoryService.SaveArgoCdAppsResourceDeleteHistory(query, id, eId, userId)
699+
if ResourceHistoryErr != nil {
700+
impl.logger.Errorw("error in saving audit logs of delete resource request for argo cd apps", "err", ResourceHistoryErr)
701+
}
702+
}
703+
680704
impl.pump.StartMessage(w, recv, err)
681705
}
682706

0 commit comments

Comments
 (0)