From b70f6098e3d8b3c9e4e02c1b93a4f81a1881abff Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Wed, 27 Mar 2019 15:58:33 -0700 Subject: [PATCH 1/7] initial commit --- dgraph/cmd/root_ee.go | 1 + ee/backup/backup.go | 10 +++++ ee/backup/backup_test.go | 6 +-- ee/backup/file_handler.go | 54 +++++++++++++++++++++++++- ee/backup/handler.go | 21 +++++++++++ ee/backup/run.go | 79 ++++++++++++++++++++++++++++++++++++++- ee/backup/s3_handler.go | 69 ++++++++++++++++++++++++++++++++++ 7 files changed, 234 insertions(+), 6 deletions(-) diff --git a/dgraph/cmd/root_ee.go b/dgraph/cmd/root_ee.go index e35e429cf16..ba479540716 100644 --- a/dgraph/cmd/root_ee.go +++ b/dgraph/cmd/root_ee.go @@ -21,6 +21,7 @@ func init() { // subcommands already has the default subcommands, we append to EE ones to that. subcommands = append(subcommands, &backup.Restore, + &backup.LsBackup, &acl.CmdAcl, ) } diff --git a/ee/backup/backup.go b/ee/backup/backup.go index b1504c23961..be8bfddb789 100644 --- a/ee/backup/backup.go +++ b/ee/backup/backup.go @@ -84,6 +84,16 @@ type Manifest struct { Groups []uint32 `json:"groups"` } +// ManifestStatus combines a manifest along with other information about it +// that should not be inside the Manifest struct since it should not be +// recorded in manifest files. +type ManifestStatus struct { + Manifest *Manifest + FileName string + // Valid is true if all the group files listed by the manifest exist. + Valid bool +} + // GoString implements the GoStringer interface for Manifest. func (m *Manifest) GoString() string { return fmt.Sprintf(`Manifest{Version: %d, ReadTs: %d, Groups: %v}`, diff --git a/ee/backup/backup_test.go b/ee/backup/backup_test.go index 3267562da94..3dbd68a7e42 100644 --- a/ee/backup/backup_test.go +++ b/ee/backup/backup_test.go @@ -214,7 +214,7 @@ func RestoreFull(t *testing.T, c *dgo.Dgraph) { // restore this backup dir (3 files total) t.Logf("--- Restoring from: %q", dirs[0]) - _, err := runRestore("./data/restore", dirs[0]) + _, err := runRestoreInternal("./data/restore", dirs[0]) require.NoError(t, err) // just check p1 which should have the 'movie' predicate (moved during setup) @@ -277,7 +277,7 @@ func RestoreIncr1(t *testing.T, c *dgo.Dgraph) { // restore this backup dir (3 files total) t.Logf("--- Restoring from: %q", dirs[1]) - _, err := runRestore("./data/restore", dirs[1]) + _, err := runRestoreInternal("./data/restore", dirs[1]) require.NoError(t, err) // just check p1 which should have the 'movie' predicate (moved during setup) @@ -335,7 +335,7 @@ func RestoreIncr2(t *testing.T, c *dgo.Dgraph) { // restore this backup dir (3 files total) t.Logf("--- Restoring from: %q", dirs[2]) - _, err := runRestore("./data/restore", dirs[2]) + _, err := runRestoreInternal("./data/restore", dirs[2]) require.NoError(t, err) // just check p1 which should have the 'movie' predicate (moved during setup) diff --git a/ee/backup/file_handler.go b/ee/backup/file_handler.go index c8277d53311..4adb10d4d1a 100644 --- a/ee/backup/file_handler.go +++ b/ee/backup/file_handler.go @@ -137,7 +137,7 @@ func (h *fileHandler) Load(uri *url.URL, fn loadFn) (uint64, error) { continue } - // Load the backup for each group in manifest. + // Check the files for each group in the manifest exist. path := filepath.Dir(manifest) for _, groupId := range m.Groups { file := filepath.Join(path, fmt.Sprintf(backupNameFmt, m.ReadTs, groupId)) @@ -155,6 +155,58 @@ func (h *fileHandler) Load(uri *url.URL, fn loadFn) (uint64, error) { return version, nil } +// ListManifests loads the manifests in the locations and returns them. +func (h *fileHandler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { + var listedManifests []*ManifestStatus + + if !pathExist(uri.Path) { + return nil, x.Errorf("The path %q does not exist or it is inaccessible.", uri.Path) + } + + // Get a list of all the manifest files at the location. + suffix := filepath.Join(string(filepath.Separator), backupManifest) + manifests := x.WalkPathFunc(uri.Path, func(path string, isdir bool) bool { + return !isdir && strings.HasSuffix(path, suffix) + }) + if len(manifests) == 0 { + return nil, x.Errorf("No manifests found at path: %s", uri.Path) + } + sort.Strings(manifests) + if glog.V(3) { + fmt.Printf("Found backup manifest(s): %v\n", manifests) + } + + // Process each manifest, first check that they are valid and then confirm the + // backup files for each group exist. Each group in manifest must have a backup file. + for _, manifest := range manifests { + var m Manifest + var ms ManifestStatus + allFilesValid := true + + if err := h.readManifest(manifest, &m); err != nil { + return nil, x.Wrapf(err, "While reading %q", manifest) + } + ms.Manifest = &m + ms.FileName = manifest + + // Load the backup for each group in manifest. + path := filepath.Dir(manifest) + for _, groupId := range m.Groups { + file := filepath.Join(path, fmt.Sprintf(backupNameFmt, m.ReadTs, groupId)) + fp, err := os.Open(file) + if err != nil { + allFilesValid = false + break + } + fp.Close() + } + + ms.Valid = allFilesValid + listedManifests = append(listedManifests, &ms) + } + return listedManifests, nil +} + func (h *fileHandler) Close() error { if h.fp == nil { return nil diff --git a/ee/backup/handler.go b/ee/backup/handler.go index 8f206882b0a..00444444c90 100644 --- a/ee/backup/handler.go +++ b/ee/backup/handler.go @@ -72,6 +72,12 @@ type handler interface { // The loadFn receives the files as they are processed by a handler, to do the actual // load to DB. Load(*url.URL, loadFn) (uint64, error) + + // ListManifests will scan the provided URI for backup manifests. This operation + // should be read-only. + // + // The URL object is parsed as described in `newHandler`. + ListManifests(*url.URL) ([]*ManifestStatus, error) } // getHandler returns a handler for the URI scheme. @@ -148,3 +154,18 @@ func Load(l string, fn loadFn) (version uint64, err error) { return h.Load(uri, fn) } + +// ListManifests scans location l for backup files and returns the list of manifests. +func ListManifests(l string) ([]*ManifestStatus, error) { + uri, err := url.Parse(l) + if err != nil { + return nil, err + } + + h := getHandler(uri.Scheme) + if h == nil { + return nil, x.Errorf("Unsupported URI: %v", uri) + } + + return h.ListManifests(uri) +} diff --git a/ee/backup/run.go b/ee/backup/run.go index 3a80db4646d..0444199a3b9 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -31,12 +31,18 @@ import ( ) var Restore x.SubCommand +var LsBackup x.SubCommand var opt struct { location, pdir, zero string } func init() { + initRestore() + initBackupLs() +} + +func initRestore() { Restore.Cmd = &cobra.Command{ Use: "restore", Short: "Run Dgraph (EE) Restore backup", @@ -85,7 +91,7 @@ $ dgraph restore -p . -l /var/backups/dgraph -z localhost:5080 Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { defer x.StartProfile(Restore.Conf).Stop() - if err := run(); err != nil { + if err := runRestoreCmd(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } @@ -102,7 +108,56 @@ $ dgraph restore -p . -l /var/backups/dgraph -z localhost:5080 _ = Restore.Cmd.MarkFlagRequired("location") } -func run() error { +func initBackupLs() { + LsBackup.Cmd = &cobra.Command{ + Use: "lsbackup", + Short: "List info on backups in given location", + Long: ` +lsbackup looks at a location where backups are stored and prints information about them. + +Backups are originated from HTTP at /admin/backup, then can be restored using CLI restore +command. Restore is intended to be used with new Dgraph clusters in offline state. + +The --location flag indicates a source URI with Dgraph backup objects. This URI supports all +the schemes used for backup. + +Source URI formats: + [scheme]://[host]/[path]?[args] + [scheme]:///[path]?[args] + /[path]?[args] (only for local or NFS) + +Source URI parts: + scheme - service handler, one of: "s3", "minio", "file" + host - remote address. ex: "dgraph.s3.amazonaws.com" + path - directory, bucket or container at target. ex: "/dgraph/backups/" + args - specific arguments that are ok to appear in logs. + +Dgraph backup creates a unique backup object for each node group, and restore will create +a posting directory 'p' matching the backup group ID. Such that a backup file +named '.../r32-g2.backup' will be loaded to posting dir 'p2'. + +Usage examples: + +# Run using location in S3: +$ dgraph lsbackup -l s3://s3.us-west-2.amazonaws.com/srfrog/dgraph + `, + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + defer x.StartProfile(Restore.Conf).Stop() + if err := runLsbackupCmd(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + }, + } + + flag := LsBackup.Cmd.Flags() + flag.StringVarP(&opt.location, "location", "l", "", + "Sets the source location URI (required).") + _ = LsBackup.Cmd.MarkFlagRequired("location") +} + +func runRestoreCmd() error { var ( start time.Time zc pb.ZeroClient @@ -183,3 +238,23 @@ func runRestore(pdir, location string) (uint64, error) { return db.Load(r) }) } + +func runLsbackupCmd() error { + fmt.Println("Listing backups from:", opt.location) + manifests, err := ListManifests(opt.location) + if err != nil { + return x.Errorf("Error while listing manifests: %v", err.Error()) + } + + fmt.Printf("Name\tVersion\tReadTs\tGroups\tValid\n") + for _, manifest := range manifests { + fmt.Printf("%v\t%v\t%v\t%v\t%v\n", + manifest.FileName, + manifest.Manifest.Version, + manifest.Manifest.ReadTs, + manifest.Manifest.Groups, + manifest.Valid) + } + + return nil +} diff --git a/ee/backup/s3_handler.go b/ee/backup/s3_handler.go index f6ebce8614e..8e18136ee8f 100644 --- a/ee/backup/s3_handler.go +++ b/ee/backup/s3_handler.go @@ -275,6 +275,75 @@ func (h *s3Handler) Load(uri *url.URL, fn loadFn) (uint64, error) { return version, nil } +// ListManifests loads the manifests in the locations and returns them. +func (h *s3Handler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { + mc, err := h.setup(uri) + if err != nil { + return nil, err + } + + var manifests []string + var listedManifests []*ManifestStatus + + doneCh := make(chan struct{}) + defer close(doneCh) + + suffix := "/" + backupManifest + for object := range mc.ListObjects(h.bucketName, h.objectPrefix, true, doneCh) { + if strings.HasSuffix(object.Key, suffix) { + manifests = append(manifests, object.Key) + } + } + if len(manifests) == 0 { + return nil, x.Errorf("No manifests found at: %s", uri.String()) + } + sort.Strings(manifests) + if glog.V(3) { + fmt.Printf("Found backup manifest(s) %s: %v\n", uri.Scheme, manifests) + } + + // Process each manifest, first check that they are valid and then confirm the + // backup files for each group exist. Each group in manifest must have a backup file. + for _, manifest := range manifests { + var m Manifest + var ms ManifestStatus + allFilesValid := true + + if err := h.readManifest(mc, manifest, &m); err != nil { + return nil, x.Wrapf(err, "While reading %q", manifest) + } + ms.Manifest = &m + ms.FileName = manifest + + // Check the files for each group in the manifest exist. + path := filepath.Dir(manifest) + for _, groupId := range m.Groups { + object := filepath.Join(path, fmt.Sprintf(backupNameFmt, m.ReadTs, groupId)) + reader, err := mc.GetObject(h.bucketName, object, minio.GetObjectOptions{}) + if err != nil { + allFilesValid = false + break + } + defer reader.Close() + + st, err := reader.Stat() + if err != nil { + allFilesValid = false + break + } + + if st.Size <= 0 { + allFilesValid = false + break + } + } + + ms.Valid = allFilesValid + listedManifests = append(listedManifests, &ms) + } + return listedManifests, nil +} + // upload will block until it's done or an error occurs. func (h *s3Handler) upload(mc *minio.Client, object string) error { start := time.Now() From 8e02206add4eeb342f28da73316e41dfc9861a9f Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Fri, 29 Mar 2019 14:24:00 -0700 Subject: [PATCH 2/7] Remove validity check --- ee/backup/backup.go | 2 -- ee/backup/file_handler.go | 18 +----------------- ee/backup/handler.go | 1 + ee/backup/run.go | 5 ++--- ee/backup/s3_handler.go | 26 -------------------------- 5 files changed, 4 insertions(+), 48 deletions(-) diff --git a/ee/backup/backup.go b/ee/backup/backup.go index be8bfddb789..4dd897a5d17 100644 --- a/ee/backup/backup.go +++ b/ee/backup/backup.go @@ -90,8 +90,6 @@ type Manifest struct { type ManifestStatus struct { Manifest *Manifest FileName string - // Valid is true if all the group files listed by the manifest exist. - Valid bool } // GoString implements the GoStringer interface for Manifest. diff --git a/ee/backup/file_handler.go b/ee/backup/file_handler.go index 4adb10d4d1a..765e32dc571 100644 --- a/ee/backup/file_handler.go +++ b/ee/backup/file_handler.go @@ -157,8 +157,6 @@ func (h *fileHandler) Load(uri *url.URL, fn loadFn) (uint64, error) { // ListManifests loads the manifests in the locations and returns them. func (h *fileHandler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { - var listedManifests []*ManifestStatus - if !pathExist(uri.Path) { return nil, x.Errorf("The path %q does not exist or it is inaccessible.", uri.Path) } @@ -178,30 +176,16 @@ func (h *fileHandler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { // Process each manifest, first check that they are valid and then confirm the // backup files for each group exist. Each group in manifest must have a backup file. + var listedManifests []*ManifestStatus for _, manifest := range manifests { var m Manifest var ms ManifestStatus - allFilesValid := true if err := h.readManifest(manifest, &m); err != nil { return nil, x.Wrapf(err, "While reading %q", manifest) } ms.Manifest = &m ms.FileName = manifest - - // Load the backup for each group in manifest. - path := filepath.Dir(manifest) - for _, groupId := range m.Groups { - file := filepath.Join(path, fmt.Sprintf(backupNameFmt, m.ReadTs, groupId)) - fp, err := os.Open(file) - if err != nil { - allFilesValid = false - break - } - fp.Close() - } - - ms.Valid = allFilesValid listedManifests = append(listedManifests, &ms) } return listedManifests, nil diff --git a/ee/backup/handler.go b/ee/backup/handler.go index 00444444c90..80e44c30bb4 100644 --- a/ee/backup/handler.go +++ b/ee/backup/handler.go @@ -169,3 +169,4 @@ func ListManifests(l string) ([]*ManifestStatus, error) { return h.ListManifests(uri) } + diff --git a/ee/backup/run.go b/ee/backup/run.go index 0444199a3b9..f1d8e1bde63 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -248,12 +248,11 @@ func runLsbackupCmd() error { fmt.Printf("Name\tVersion\tReadTs\tGroups\tValid\n") for _, manifest := range manifests { - fmt.Printf("%v\t%v\t%v\t%v\t%v\n", + fmt.Printf("%v\t%v\t%v\t%v\n", manifest.FileName, manifest.Manifest.Version, manifest.Manifest.ReadTs, - manifest.Manifest.Groups, - manifest.Valid) + manifest.Manifest.Groups) } return nil diff --git a/ee/backup/s3_handler.go b/ee/backup/s3_handler.go index 8e18136ee8f..1dd7d1ba0e9 100644 --- a/ee/backup/s3_handler.go +++ b/ee/backup/s3_handler.go @@ -307,38 +307,12 @@ func (h *s3Handler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { for _, manifest := range manifests { var m Manifest var ms ManifestStatus - allFilesValid := true if err := h.readManifest(mc, manifest, &m); err != nil { return nil, x.Wrapf(err, "While reading %q", manifest) } ms.Manifest = &m ms.FileName = manifest - - // Check the files for each group in the manifest exist. - path := filepath.Dir(manifest) - for _, groupId := range m.Groups { - object := filepath.Join(path, fmt.Sprintf(backupNameFmt, m.ReadTs, groupId)) - reader, err := mc.GetObject(h.bucketName, object, minio.GetObjectOptions{}) - if err != nil { - allFilesValid = false - break - } - defer reader.Close() - - st, err := reader.Stat() - if err != nil { - allFilesValid = false - break - } - - if st.Size <= 0 { - allFilesValid = false - break - } - } - - ms.Valid = allFilesValid listedManifests = append(listedManifests, &ms) } return listedManifests, nil From 15e9ae9d32b2262280fc1e5d4c019a1a92c24452 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Fri, 29 Mar 2019 14:36:24 -0700 Subject: [PATCH 3/7] go fmt --- ee/backup/handler.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ee/backup/handler.go b/ee/backup/handler.go index 80e44c30bb4..00444444c90 100644 --- a/ee/backup/handler.go +++ b/ee/backup/handler.go @@ -169,4 +169,3 @@ func ListManifests(l string) ([]*ManifestStatus, error) { return h.ListManifests(uri) } - From 68be8c415e971adda0fb6214ab4b73ace9d989c2 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Tue, 2 Apr 2019 13:35:31 -0700 Subject: [PATCH 4/7] Refactor to share common code. --- ee/backup/file_handler.go | 21 +++++---------------- ee/backup/handler.go | 30 ++++++++++++++++++++++++++---- ee/backup/s3_handler.go | 27 +++++++++++---------------- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/ee/backup/file_handler.go b/ee/backup/file_handler.go index 765e32dc571..a05d0e2adc9 100644 --- a/ee/backup/file_handler.go +++ b/ee/backup/file_handler.go @@ -156,7 +156,7 @@ func (h *fileHandler) Load(uri *url.URL, fn loadFn) (uint64, error) { } // ListManifests loads the manifests in the locations and returns them. -func (h *fileHandler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { +func (h *fileHandler) ListManifests(uri *url.URL) ([]string, error) { if !pathExist(uri.Path) { return nil, x.Errorf("The path %q does not exist or it is inaccessible.", uri.Path) } @@ -173,22 +173,11 @@ func (h *fileHandler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { if glog.V(3) { fmt.Printf("Found backup manifest(s): %v\n", manifests) } + return manifests, nil +} - // Process each manifest, first check that they are valid and then confirm the - // backup files for each group exist. Each group in manifest must have a backup file. - var listedManifests []*ManifestStatus - for _, manifest := range manifests { - var m Manifest - var ms ManifestStatus - - if err := h.readManifest(manifest, &m); err != nil { - return nil, x.Wrapf(err, "While reading %q", manifest) - } - ms.Manifest = &m - ms.FileName = manifest - listedManifests = append(listedManifests, &ms) - } - return listedManifests, nil +func (h *fileHandler) ReadManifest(path string, m *Manifest) error { + return h.readManifest(path, m) } func (h *fileHandler) Close() error { diff --git a/ee/backup/handler.go b/ee/backup/handler.go index 00444444c90..6cdc22ff3eb 100644 --- a/ee/backup/handler.go +++ b/ee/backup/handler.go @@ -73,11 +73,15 @@ type handler interface { // load to DB. Load(*url.URL, loadFn) (uint64, error) - // ListManifests will scan the provided URI for backup manifests. This operation - // should be read-only. + // ListManifests will scan the provided URI and return the paths to the manifests stored + // in that location. // // The URL object is parsed as described in `newHandler`. - ListManifests(*url.URL) ([]*ManifestStatus, error) + ListManifests(*url.URL) ([]string, error) + + // ReadManifest will read the manifest at the given location and load it into the given + // Manifest object. + ReadManifest(string, *Manifest) error } // getHandler returns a handler for the URI scheme. @@ -167,5 +171,23 @@ func ListManifests(l string) ([]*ManifestStatus, error) { return nil, x.Errorf("Unsupported URI: %v", uri) } - return h.ListManifests(uri) + paths, err := h.ListManifests(uri) + if err != nil { + return nil, err + } + + var listedManifests []*ManifestStatus + for _, path := range paths { + var m Manifest + var ms ManifestStatus + + if err := h.ReadManifest(path, &m); err != nil { + return nil, x.Wrapf(err, "While reading %q", path) + } + ms.Manifest = &m + ms.FileName = path + listedManifests = append(listedManifests, &ms) + } + + return listedManifests, nil } diff --git a/ee/backup/s3_handler.go b/ee/backup/s3_handler.go index 1dd7d1ba0e9..286c5bfcc1f 100644 --- a/ee/backup/s3_handler.go +++ b/ee/backup/s3_handler.go @@ -49,6 +49,7 @@ type s3Handler struct { pwriter *io.PipeWriter preader *io.PipeReader cerr chan error + uri *url.URL } // setup creates a new session, checks valid bucket at uri.Path, and configures a minio client. @@ -276,15 +277,14 @@ func (h *s3Handler) Load(uri *url.URL, fn loadFn) (uint64, error) { } // ListManifests loads the manifests in the locations and returns them. -func (h *s3Handler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { +func (h *s3Handler) ListManifests(uri *url.URL) ([]string, error) { mc, err := h.setup(uri) if err != nil { return nil, err } + h.uri = uri var manifests []string - var listedManifests []*ManifestStatus - doneCh := make(chan struct{}) defer close(doneCh) @@ -301,21 +301,16 @@ func (h *s3Handler) ListManifests(uri *url.URL) ([]*ManifestStatus, error) { if glog.V(3) { fmt.Printf("Found backup manifest(s) %s: %v\n", uri.Scheme, manifests) } + return manifests, nil +} - // Process each manifest, first check that they are valid and then confirm the - // backup files for each group exist. Each group in manifest must have a backup file. - for _, manifest := range manifests { - var m Manifest - var ms ManifestStatus - - if err := h.readManifest(mc, manifest, &m); err != nil { - return nil, x.Wrapf(err, "While reading %q", manifest) - } - ms.Manifest = &m - ms.FileName = manifest - listedManifests = append(listedManifests, &ms) +func (h *s3Handler) ReadManifest(path string, m *Manifest) error { + mc, err := h.setup(h.uri) + if err != nil { + return err } - return listedManifests, nil + + return h.readManifest(mc, path, m) } // upload will block until it's done or an error occurs. From 910161d469d02e5e576874f0dfd2373bd137798d Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Tue, 2 Apr 2019 13:57:07 -0700 Subject: [PATCH 5/7] Fix captions. --- ee/backup/run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/backup/run.go b/ee/backup/run.go index f1d8e1bde63..f69982d065e 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -246,7 +246,7 @@ func runLsbackupCmd() error { return x.Errorf("Error while listing manifests: %v", err.Error()) } - fmt.Printf("Name\tVersion\tReadTs\tGroups\tValid\n") + fmt.Printf("Name\tVersion\tReadTs\tGroups\n") for _, manifest := range manifests { fmt.Printf("%v\t%v\t%v\t%v\n", manifest.FileName, From 25be6affdb6059a21e6e8e36dbe215f07f429135 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Thu, 4 Apr 2019 14:00:00 -0700 Subject: [PATCH 6/7] Embed Manifest inside ManifestStatus --- ee/backup/backup.go | 2 +- ee/backup/handler.go | 2 +- ee/backup/run.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/backup/backup.go b/ee/backup/backup.go index 4dd897a5d17..23883540555 100644 --- a/ee/backup/backup.go +++ b/ee/backup/backup.go @@ -88,7 +88,7 @@ type Manifest struct { // that should not be inside the Manifest struct since it should not be // recorded in manifest files. type ManifestStatus struct { - Manifest *Manifest + Manifest FileName string } diff --git a/ee/backup/handler.go b/ee/backup/handler.go index 6cdc22ff3eb..04a121febaa 100644 --- a/ee/backup/handler.go +++ b/ee/backup/handler.go @@ -184,7 +184,7 @@ func ListManifests(l string) ([]*ManifestStatus, error) { if err := h.ReadManifest(path, &m); err != nil { return nil, x.Wrapf(err, "While reading %q", path) } - ms.Manifest = &m + ms.Manifest = m ms.FileName = path listedManifests = append(listedManifests, &ms) } diff --git a/ee/backup/run.go b/ee/backup/run.go index f69982d065e..3c8b0ae29fd 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -250,9 +250,9 @@ func runLsbackupCmd() error { for _, manifest := range manifests { fmt.Printf("%v\t%v\t%v\t%v\n", manifest.FileName, - manifest.Manifest.Version, - manifest.Manifest.ReadTs, - manifest.Manifest.Groups) + manifest.Version, + manifest.ReadTs, + manifest.Groups) } return nil From 60022e1a593ea46e954ff80bc1415d264b20959d Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Thu, 4 Apr 2019 14:15:59 -0700 Subject: [PATCH 7/7] Fix copylock warning. --- ee/backup/backup.go | 2 +- ee/backup/handler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/backup/backup.go b/ee/backup/backup.go index 23883540555..f0d9a1cd457 100644 --- a/ee/backup/backup.go +++ b/ee/backup/backup.go @@ -88,7 +88,7 @@ type Manifest struct { // that should not be inside the Manifest struct since it should not be // recorded in manifest files. type ManifestStatus struct { - Manifest + *Manifest FileName string } diff --git a/ee/backup/handler.go b/ee/backup/handler.go index 04a121febaa..6cdc22ff3eb 100644 --- a/ee/backup/handler.go +++ b/ee/backup/handler.go @@ -184,7 +184,7 @@ func ListManifests(l string) ([]*ManifestStatus, error) { if err := h.ReadManifest(path, &m); err != nil { return nil, x.Wrapf(err, "While reading %q", path) } - ms.Manifest = m + ms.Manifest = &m ms.FileName = path listedManifests = append(listedManifests, &ms) }