maintenance: cleanup debug logs

This commit is contained in:
iwilltry42 2020-05-26 14:14:55 +02:00
parent 7cec9bfd02
commit 21fd427d8a
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
16 changed files with 6 additions and 27 deletions

View File

@ -98,7 +98,6 @@ func NewCmdCreateCluster() *cobra.Command {
fmt.Printf("kubectl config use-context %s\n", fmt.Sprintf("%s-%s", k3d.DefaultObjectNamePrefix, cluster.Name)) fmt.Printf("kubectl config use-context %s\n", fmt.Sprintf("%s-%s", k3d.DefaultObjectNamePrefix, cluster.Name))
} else { } else {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
log.Debugf("GOOS is %s", runtime.GOOS)
fmt.Printf("$env:KUBECONFIG=(%s get kubeconfig %s)\n", os.Args[0], cluster.Name) fmt.Printf("$env:KUBECONFIG=(%s get kubeconfig %s)\n", os.Args[0], cluster.Name)
} else { } else {
fmt.Printf("export KUBECONFIG=$(%s get kubeconfig %s)\n", os.Args[0], cluster.Name) fmt.Printf("export KUBECONFIG=$(%s get kubeconfig %s)\n", os.Args[0], cluster.Name)

View File

@ -40,8 +40,6 @@ func NewCmdDeleteCluster() *cobra.Command {
Long: `Delete a cluster.`, Long: `Delete a cluster.`,
Args: cobra.MinimumNArgs(0), // 0 or n arguments; 0 only if --all is set Args: cobra.MinimumNArgs(0), // 0 or n arguments; 0 only if --all is set
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("delete cluster called")
clusters := parseDeleteClusterCmd(cmd, args) clusters := parseDeleteClusterCmd(cmd, args)
if len(clusters) == 0 { if len(clusters) == 0 {

View File

@ -39,7 +39,6 @@ func NewCmdDeleteNode() *cobra.Command {
Long: `Delete a node.`, Long: `Delete a node.`,
Args: cobra.MinimumNArgs(1), // at least one node has to be specified Args: cobra.MinimumNArgs(1), // at least one node has to be specified
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("delete node called")
nodes := parseDeleteNodeCmd(cmd, args) nodes := parseDeleteNodeCmd(cmd, args)
@ -52,8 +51,6 @@ func NewCmdDeleteNode() *cobra.Command {
} }
} }
} }
log.Debugln("...Finished")
}, },
} }

View File

