From 1936d5aeeafc70e9419dd6a667cc5e622d9e5b6e Mon Sep 17 00:00:00 2001 From: Swapnil Mhamane Date: Tue, 19 Feb 2019 16:34:52 +0530 Subject: [PATCH] Skip snap store specific sanity check when not configured Signed-off-by: Swapnil Mhamane --- pkg/initializer/validator/datavalidator.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/initializer/validator/datavalidator.go b/pkg/initializer/validator/datavalidator.go index da626b32b..0ef924bf0 100644 --- a/pkg/initializer/validator/datavalidator.go +++ b/pkg/initializer/validator/datavalidator.go @@ -96,10 +96,14 @@ func (d *DataValidator) Validate() (DataDirStatus, error) { return DataDirectoryInvStruct, nil } - d.Logger.Info("Checking for revision consistency...") - if err = d.CheckRevisionConsistency(); err != nil { - d.Logger.Infof("Etcd revision inconsistent with latest snapshot revision: %v", err) - return RevisionConsistencyError, nil + if d.Config.SnapstoreConfig != nil { + d.Logger.Info("Checking for revision consistency...") + if err = checkRevisionConsistency(d.backendPath(), *d.Config.SnapstoreConfig); err != nil { + d.Logger.Infof("Etcd revision inconsistent with latest snapshot revision: %v", err) + return RevisionConsistencyError, nil + } + } else { + d.Logger.Info("Skipping check for revision consistency, since no snapstore configured.") } d.Logger.Info("Checking for data directory files corruption...") @@ -338,14 +342,14 @@ func verifyDB(path string) error { }) } -// CheckRevisionConsistency compares the latest revisions on the etcd db file and the latest snapshot to verify that the etcd revision is not lesser than snapshot revision. -func (d *DataValidator) CheckRevisionConsistency() error { - etcdRevision, err := getLatestEtcdRevision(d.backendPath()) +// checkRevisionConsistency compares the latest revisions on the etcd db file and the latest snapshot to verify that the etcd revision is not lesser than snapshot revision. +func checkRevisionConsistency(dbPath string, config snapstore.Config) error { + etcdRevision, err := getLatestEtcdRevision(dbPath) if err != nil { return fmt.Errorf("unable to get current etcd revision from backend db file: %v", err) } - store, err := snapstore.GetSnapstore(d.Config.SnapstoreConfig) + store, err := snapstore.GetSnapstore(&config) if err != nil { return fmt.Errorf("unable to fetch snapstore: %v", err) }