Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Issue529 #530

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cmd/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewAliyunCmd(targetReader TargetReader) *cobra.Command {
return errors.New("no shoot targeted")
}

arguments := "aliyun " + strings.Join(args[:], " ")
arguments := strings.Join(args[:], " ")
operate("aliyun", arguments)

return nil
Expand Down
24 changes: 11 additions & 13 deletions pkg/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/Masterminds/semver"
"github.com/spf13/cobra"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -849,33 +850,30 @@ func saveLogsClusterAutoscaler(targetReader TargetReader) {
// logsTerraform prints the logfiles of tf pod
func logsTerraform(toMatch string) {
var latestTime int64
var podName [100]string
var podNamespace [100]string
matchedPods := make([]v1.Pod, 0, 100)
var err error
Client, err = clientToTarget("seed")
checkError(err)
pods, err := Client.CoreV1().Pods(emptyString).List(metav1.ListOptions{})
checkError(err)
count := 0
for _, pod := range pods.Items {
if strings.Contains(pod.Name, toMatch) && pod.Status.Phase == "Running" {
if latestTime < pod.ObjectMeta.CreationTimestamp.Unix() {
latestTime = pod.ObjectMeta.CreationTimestamp.Unix()
podName[count] = pod.Name
podNamespace[count] = pod.Namespace
count++
matchedPods = append(matchedPods, pod)
}
}
}
if len(podName) == 0 || len(podNamespace) == 0 {
if len(matchedPods) == 0 {
fmt.Println("No running tf " + toMatch)
} else {
for i := 0; i < count; i++ {
fmt.Println("gardenctl logs " + podName[i] + " namespace=" + podNamespace[i])
err = ExecCmd(nil, "kubectl logs "+podName[i]+" -n "+podNamespace[i], false, "KUBECONFIG="+KUBECONFIG)
checkError(err)
}
return
}
for _, pod := range matchedPods {
fmt.Println("gardenctl logs " + pod.Name + " namespace=" + pod.Namespace)
err = ExecCmd(nil, "kubectl logs "+pod.Name+" -n "+pod.Namespace, false, "KUBECONFIG="+KUBECONFIG)
checkError(err)
}

}

func saveLogsTerraform(toMatch string) {
Expand Down