@@ -17,10 +17,14 @@ import (
1717	"k8s.io/client-go/tools/remotecommand" 
1818	"k8s.io/metrics/pkg/apis/metrics" 
1919	metricsv1beta1api "k8s.io/metrics/pkg/apis/metrics/v1beta1" 
20+ 	"k8s.io/utils/ptr" 
2021
2122	"github.com/containers/kubernetes-mcp-server/pkg/version" 
2223)
2324
25+ // Default number of lines to retrieve from the end of the logs 
26+ const  DefaultTailLines  =  int64 (100 )
27+ 
2428type  PodsTopOptions  struct  {
2529	metav1.ListOptions 
2630	AllNamespaces  bool 
@@ -92,17 +96,26 @@ func (k *Kubernetes) PodsDelete(ctx context.Context, namespace, name string) (st
9296		k .ResourcesDelete (ctx , & schema.GroupVersionKind {Group : "" , Version : "v1" , Kind : "Pod" }, namespace , name )
9397}
9498
95- func  (k  * Kubernetes ) PodsLog (ctx  context.Context , namespace , name , container  string , previous  bool ) (string , error ) {
96- 	tailLines  :=  int64 (256 )
99+ func  (k  * Kubernetes ) PodsLog (ctx  context.Context , namespace , name , container  string , previous  bool , tail  int64 ) (string , error ) {
97100	pods , err  :=  k .manager .accessControlClientSet .Pods (k .NamespaceOrDefault (namespace ))
98101	if  err  !=  nil  {
99102		return  "" , err 
100103	}
101- 	 req   :=   pods . GetLogs ( name ,  & v1. PodLogOptions { 
102- 		 TailLines :  & tailLines , 
104+ 
105+ 	logOptions   :=   & v1. PodLogOptions { 
103106		Container : container ,
104107		Previous :  previous ,
105- 	})
108+ 	}
109+ 
110+ 	// Only set tailLines if a value is provided (non-zero) 
111+ 	if  tail  >  0  {
112+ 		logOptions .TailLines  =  & tail 
113+ 	} else  {
114+ 		// Default to DefaultTailLines lines when not specified 
115+ 		logOptions .TailLines  =  ptr .To (DefaultTailLines )
116+ 	}
117+ 
118+ 	req  :=  pods .GetLogs (name , logOptions )
106119	res  :=  req .Do (ctx )
107120	if  res .Error () !=  nil  {
108121		return  "" , res .Error ()
0 commit comments