@@ -17,14 +17,15 @@ limitations under the License.
17
17
package main
18
18
19
19
import (
20
+ "cloner-startup/internal/helpers"
20
21
"fmt"
21
22
"log/slog"
22
23
"os"
23
-
24
- "cloner-startup/internal/helpers"
25
24
)
26
25
27
26
func main () {
27
+ var uploadBytes uint64
28
+
28
29
logger := slog .New (slog .NewJSONHandler (os .Stdout , nil ))
29
30
slog .SetDefault (logger )
30
31
@@ -61,6 +62,8 @@ func main() {
61
62
os .Exit (1 )
62
63
}
63
64
65
+ logger .Info (fmt .Sprintf ("Start clone block with %s" , helpers .FormatBytes (float64 (uploadBytes ))))
66
+
64
67
if err = helpers .RunCloner ("blockdevice-clone" , uploadBytes , mountPoint ); err != nil {
65
68
logger .Error ("Error running cdi-cloner: %v\n " , slog .String ("error" , err .Error ()))
66
69
os .Exit (1 )
@@ -73,38 +76,22 @@ func main() {
73
76
os .Exit (1 )
74
77
}
75
78
76
- // TODO correct log message
77
- if preallocation {
78
- logger .Info ("Get only used blocks in bytes" )
79
- } else {
80
- logger .Info ("Preallocating filesystem, uploading all bytes" )
81
- }
82
- // directory bytes, directory bytes
83
- // total count bytes, used count bytes
84
- // uploadBytes, err := helpers.GetDirectorySize(".", preallocation)
85
79
totalBytes , totalUsedBytes , err := helpers .GetDirectorySize ("." )
86
80
if err != nil {
87
81
logger .Error ("Directory size calculation failed: %v\n " , slog .String ("error" , err .Error ()))
88
82
os .Exit (1 )
89
83
}
90
84
91
- /*
92
- if preallocation {
93
- uploadBytes := totalUsedBytes
94
- }else
95
- {
96
- uploadBytes := totalBytes
97
- }
98
- */
99
- var uploadBytes uint64
100
-
101
85
if preallocation {
102
- uploadBytes = totalUsedBytes
103
- } else {
104
86
uploadBytes = totalBytes
87
+ logger .Info ("Preallocating filesystem, uploading all bytes" )
88
+ } else {
89
+ uploadBytes = totalUsedBytes
90
+ logger .Info ("Not preallocating filesystem, get only used blocks in bytes" )
105
91
}
106
92
107
93
logger .Info (fmt .Sprintf ("Start clone with %d bytes" , uploadBytes ))
94
+ logger .Info (fmt .Sprintf ("Start clone with %s" , helpers .FormatBytes (float64 (uploadBytes ))))
108
95
109
96
if err = helpers .RunCloner ("filesystem-clone" , uploadBytes , mountPoint ); err != nil {
110
97
logger .Error ("Error running cdi-cloner: %v\n " , slog .String ("error" , err .Error ()))
0 commit comments