Skip to content

Commit 6526c08

Browse files
committed
Fixup: Add logging
1 parent 5c6e298 commit 6526c08

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

go/oasis-node/cmd/storage/checkpoint.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,19 @@ func newCreateCmd() *cobra.Command {
8383
return fmt.Errorf("failed to open consensus state DB: %w", err)
8484
}
8585
defer close()
86-
8786
return createCheckpoints(ctx, ndb, common.Namespace{}, height, outputDir)
8887
}
8988
if height != 0 { // TODO handle zero value vs not set correctly.
9089
consensusOutDir := filepath.Join(outDir, consensusSubdir)
90+
logger.Info("creating consensus checkpoint",
91+
"height", height,
92+
"output_dir", consensusOutDir,
93+
)
9194
if err := createConsensusCp(consensusOutDir); err != nil {
9295
return fmt.Errorf("failed to create consensus checkpoint (height: %d): %w", height, err)
9396
}
97+
logger.Info("consensus checkpoint created")
98+
9499
if err := createCometBFTBootstrapMeta(dataDir, height, consensusOutDir); err != nil {
95100
return fmt.Errorf("failed to write bootstrap metadata: %w", err)
96101
}
@@ -103,7 +108,6 @@ func newCreateCmd() *cobra.Command {
103108
return fmt.Errorf("failed to open runtime state DB: %w", err)
104109
}
105110
defer ndb.Close()
106-
107111
return createCheckpoints(ctx, ndb, ns, round, outputDir)
108112
}
109113
if runtimeID != "" {
@@ -112,9 +116,15 @@ func newCreateCmd() *cobra.Command {
112116
return fmt.Errorf("malformed source runtime ID: %q: %w", runtimeID, err)
113117
}
114118
rtOutDir := filepath.Join(outDir, runtimesSubdir, ns.Hex())
119+
logger.Info("creating runtime checkpoints (may take minutes to hours depending on the db size)",
120+
"round", round,
121+
"output_dir", rtOutDir,
122+
"runtime_id", ns,
123+
)
115124
if err := createRuntimeCps(ns, rtOutDir); err != nil {
116125
return fmt.Errorf("failed to create runtime checkpoints (runtime: %s, round: %d): %w", runtimeID, round, err)
117126
}
127+
logger.Info("runtime checkpoints created", "runtime_id", ns)
118128
}
119129

120130
return nil
@@ -154,9 +164,11 @@ func newImportCmd() *cobra.Command {
154164
_, err := os.ReadDir(consensusInputDir)
155165
switch {
156166
case err == nil:
167+
logger.Info("restoring consensus checkpoint", "input_dir", inputDir)
157168
if err := restoreConsensusCp(consensusInputDir); err != nil {
158169
return fmt.Errorf("failed to restore consensus cp (input dir: %s): %w", consensusInputDir, err)
159170
}
171+
logger.Info("consensus checkpoint restored")
160172

161173
meta, err := readCometBFTBootstrapMeta(consensusInputDir)
162174
if err != nil {
@@ -178,7 +190,6 @@ func newImportCmd() *cobra.Command {
178190
return err
179191
}
180192
defer ndb.Close()
181-
182193
return restoreCheckpoints(ctx, ndb, ns, inputDir)
183194
}
184195
runtimeInputDir := filepath.Join(inputDir, runtimesSubdir)
@@ -192,9 +203,14 @@ func newImportCmd() *cobra.Command {
192203
}
193204
rtCpsDir := filepath.Join(runtimeInputDir, entry.Name())
194205

206+
logger.Info("restoring runtime checkpoints (may take few minutes)",
207+
"runtime_id", ns,
208+
"input_dir", inputDir,
209+
)
195210
if err := restoreRuntimeCp(rtCpsDir, ns); err != nil {
196211
return fmt.Errorf("failed to import checkpoints (checkpoint dir: %s): %w", rtCpsDir, err)
197212
}
213+
logger.Info("runtime checkpoints restored", "runtime_id", ns)
198214
}
199215
case os.IsNotExist(err):
200216
// No runtime checkpoints to restore

0 commit comments

Comments
 (0)