Skip to content

Commit 3b86c6a

Browse files
committed
debug logs
1 parent 414da71 commit 3b86c6a

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

pkg/cmd/backuprestore/backupserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type backupRunner interface {
2828
type backupRunnerImpl struct{}
2929

3030
func (b backupRunnerImpl) runBackup(backupOpts *backupOptions, pruneOpts *prune.PruneOpts) error {
31+
klog.Infof("@Mustafa: being runBackup() - backupOpts are [%v] - pruneOpts are [%v] ", backupOpts, pruneOpts)
3132
dateString := time.Now().Format("2006-01-02_150405")
3233
backupOpts.backupDir = path.Join(backupVolume, dateString)
3334
err := backup(backupOpts)

pkg/cmd/backuprestore/backuputils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var backupResourcePodList = []string{
1818
}
1919

2020
func archiveLatestResources(configDir, backupFile string) error {
21+
klog.Infof("@Mustafa: being archiveLatestResources() - configDir are [%v] - backupFile are [%v]", configDir, backupFile)
2122
klog.Info("Static Pod Resources are being stored in: ", backupFile)
2223

2324
paths := []string{}
@@ -38,6 +39,7 @@ func archiveLatestResources(configDir, backupFile string) error {
3839
}
3940

4041
func backup(r *backupOptions) error {
42+
klog.Infof("@Mustafa: being backup() - backupOpts are [%v] - endpoints are [%v]", r, r.endpoints)
4143
cli, err := getEtcdClient(r.endpoints)
4244
if err != nil {
4345
return fmt.Errorf("backup: failed to get etcd client: %w", err)

pkg/cmd/backuprestore/etcdclientutils.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ import (
1616
)
1717

1818
func getEtcdClient(endpoints []string) (*clientv3.Client, error) {
19+
klog.Infof("@Mustafa: being getEtcdClient() - endpoints are [%v]", endpoints)
1920
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, os.Stderr))
2021
dialOptions := []grpc.DialOption{
2122
grpc.WithBlock(), // block until the underlying connection is up
2223
}
2324

25+
klog.Infof("@Mustafa: before tlsInfo in getEtcdClient()")
2426
tlsInfo := transport.TLSInfo{
2527
CertFile: os.Getenv("ETCDCTL_CERT"),
2628
KeyFile: os.Getenv("ETCDCTL_KEY"),
2729
TrustedCAFile: os.Getenv("ETCDCTL_CACERT"),
2830
}
2931
tlsConfig, err := tlsInfo.ClientConfig()
3032
if err != nil {
33+
klog.Infof("@Mustafa: before tlsInfo in getEtcdClient() - tlsConfig are [%v]", tlsConfig)
34+
klog.Infof("@Mustafa: before tlsInfo in getEtcdClient() - err is [%v]", err)
3135
return nil, fmt.Errorf("failed to generate tls client config endpoints %v and env %v: %w", endpoints, os.Environ(), err)
3236
}
3337

@@ -38,14 +42,18 @@ func getEtcdClient(endpoints []string) (*clientv3.Client, error) {
3842
TLS: tlsConfig,
3943
}
4044

45+
klog.Infof("@Mustafa: after tlsInfo in getEtcdClient()")
4146
cli, err := clientv3.New(*cfg)
4247
if err != nil {
48+
klog.Infof("@Mustafa: after tlsInfo in getEtcdClient() - cli are [%v]", cli)
49+
klog.Infof("@Mustafa: after tlsInfo in getEtcdClient() - err is [%v]", err)
4350
return nil, fmt.Errorf("failed to make etcd client for endpoints %v and env %v: %w", endpoints, os.Environ(), err)
4451
}
4552
return cli, nil
4653
}
4754

4855
func saveSnapshot(cli *clientv3.Client, dbPath string) error {
56+
klog.Infof("@Mustafa: being saveSnapshot() - cli are [%v] - dbPath are [%v]", cli, dbPath)
4957
partpath := dbPath + ".part"
5058
defer os.RemoveAll(partpath)
5159

pkg/cmd/backuprestore/fileioutils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66
"io/ioutil"
7+
"k8s.io/klog/v2"
78
"os"
89
"path/filepath"
910
"strings"
@@ -71,12 +72,15 @@ func findTheLatestRevision(dir, filePrefix string, isDir bool) (string, error) {
7172
}
7273

7374
func checkAndCreateDir(dirName string) error {
75+
klog.Infof("@Mustafa: being checkAndCreateDir() - dirName are [%v]", dirName)
7476
_, err := os.Stat(dirName)
7577
if err != nil && !os.IsNotExist(err) {
78+
klog.Infof("@Mustafa: being checkAndCreateDir() - err are [%v]", err)
7679
return fmt.Errorf("checkAndCreateDir failed: %w", err)
7780
}
7881
// If dirName already exists, remove it
7982
if err == nil {
83+
klog.Infof("@Mustafa: being checkAndCreateDir() - err are [%v]", err)
8084
if err := os.RemoveAll(dirName); err != nil {
8185
return fmt.Errorf("checkAndCreateDir failed to remove %s: %w", dirName, err)
8286
}

0 commit comments

Comments
 (0)