Skip to content

Commit 5db5a84

Browse files
committed
Merge branch 'debug' into 'main'
install: Two logging/output tweaks See merge request bootc-org/podman-bootc-cli!57
2 parents 02ec5b3 + 36a3ca9 commit 5db5a84

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/bootc/bootc_disk.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,17 @@ func (p *BootcDisk) getOrInstallImageToDisk(quiet bool) error {
135135
if !errors.Is(err, os.ErrNotExist) {
136136
return err
137137
}
138+
logrus.Debugf("No existing disk image found")
138139
return p.bootcInstallImageToDisk(quiet)
139140
}
141+
logrus.Debug("Found existing disk image, comparing digest")
140142
defer f.Close()
141143
buf := make([]byte, 4096)
142144
len, err := unix.Fgetxattr(int(f.Fd()), imageMetaXattr, buf)
143145
if err != nil {
144146
// If there's no xattr, just remove it
145147
os.Remove(diskPath)
148+
logrus.Debugf("No %s xattr found", imageMetaXattr)
146149
return p.bootcInstallImageToDisk(quiet)
147150
}
148151
bufTrimmed := buf[:len]
@@ -170,7 +173,7 @@ func align(size int64, align int64) int64 {
170173

171174
// bootcInstallImageToDisk creates a disk image from a bootc container
172175
func (p *BootcDisk) bootcInstallImageToDisk(quiet bool) (err error) {
173-
println("Creating bootc disk image...")
176+
fmt.Printf("Executing `bootc install to-disk` from container image %s to create disk image\n", p.RepoTag)
174177
p.file, err = os.CreateTemp(p.Directory, "podman-bootc-tempdisk")
175178
if err != nil {
176179
return err
@@ -186,6 +189,7 @@ func (p *BootcDisk) bootcInstallImageToDisk(quiet bool) (err error) {
186189
if err := syscall.Ftruncate(int(p.file.Fd()), size); err != nil {
187190
return err
188191
}
192+
logrus.Debugf("Created %s with size %v", p.file.Name(), diskSize)
189193
doCleanupDisk := true
190194
defer func() {
191195
if doCleanupDisk {
@@ -260,16 +264,19 @@ func (p *BootcDisk) runInstallContainer(quiet bool) (err error) {
260264
}
261265

262266
p.bootcInstallContainerId = createResponse.ID //save the id for possible cleanup
267+
logrus.Debugf("Created install container, id=%s", createResponse.ID)
263268

264269
// run the container to create the disk
265270
err = containers.Start(p.Ctx, p.bootcInstallContainerId, &containers.StartOptions{})
266271
if err != nil {
267272
return fmt.Errorf("failed to start container: %w", err)
268273
}
274+
logrus.Debugf("Started install container")
269275

270276
var exitCode int32
271277
if quiet {
272278
//wait for the container to finish
279+
logrus.Debugf("Waiting for container completion")
273280
exitCode, err = containers.Wait(p.Ctx, p.bootcInstallContainerId, nil)
274281
if err != nil {
275282
return fmt.Errorf("failed to wait for container: %w", err)
@@ -311,6 +318,7 @@ func (p *BootcDisk) runInstallContainer(quiet bool) (err error) {
311318
}()
312319

313320
//wait for the container to finish
321+
logrus.Debugf("Waiting for container completion (streaming output)")
314322
exitCode, err = containers.Wait(p.Ctx, p.bootcInstallContainerId, nil)
315323
if err != nil {
316324
return fmt.Errorf("failed to wait for container: %w", err)

0 commit comments

Comments
 (0)