Skip to content

Commit 978d81c

Browse files
Limit norman API use of downstream cluster caches
1 parent 9dc3239 commit 978d81c

File tree

30 files changed

+131
-82
lines changed

30 files changed

+131
-82
lines changed

pkg/api/norman/customization/cluster/actions_kubeconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (a ActionHandler) GenerateKubeconfigActionHandler(actionName string, action
6565

6666
if endpointEnabled {
6767
clusterName := apiContext.ID
68-
clusterClient, err := a.ClusterManager.UserContext(clusterName)
68+
clusterClient, err := a.ClusterManager.UserContextNoControllers(clusterName)
6969
if err != nil {
7070
return err
7171
}

pkg/api/norman/customization/cluster/actions_yaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (a ActionHandler) processYAML(apiContext *types.APIContext, clusterName, pr
178178
}
179179

180180
func (a ActionHandler) findOrCreateProjectNamespaces(apiContext *types.APIContext, namespaces []string, clusterName, projectName string) (corev1.NamespaceInterface, error) {
181-
userCtx, err := a.ClusterManager.UserContext(clusterName)
181+
userCtx, err := a.ClusterManager.UserContextNoControllers(clusterName)
182182
if err != nil {
183183
return nil, err
184184
}

pkg/api/norman/customization/cluster/shell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type ShellLinkHandler struct {
2525
}
2626

2727
func (s *ShellLinkHandler) LinkHandler(apiContext *types.APIContext, next types.RequestHandler) error {
28-
context, err := s.ClusterManager.UserContext(apiContext.ID)
28+
context, err := s.ClusterManager.UserContextNoControllers(apiContext.ID)
2929
if err != nil {
3030
return err
3131
}

pkg/api/norman/customization/clusterscan/clusterscan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (h Handler) LinkHandler(apiContext *types.APIContext, next types.RequestHan
9090

9191
clusterID, clusterScanID := ref.Parse(cs["id"].(string))
9292

93-
clusterContext, err := h.ClusterManager.UserContext(clusterID)
93+
clusterContext, err := h.ClusterManager.UserContextNoControllers(clusterID)
9494
if err != nil {
9595
return err
9696
}

pkg/api/norman/customization/logging/action.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ func (h *Handler) testLoggingTarget(ctx context.Context, clusterName string, tar
174174
}
175175

176176
func (h *Handler) dryRunLoggingTarget(apiContext *types.APIContext, level, clusterName, projectID string, target v33.LoggingTargets) error {
177-
context, err := h.clusterManager.UserContext(clusterName)
177+
context, err := h.clusterManager.UserContextNoControllers(clusterName)
178178
if err != nil {
179179
return err
180180
}
181181

182-
podLister := context.Core.Pods(metav1.NamespaceAll).Controller().Lister()
182+
pods := context.Core.Pods(metav1.NamespaceAll)
183183
namespaces := context.Core.Namespaces(metav1.NamespaceAll)
184-
testerDeployer := deployer.NewTesterDeployer(context.Management, h.appsGetter, h.appLister, h.projectLister, podLister, h.projectLoggingLister, namespaces, h.templateLister)
184+
testerDeployer := deployer.NewTesterDeployer(context.Management, h.appsGetter, h.appLister, h.projectLister, pods, h.projectLoggingLister, namespaces, h.templateLister)
185185
configGenerator := configsyncer.NewConfigGenerator(metav1.NamespaceAll, h.projectLoggingLister, namespaces.Controller().Lister())
186186

187187
var dryRunConfigBuf []byte

pkg/api/norman/customization/monitor/cluster_graph_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (h *ClusterGraphHandler) QuerySeriesAction(actionName string, action *types
6666
}
6767

6868
clusterName := inputParser.ClusterName
69-
userContext, err := h.clustermanager.UserContext(clusterName)
69+
userContext, err := h.clustermanager.UserContextNoControllers(clusterName)
7070
if err != nil {
7171
return fmt.Errorf("get usercontext failed, %v", err)
7272
}

pkg/api/norman/customization/monitor/handler_utils.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,16 @@ func (p *projectGraphInputParser) parseFilter() error {
124124
}
125125

126126
type authChecker struct {
127-
ProjectID string
128-
Input *v32.QueryGraphInput
129-
UserContext *config.UserContext
130-
WorkloadController workload.CommonController
127+
ProjectID string
128+
Input *v32.QueryGraphInput
129+
UserContext *config.UserContext
131130
}
132131

133132
func newAuthChecker(ctx context.Context, userContext *config.UserContext, input *v32.QueryGraphInput, projectID string) *authChecker {
134133
return &authChecker{
135-
ProjectID: projectID,
136-
Input: input,
137-
UserContext: userContext,
138-
WorkloadController: workload.NewWorkloadController(ctx, userContext.UserOnlyContext(), nil),
134+
ProjectID: projectID,
135+
Input: input,
136+
UserContext: userContext,
139137
}
140138
}
141139

pkg/api/norman/customization/monitor/metric_action.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (h *MetricHandler) Action(actionName string, action *types.Action, apiConte
8282
return err
8383
}
8484

85-
userContext, err := h.clustermanager.UserContext(clusterName)
85+
userContext, err := h.clustermanager.UserContextNoControllers(clusterName)
8686
if err != nil {
8787
return fmt.Errorf("get usercontext failed, %v", err)
8888
}
@@ -137,7 +137,7 @@ func (h *MetricHandler) Action(actionName string, action *types.Action, apiConte
137137
return fmt.Errorf("clusterName is empty")
138138
}
139139

140-
userContext, err := h.clustermanager.UserContext(clusterName)
140+
userContext, err := h.clustermanager.UserContextNoControllers(clusterName)
141141
if err != nil {
142142
return fmt.Errorf("get usercontext failed, %v", err)
143143
}
@@ -185,7 +185,7 @@ func (h *MetricHandler) Action(actionName string, action *types.Action, apiConte
185185
return fmt.Errorf("clusterName is empty")
186186
}
187187

188-
userContext, err := h.clustermanager.UserContext(clusterName)
188+
userContext, err := h.clustermanager.UserContextNoControllers(clusterName)
189189
if err != nil {
190190
return fmt.Errorf("get usercontext failed, %v", err)
191191
}

pkg/api/norman/customization/monitor/project_graph_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (h *ProjectGraphHandler) QuerySeriesAction(actionName string, action *types
5858
}
5959

6060
clusterName := inputParser.ClusterName
61-
userContext, err := h.clustermanager.UserContext(clusterName)
61+
userContext, err := h.clustermanager.UserContextNoControllers(clusterName)
6262
if err != nil {
6363
return fmt.Errorf("get usercontext failed, %v", err)
6464
}

pkg/api/norman/customization/namespace/link.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (s *yamlLinkHandler) LinkHandler(apiContext *types.APIContext, next types.R
5050

5151
clusterName := s.clusterManagement.ClusterName(apiContext)
5252

53-
userContext, err := s.clusterManagement.UserContext(clusterName)
53+
userContext, err := s.clusterManagement.UserContextNoControllers(clusterName)
5454
if err != nil {
5555
return err
5656
}

0 commit comments

Comments
 (0)