Skip to content

Commit ac8ccbc

Browse files
Rebased with lastest main
1 parent b3704fd commit ac8ccbc

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

pkg/kubernetes/nodes.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
v1 "k8s.io/api/core/v1"
1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
"k8s.io/apimachinery/pkg/util/httpstream"
1516
"k8s.io/apimachinery/pkg/util/rand"
1617
"k8s.io/client-go/tools/remotecommand"
1718
"k8s.io/metrics/pkg/apis/metrics"
@@ -169,7 +170,7 @@ func (k *Kubernetes) NodesFiles(ctx context.Context, opts NodeFilesOptions) (str
169170
}
170171

171172
// Create the pod
172-
pods, err := k.manager.accessControlClientSet.Pods(opts.Namespace)
173+
pods, err := k.AccessControlClientset().Pods(opts.Namespace)
173174
if err != nil {
174175
return "", fmt.Errorf("failed to get pods client: %w", err)
175176
}
@@ -288,7 +289,26 @@ func (k *Kubernetes) execInPod(ctx context.Context, namespace, podName string, c
288289
Stderr: true,
289290
}
290291

291-
executor, err := k.manager.accessControlClientSet.PodsExec(namespace, podName, podExecOptions)
292+
// Compute URL
293+
execRequest := k.AccessControlClientset().CoreV1().RESTClient().
294+
Post().
295+
Resource("pods").
296+
Namespace(namespace).
297+
Name(podName).
298+
SubResource("exec")
299+
execRequest.VersionedParams(podExecOptions, ParameterCodec)
300+
301+
spdyExec, err := remotecommand.NewSPDYExecutor(k.AccessControlClientset().cfg, "POST", execRequest.URL())
302+
if err != nil {
303+
return "", err
304+
}
305+
webSocketExec, err := remotecommand.NewWebSocketExecutor(k.AccessControlClientset().cfg, "GET", execRequest.URL().String())
306+
if err != nil {
307+
return "", err
308+
}
309+
executor, err := remotecommand.NewFallbackExecutor(webSocketExec, spdyExec, func(err error) bool {
310+
return httpstream.IsUpgradeFailure(err) || httpstream.IsHTTPSProxyError(err)
311+
})
292312
if err != nil {
293313
return "", err
294314
}
@@ -316,7 +336,7 @@ func (k *Kubernetes) execInPod(ctx context.Context, namespace, podName string, c
316336

317337
// waitForPodReady waits for a pod to be ready
318338
func (k *Kubernetes) waitForPodReady(ctx context.Context, namespace, podName string, timeout time.Duration) error {
319-
pods, err := k.manager.accessControlClientSet.Pods(namespace)
339+
pods, err := k.AccessControlClientset().Pods(namespace)
320340
if err != nil {
321341
return err
322342
}

pkg/mcp/testdata/toolsets-core-tools.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
{
3535
"annotations": {
3636
"title": "Node: Files",
37-
"readOnlyHint": false,
3837
"destructiveHint": true,
39-
"idempotentHint": false,
4038
"openWorldHint": true
4139
},
4240
"description": "Perform file operations (put, get, list) on a Kubernetes node filesystem by creating a privileged pod. WARNING: Requires privileged access to the node. This tool creates a temporary privileged pod that mounts the node's root filesystem to perform file operations. The pod is automatically deleted after the operation completes.",

pkg/mcp/testdata/toolsets-full-tools-multicluster-enum.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@
191191
{
192192
"annotations": {
193193
"title": "Node: Files",
194-
"readOnlyHint": false,
195194
"destructiveHint": true,
196-
"idempotentHint": false,
197195
"openWorldHint": true
198196
},
199197
"description": "Perform file operations (put, get, list) on a Kubernetes node filesystem by creating a privileged pod. WARNING: Requires privileged access to the node. This tool creates a temporary privileged pod that mounts the node's root filesystem to perform file operations. The pod is automatically deleted after the operation completes.",
@@ -277,7 +275,7 @@
277275
"type": "string"
278276
},
279277
"query": {
280-
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/<log-file-name>\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
278+
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/\u003clog-file-name\u003e\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
281279
"type": "string"
282280
},
283281
"tailLines": {
@@ -874,4 +872,4 @@
874872
},
875873
"name": "resources_scale"
876874
}
877-
]
875+
]

pkg/mcp/testdata/toolsets-full-tools-multicluster.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@
171171
{
172172
"annotations": {
173173
"title": "Node: Files",
174-
"readOnlyHint": false,
175174
"destructiveHint": true,
176-
"idempotentHint": false,
177175
"openWorldHint": true
178176
},
179177
"description": "Perform file operations (put, get, list) on a Kubernetes node filesystem by creating a privileged pod. WARNING: Requires privileged access to the node. This tool creates a temporary privileged pod that mounts the node's root filesystem to perform file operations. The pod is automatically deleted after the operation completes.",
@@ -249,7 +247,7 @@
249247
"type": "string"
250248
},
251249
"query": {
252-
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/<log-file-name>\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
250+
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/\u003clog-file-name\u003e\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
253251
"type": "string"
254252
},
255253
"tailLines": {
@@ -786,4 +784,4 @@
786784
},
787785
"name": "resources_scale"
788786
}
789-
]
787+
]

pkg/mcp/testdata/toolsets-full-tools-openshift.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@
135135
{
136136
"annotations": {
137137
"title": "Node: Files",
138-
"readOnlyHint": false,
139138
"destructiveHint": true,
140-
"idempotentHint": false,
141139
"openWorldHint": true
142140
},
143141
"description": "Perform file operations (put, get, list) on a Kubernetes node filesystem by creating a privileged pod. WARNING: Requires privileged access to the node. This tool creates a temporary privileged pod that mounts the node's root filesystem to perform file operations. The pod is automatically deleted after the operation completes.",
@@ -205,7 +203,7 @@
205203
"type": "string"
206204
},
207205
"query": {
208-
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/<log-file-name>\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
206+
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/\u003clog-file-name\u003e\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
209207
"type": "string"
210208
},
211209
"tailLines": {
@@ -695,4 +693,4 @@
695693
},
696694
"name": "resources_scale"
697695
}
698-
]
696+
]

pkg/mcp/testdata/toolsets-full-tools.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@
135135
{
136136
"annotations": {
137137
"title": "Node: Files",
138-
"readOnlyHint": false,
139138
"destructiveHint": true,
140-
"idempotentHint": false,
141139
"openWorldHint": true
142140
},
143141
"description": "Perform file operations (put, get, list) on a Kubernetes node filesystem by creating a privileged pod. WARNING: Requires privileged access to the node. This tool creates a temporary privileged pod that mounts the node's root filesystem to perform file operations. The pod is automatically deleted after the operation completes.",
@@ -205,7 +203,7 @@
205203
"type": "string"
206204
},
207205
"query": {
208-
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/<log-file-name>\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
206+
"description": "query specifies services(s) or files from which to return logs (required). Example: \"kubelet\" to fetch kubelet logs, \"/\u003clog-file-name\u003e\" to fetch a specific log file from the node (e.g., \"/var/log/kubelet.log\" or \"/var/log/kube-proxy.log\")",
209207
"type": "string"
210208
},
211209
"tailLines": {
@@ -682,4 +680,4 @@
682680
},
683681
"name": "resources_scale"
684682
}
685-
]
683+
]

0 commit comments

Comments
 (0)