@@ -22,6 +22,9 @@ import (
22
22
"k8s.io/client-go/rest"
23
23
"k8s.io/client-go/tools/remotecommand"
24
24
cmdutil "k8s.io/kubectl/pkg/cmd/util"
25
+ "k8s.io/kubectl/pkg/util/templates"
26
+
27
+ "github.com/ray-project/kuberay/kubectl-plugin/pkg/util/completion"
25
28
)
26
29
27
30
const filePathInPod = "/tmp/ray/session_latest/logs/"
@@ -35,6 +38,23 @@ type ClusterLogOptions struct {
35
38
args []string
36
39
}
37
40
41
+ var (
42
+ logLong = templates .LongDesc (`
43
+ Download logs from a RayCluster and save them to a directory.
44
+ ` )
45
+
46
+ logExample = templates .Examples (`
47
+ # Download logs from a RayCluster and save them to a directory with the RayCluster's name
48
+ kubectl ray log my-raycluster
49
+
50
+ # Download logs from a RayCluster and save them to a directory named /path/to/dir
51
+ kubectl ray log my-raycluster --out-dir /path/to/dir
52
+
53
+ # Download logs from a RayCluster, but only for the head node
54
+ kubectl ray log my-raycluster --node-type head
55
+ ` )
56
+ )
57
+
38
58
func NewClusterLogOptions (streams genericclioptions.IOStreams ) * ClusterLogOptions {
39
59
return & ClusterLogOptions {
40
60
configFlags : genericclioptions .NewConfigFlags (true ),
@@ -49,10 +69,13 @@ func NewClusterLogCommand(streams genericclioptions.IOStreams) *cobra.Command {
49
69
cmdFactory := cmdutil .NewFactory (options .configFlags )
50
70
51
71
cmd := & cobra.Command {
52
- Use : "log (RAY_CLUSTER_NAME) [--out-dir DIR_PATH] [--node-type all|head|worker]" ,
53
- Short : "Get ray cluster log" ,
54
- Aliases : []string {"logs" },
55
- SilenceUsage : true ,
72
+ Use : "log (RAYCLUSTER) [--out-dir DIR_PATH] [--node-type all|head|worker]" ,
73
+ Short : "Get ray cluster log" ,
74
+ Long : logLong ,
75
+ Example : logExample ,
76
+ Aliases : []string {"logs" },
77
+ SilenceUsage : true ,
78
+ ValidArgsFunction : completion .RayClusterCompletionFunc (cmdFactory ),
56
79
RunE : func (cmd * cobra.Command , args []string ) error {
57
80
if err := options .Complete (args ); err != nil {
58
81
return err
0 commit comments