@ -48,7 +48,6 @@ func NewCmdGetCluster() *cobra.Command {
Long: `Get cluster.`, Long: `Get cluster.`,
Args: cobra.MinimumNArgs(0), // 0 or more; 0 = all Args: cobra.MinimumNArgs(0), // 0 or more; 0 = all
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("get cluster called")
clusters, headersOff := parseGetClusterCmd(cmd, args) clusters, headersOff := parseGetClusterCmd(cmd, args)
var existingClusters []*k3d.Cluster var existingClusters []*k3d.Cluster
if clusters == nil { // Option a) no cluster name specified -> get all clusters if clusters == nil { // Option a) no cluster name specified -> get all clusters

View File

@ -46,7 +46,6 @@ func NewCmdGetNode() *cobra.Command {
Aliases: []string{"nodes"}, Aliases: []string{"nodes"},
Long: `Get node.`, Long: `Get node.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("get node called")
node, headersOff := parseGetNodeCmd(cmd, args) node, headersOff := parseGetNodeCmd(cmd, args)
var existingNodes []*k3d.Node var existingNodes []*k3d.Node
if node == nil { // Option a) no name specified -> get all nodes if node == nil { // Option a) no name specified -> get all nodes

View File

@ -44,13 +44,13 @@ func NewCmdLoadImage() *cobra.Command {
images, clusters, keepTarball := parseLoadImageCmd(cmd, args) images, clusters, keepTarball := parseLoadImageCmd(cmd, args)
log.Debugf("Load images [%+v] from runtime [%s] into clusters [%+v]", runtimes.SelectedRuntime, images, clusters) log.Debugf("Load images [%+v] from runtime [%s] into clusters [%+v]", runtimes.SelectedRuntime, images, clusters)
for _, cluster := range clusters { for _, cluster := range clusters {
log.Debugf("Loading images into '%s'", cluster.Name) log.Infof("Loading images into '%s'", cluster.Name)
if err := tools.LoadImagesIntoCluster(runtimes.SelectedRuntime, images, &cluster, keepTarball); err != nil { if err := tools.LoadImagesIntoCluster(runtimes.SelectedRuntime, images, &cluster, keepTarball); err != nil {
log.Errorf("Failed to load images into cluster '%s'", cluster.Name) log.Errorf("Failed to load images into cluster '%s'", cluster.Name)
log.Errorln(err) log.Errorln(err)
} }
} }
log.Debugln("Finished loading images into clusters") log.Info("DONE")
}, },
} }

View File

@ -40,7 +40,6 @@ func NewCmdStartCluster() *cobra.Command {
Short: "Start an existing k3d cluster", Short: "Start an existing k3d cluster",
Long: `Start an existing k3d cluster`, Long: `Start an existing k3d cluster`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("start cluster called")
clusters := parseStartClusterCmd(cmd, args) clusters := parseStartClusterCmd(cmd, args)
if len(clusters) == 0 { if len(clusters) == 0 {
log.Infoln("No clusters found") log.Infoln("No clusters found")
@ -51,8 +50,6 @@ func NewCmdStartCluster() *cobra.Command {
} }
} }
} }
log.Debugln("...Finished")
}, },
} }

View File

@ -38,7 +38,6 @@ func NewCmdStartNode() *cobra.Command {
Short: "Start an existing k3d node", Short: "Start an existing k3d node",
Long: `Start an existing k3d node.`, Long: `Start an existing k3d node.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("start node called")
node := parseStartNodeCmd(cmd, args) node := parseStartNodeCmd(cmd, args)
if err := runtimes.SelectedRuntime.StartNode(node); err != nil { if err := runtimes.SelectedRuntime.StartNode(node); err != nil {
log.Fatalln(err) log.Fatalln(err)

View File

@ -40,7 +40,6 @@ func NewCmdStopCluster() *cobra.Command {
Short: "Stop an existing k3d cluster", Short: "Stop an existing k3d cluster",
Long: `Stop an existing k3d cluster.`, Long: `Stop an existing k3d cluster.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("stop cluster called")
clusters := parseStopClusterCmd(cmd, args) clusters := parseStopClusterCmd(cmd, args)
if len(clusters) == 0 { if len(clusters) == 0 {
log.Infoln("No clusters found") log.Infoln("No clusters found")
@ -51,8 +50,6 @@ func NewCmdStopCluster() *cobra.Command {
} }
} }
} }
log.Debugln("...Finished")
}, },
} }

View File

@ -39,7 +39,6 @@ func NewCmdStopNode() *cobra.Command {
Short: "Stop an existing k3d node", Short: "Stop an existing k3d node",
Long: `Stop an existing k3d node.`, Long: `Stop an existing k3d node.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log.Debugln("stop node called")
node := parseStopNodeCmd(cmd, args) node := parseStopNodeCmd(cmd, args)
if err := runtimes.SelectedRuntime.StopNode(node); err != nil { if err := runtimes.SelectedRuntime.StopNode(node); err != nil {
log.Fatalln(err) log.Fatalln(err)

View File

@ -320,7 +320,7 @@ func CreateCluster(ctx context.Context, cluster *k3d.Cluster, runtime k3drt.Runt
func DeleteCluster(cluster *k3d.Cluster, runtime k3drt.Runtime) error { func DeleteCluster(cluster *k3d.Cluster, runtime k3drt.Runtime) error {
log.Infof("Deleting cluster '%s'", cluster.Name) log.Infof("Deleting cluster '%s'", cluster.Name)
log.Debugf("%+v", cluster) log.Debugf("Cluster Details: %+v", cluster)
failed := 0 failed := 0
for _, node := range cluster.Nodes { for _, node := range cluster.Nodes {

View File

@ -46,7 +46,7 @@ func AddMasterToLoadBalancer(runtime runtimes.Runtime, cluster *k3d.Cluster, new
} }
masterNodes += newNode.Name // append the new master node to the end of the list masterNodes += newNode.Name // append the new master node to the end of the list
log.Debugf("SERVERS=%s", masterNodes) log.Debugf("Servers as passed to masterlb: '%s'", masterNodes)
command := fmt.Sprintf("SERVERS=%s %s", masterNodes, "confd -onetime -backend env && nginx -s reload") command := fmt.Sprintf("SERVERS=%s %s", masterNodes, "confd -onetime -backend env && nginx -s reload")
if err := runtime.ExecInNode(loadbalancer, []string{"sh", "-c", command}); err != nil { if err := runtime.ExecInNode(loadbalancer, []string{"sh", "-c", command}); err != nil {

View File

@ -162,7 +162,6 @@ func CreateNode(node *k3d.Node, runtime runtimes.Runtime) error {
if err := patchMasterSpec(node); err != nil { if err := patchMasterSpec(node); err != nil {
return err return err
} }
log.Debugf("spec = %+v\n", node)
} }
/* /*

View File

@ -34,8 +34,6 @@ import (
// CreateNode creates a new k3d node // CreateNode creates a new k3d node
func (d Containerd) CreateNode(node *k3d.Node) error { func (d Containerd) CreateNode(node *k3d.Node) error {
log.Debugln("containerd.CreateNode...")
// create containerd client // create containerd client
ctx := context.Background() ctx := context.Background()
clientOpts := []containerd.ClientOpt{ clientOpts := []containerd.ClientOpt{
@ -78,7 +76,6 @@ func (d Containerd) CreateNode(node *k3d.Node) error {
// DeleteNode deletes an existing k3d node // DeleteNode deletes an existing k3d node
func (d Containerd) DeleteNode(node *k3d.Node) error { func (d Containerd) DeleteNode(node *k3d.Node) error {
log.Debugln("containerd.DeleteNode...")
ctx := context.Background() ctx := context.Background()
clientOpts := []containerd.ClientOpt{ clientOpts := []containerd.ClientOpt{
containerd.WithDefaultNamespace("k3d"), containerd.WithDefaultNamespace("k3d"),

View File

@ -46,7 +46,7 @@ func (d Docker) GetKubeconfig(node *k3d.Node) (io.ReadCloser, error) {
return nil, err return nil, err
} }
log.Debugf("Container: %+v", container) log.Debugf("Container Details: %+v", container)
reader, _, err := docker.CopyFromContainer(ctx, container.ID, "/output/kubeconfig.yaml") reader, _, err := docker.CopyFromContainer(ctx, container.ID, "/output/kubeconfig.yaml")
if err != nil { if err != nil {

View File

@ -57,7 +57,6 @@ func (d Docker) CreateNode(node *k3d.Node) error {
// DeleteNode deletes a node // DeleteNode deletes a node
func (d Docker) DeleteNode(nodeSpec *k3d.Node) error { func (d Docker) DeleteNode(nodeSpec *k3d.Node) error {
log.Debugln("docker.DeleteNode...")
return removeContainer(nodeSpec.Name) return removeContainer(nodeSpec.Name)
} }
@ -257,7 +256,7 @@ func (d Docker) GetNodeLogs(node *k3d.Node) (io.ReadCloser, error) {
// ExecInNode execs a command inside a node // ExecInNode execs a command inside a node
func (d Docker) ExecInNode(node *k3d.Node, cmd []string) error { func (d Docker) ExecInNode(node *k3d.Node, cmd []string) error {
log.Debugf("Exec cmds '%+v' in node '%s'", cmd, node.Name) log.Debugf("Executing command '%+v' in node '%s'", cmd, node.Name)
// get the container for the given node // get the container for the given node
container, err := getNodeContainer(node) container, err := getNodeContainer(node)