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

Commit

Permalink
add logs gardenlet
Browse files Browse the repository at this point in the history
add logs_test
  • Loading branch information
tedteng committed Sep 23, 2020
1 parent f42ec92 commit 93170ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions pkg/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var flags *logFlags
func NewLogsCmd() *cobra.Command {
flags = newLogsFlags()
cmd := &cobra.Command{
Use: "logs (gardener-apiserver|gardener-controller-manager|gardener-dashboard|api|scheduler|controller-manager|etcd-operator|etcd-main[etcd backup-restore]|etcd-main-backup|etcd-events[etcd backup-restore]|addon-manager|vpn-seed|vpn-shoot|machine-controller-manager|kubernetes-dashboard|prometheus|grafana|alertmanager|tf (infra|dns|ingress)|cluster-autoscaler)",
Use: "logs (gardener-apiserver|gardener-controller-manager|gardener-dashboard|api|scheduler|controller-manager|etcd-operator|etcd-main[etcd backup-restore]|etcd-main-backup|etcd-events[etcd backup-restore]|addon-manager|vpn-seed|vpn-shoot|machine-controller-manager|kubernetes-dashboard|prometheus|grafana|alertmanager|gardenlet|tf (infra|dns|ingress)|cluster-autoscaler)",
Short: "Show and optionally follow logs of given component\n",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -61,7 +61,7 @@ func NewLogsCmd() *cobra.Command {
runCommand(args)
return nil
},
ValidArgs: []string{"gardener-apiserver", "gardener-controller-manager", "gardener-dashboard", "api", "scheduler", "controller-manager", "etcd-operator", "etcd-main", "etcd-events", "addon-manager", "vpn-seed", "vpn-shoot", "auto-node-repair", "kubernetes-dashboard", "prometheus", "grafana", "alertmanager", "tf"},
ValidArgs: []string{"gardener-apiserver", "gardener-controller-manager", "gardener-dashboard", "api", "scheduler", "controller-manager", "etcd-operator", "etcd-main", "etcd-events", "addon-manager", "vpn-seed", "vpn-shoot", "auto-node-repair", "kubernetes-dashboard", "prometheus", "grafana", "alertmanager", "gardenlet", "tf"},
Aliases: []string{"log"},
}
cmd.Flags().Int64Var(&flags.tail, "tail", 200, "Lines of recent log file to display. Defaults to 200 with no selector, if a selector is provided takes the number of specified lines (max 100 000 for loki).")
Expand All @@ -75,7 +75,7 @@ func NewLogsCmd() *cobra.Command {

func validateArgs(args []string) error {
if len(args) < 1 || len(args) > 3 {
return errors.New("Command must be in the format: logs (gardener-apiserver|gardener-controller-manager|gardener-dashboard|api|scheduler|controller-manager|etcd-operator|etcd-main[etcd backup-restore]|etcd-events[etcd backup-restore]|addon-manager|vpn-seed|vpn-shoot|machine-controller-manager|kubernetes-dashboard|prometheus|grafana|alertmanager|tf (infra|dns|ingress)|cluster-autoscaler flags(--loki|--elasticsearch|--tail|--since|--since-time|--timestamps)")
return errors.New("Command must be in the format: logs (gardener-apiserver|gardener-controller-manager|gardener-dashboard|api|scheduler|controller-manager|etcd-operator|etcd-main[etcd backup-restore]|etcd-events[etcd backup-restore]|addon-manager|vpn-seed|vpn-shoot|machine-controller-manager|kubernetes-dashboard|prometheus|grafana|alertmanager|gardenlet|tf (infra|dns|ingress)|cluster-autoscaler flags(--loki|--elasticsearch|--tail|--since|--since-time|--timestamps)")
}
var t Target
ReadTarget(pathTarget, &t)
Expand Down Expand Up @@ -159,6 +159,8 @@ func runCommand(args []string) {
logsGrafana()
case "alertmanager":
logsAlertmanager()
case "gardenlet":
logsGardenlet()
case "cluster-autoscaler":
logsClusterAutoscaler()
case "tf":
Expand Down Expand Up @@ -409,6 +411,14 @@ func logPodGarden(toMatch, namespace string) {
showLogsFromKubectl(namespace, toMatch, emptyString)
}

// logPodSeed print logfiles for Seed pods
func logPodSeed(toMatch, namespace string) {
var err error
Client, err = clientToTarget("seed")
checkError(err)
showLogsFromKubectl(namespace, toMatch, emptyString)
}

// logPodGardenImproved print logfiles for garden pods
func logPodGardenImproved(podName string) {
var target Target
Expand Down Expand Up @@ -565,6 +575,10 @@ func logsGrafana() {
logPod("grafana", "seed", "grafana")
}

func logsGardenlet() {
logPodSeed("gardenlet", "garden")
}

// logsAlertmanager prints the logfiles of alertmanager
func logsAlertmanager() {
logPod("alertmanager", "seed", "alertmanager") // TODO: TWO PODS ARE RUNNING
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var _ = Describe("Logs command", func() {
err := execute(command, []string{})

Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Command must be in the format: logs (gardener-apiserver|gardener-controller-manager|gardener-dashboard|api|scheduler|controller-manager|etcd-operator|etcd-main[etcd backup-restore]|etcd-events[etcd backup-restore]|addon-manager|vpn-seed|vpn-shoot|machine-controller-manager|kubernetes-dashboard|prometheus|grafana|alertmanager|tf (infra|dns|ingress)|cluster-autoscaler flags(--loki|--elasticsearch|--tail|--since|--since-time|--timestamps)"))
Expect(err.Error()).To(Equal("Command must be in the format: logs (gardener-apiserver|gardener-controller-manager|gardener-dashboard|api|scheduler|controller-manager|etcd-operator|etcd-main[etcd backup-restore]|etcd-events[etcd backup-restore]|addon-manager|vpn-seed|vpn-shoot|machine-controller-manager|kubernetes-dashboard|prometheus|grafana|alertmanager|gardenlet|tf (infra|dns|ingress)|cluster-autoscaler flags(--loki|--elasticsearch|--tail|--since|--since-time|--timestamps)"))
})
})
})

0 comments on commit 93170ea

Please sign in to comment.