Skip to content

Commit 9b21172

Browse files
Merge pull request #6777 from devtron-labs/release-candidate-v0.41.0
sync: Release candidate v0.41.0
2 parents a447ff7 + b7855b4 commit 9b21172

File tree

344 files changed

+93486
-981
lines changed

Some content is hidden

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

344 files changed

+93486
-981
lines changed

Wire.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ import (
103103
app2 "github.com/devtron-labs/devtron/internal/sql/repository/app"
104104
appStatusRepo "github.com/devtron-labs/devtron/internal/sql/repository/appStatus"
105105
appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow"
106-
"github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate"
107106
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
108107
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
109108
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
@@ -128,6 +127,7 @@ import (
128127
"github.com/devtron-labs/devtron/pkg/build"
129128
"github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging"
130129
pipeline6 "github.com/devtron-labs/devtron/pkg/build/pipeline"
130+
repository11 "github.com/devtron-labs/devtron/pkg/bulkAction/repository"
131131
"github.com/devtron-labs/devtron/pkg/bulkAction/service"
132132
"github.com/devtron-labs/devtron/pkg/chart"
133133
"github.com/devtron-labs/devtron/pkg/chart/gitOpsConfig"
@@ -268,8 +268,8 @@ func InitializeApp() (*App, error) {
268268
app.NewAppService,
269269
wire.Bind(new(app.AppService), new(*app.AppServiceImpl)),
270270

271-
bulkUpdate.NewBulkUpdateRepository,
272-
wire.Bind(new(bulkUpdate.BulkUpdateRepository), new(*bulkUpdate.BulkUpdateRepositoryImpl)),
271+
repository11.NewBulkEditRepository,
272+
wire.Bind(new(repository11.BulkEditRepository), new(*repository11.BulkEditRepositoryImpl)),
273273

274274
chartConfig.NewEnvConfigOverrideRepository,
275275
wire.Bind(new(chartConfig.EnvConfigOverrideRepository), new(*chartConfig.EnvConfigOverrideRepositoryImpl)),
@@ -372,6 +372,8 @@ func InitializeApp() (*App, error) {
372372
wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)),
373373
read2.NewChartReadServiceImpl,
374374
wire.Bind(new(read2.ChartReadService), new(*read2.ChartReadServiceImpl)),
375+
376+
service.NewBulkUpdateServiceEntImpl,
375377
service.NewBulkUpdateServiceImpl,
376378
wire.Bind(new(service.BulkUpdateService), new(*service.BulkUpdateServiceImpl)),
377379

api/cluster/ClusterRestHandler.go

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import (
2020
"context"
2121
"encoding/json"
2222
"errors"
23-
bean2 "github.com/devtron-labs/devtron/pkg/cluster/bean"
24-
"github.com/devtron-labs/devtron/pkg/cluster/environment"
25-
"github.com/devtron-labs/devtron/pkg/cluster/rbac"
2623
"net/http"
2724
"strconv"
2825
"strings"
2926
"time"
3027

28+
bean2 "github.com/devtron-labs/devtron/pkg/cluster/bean"
29+
"github.com/devtron-labs/devtron/pkg/cluster/environment"
30+
"github.com/devtron-labs/devtron/pkg/cluster/rbac"
31+
3132
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
3233
"github.com/devtron-labs/devtron/pkg/auth/user"
3334
"github.com/devtron-labs/devtron/pkg/genericNotes"
@@ -60,6 +61,7 @@ type ClusterRestHandler interface {
6061
GetClusterNamespaces(w http.ResponseWriter, r *http.Request)
6162
GetAllClusterNamespaces(w http.ResponseWriter, r *http.Request)
6263
FindAllForClusterPermission(w http.ResponseWriter, r *http.Request)
64+
FindByIds(w http.ResponseWriter, r *http.Request)
6365
}
6466

6567
type ClusterRestHandlerImpl struct {
@@ -288,6 +290,7 @@ func (impl ClusterRestHandlerImpl) FindAll(w http.ResponseWriter, r *http.Reques
288290
var result []*bean2.ClusterBean
289291
for _, item := range clusterList {
290292
if ok := impl.enforcer.Enforce(token, casbin.ResourceCluster, casbin.ActionGet, item.ClusterName); ok {
293+
item.SetClusterStatus()
291294
result = append(result, item)
292295
}
293296
}
@@ -296,6 +299,61 @@ func (impl ClusterRestHandlerImpl) FindAll(w http.ResponseWriter, r *http.Reques
296299
common.WriteJsonResp(w, err, result, http.StatusOK)
297300
}
298301

302+
func (impl ClusterRestHandlerImpl) FindByIds(w http.ResponseWriter, r *http.Request) {
303+
token := r.Header.Get("token")
304+
305+
// Parse clusterId query parameter
306+
clusterIdsStr := r.URL.Query().Get("clusterId")
307+
if clusterIdsStr == "" {
308+
// If no clusterId parameter, return all clusters (same as FindAll)
309+
impl.FindAll(w, r)
310+
return
311+
}
312+
313+
// Parse comma-separated cluster IDs
314+
var clusterIds []int
315+
clusterIdStrs := strings.Split(clusterIdsStr, ",")
316+
for _, idStr := range clusterIdStrs {
317+
idStr = strings.TrimSpace(idStr)
318+
if idStr == "" {
319+
continue
320+
}
321+
id, err := strconv.Atoi(idStr)
322+
if err != nil {
323+
impl.logger.Errorw("request err, FindByIds", "error", err, "clusterId", idStr)
324+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
325+
return
326+
}
327+
clusterIds = append(clusterIds, id)
328+
}
329+
330+
if len(clusterIds) == 0 {
331+
// If no valid cluster IDs, return empty result
332+
common.WriteJsonResp(w, nil, []*bean2.ClusterBean{}, http.StatusOK)
333+
return
334+
}
335+
336+
clusterList, err := impl.clusterService.FindByIdsWithoutConfig(clusterIds)
337+
if err != nil {
338+
impl.logger.Errorw("service err, FindByIds", "err", err)
339+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
340+
return
341+
}
342+
343+
// RBAC enforcer applying
344+
var result []*bean2.ClusterBean
345+
for _, item := range clusterList {
346+
if ok := impl.enforcer.Enforce(token, casbin.ResourceCluster, casbin.ActionGet, item.ClusterName); ok {
347+
item.SetClusterStatus()
348+
result = append(result, item)
349+
}
350+
351+
}
352+
//RBAC enforcer Ends
353+
354+
common.WriteJsonResp(w, nil, result, http.StatusOK)
355+
}
356+
299357
func (impl ClusterRestHandlerImpl) FindById(w http.ResponseWriter, r *http.Request) {
300358
vars := mux.Vars(r)
301359
id := vars["id"]
@@ -671,7 +729,14 @@ func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r
671729

672730
allClusterNamespaces, err := impl.clusterService.FindAllNamespacesByUserIdAndClusterId(userId, clusterId, isActionUserSuperAdmin)
673731
if err != nil {
674-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
732+
// Check if it's a cluster connectivity error and return appropriate status code
733+
if err.Error() == cluster.ErrClusterNotReachable {
734+
impl.logger.Errorw("cluster connectivity error in GetClusterNamespaces", "error", err, "clusterId", clusterId)
735+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
736+
} else {
737+
impl.logger.Errorw("error in GetClusterNamespaces", "error", err, "clusterId", clusterId)
738+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
739+
}
675740
return
676741
}
677742
common.WriteJsonResp(w, nil, allClusterNamespaces, http.StatusOK)

api/cluster/ClusterRouter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func (impl ClusterRouterImpl) InitClusterRouter(clusterRouter *mux.Router) {
5757
Queries("id", "{id}").
5858
HandlerFunc(impl.clusterRestHandler.FindNoteByClusterId)
5959

60+
clusterRouter.Path("").
61+
Methods("GET").
62+
Queries("clusterId", "{clusterId}").
63+
HandlerFunc(impl.clusterRestHandler.FindByIds)
64+
6065
clusterRouter.Path("").
6166
Methods("GET").
6267
HandlerFunc(impl.clusterRestHandler.FindAll)

0 commit comments

Comments
 (0)