diff --git a/cmd/dist-receiver/main.go b/cmd/dist-receiver/main.go index 81cb6d9e9ac..8ee0dc8e633 100644 --- a/cmd/dist-receiver/main.go +++ b/cmd/dist-receiver/main.go @@ -46,7 +46,9 @@ func main() { http.HandleFunc("/next", next) http.HandleFunc("/connect", connect) go func() { - http.ListenAndServe("0.0.0.0:4002", nil) + if err := http.ListenAndServe("0.0.0.0:4002", nil); err != nil { + panic(fmt.Errorf("failed to spawn command receiver: %s", err)) + } }() ctx, cancel := context.WithCancel(context.Background()) @@ -57,18 +59,27 @@ func main() { panic(fmt.Errorf("failed to spawn ephemeral node: %s", err)) } - connectToPeers(ctx, node, []string{args[1]}) + if err := connectToPeers(ctx, node, []string{args[1]}); err != nil { + fmt.Fprintln(os.Stderr, "Failed to connect to root peer: {}", err) + } stageNow = 1 <-sig - connectToPeers(ctx, node, targets) + if err := connectToPeers(ctx, node, targets); err != nil { + fmt.Fprintln(os.Stderr, "Failed to connect to peers: {}", err) + } cid := icorepath.New(args[2]) - node.Dht().Provide(ctx, cid) - node.Pin().Add(ctx, cid) + if err := node.Dht().Provide(ctx, cid); err != nil { + fmt.Fprintln(os.Stderr, "Failed to seed the resource file: {}", err) + } + + if err := node.Pin().Add(ctx, cid); err != nil { + fmt.Fprintln(os.Stderr, "Failed to pin the resource file: {}", err) + } rootNode, err := node.Unixfs().Get(ctx, cid) @@ -76,7 +87,9 @@ func main() { panic(fmt.Errorf("could not get file with CID: %s", err)) } - os.RemoveAll(args[3]) + if err := os.RemoveAll(args[3]); err != nil { + panic(fmt.Errorf("could not clean previous temporary file: %s", err)) + } err = files.WriteTo(rootNode, args[3]) if err != nil { diff --git a/pkg/imagedistributor/p2p_distributor.go b/pkg/imagedistributor/p2p_distributor.go index 812d7869380..e37d444ee72 100644 --- a/pkg/imagedistributor/p2p_distributor.go +++ b/pkg/imagedistributor/p2p_distributor.go @@ -61,7 +61,9 @@ func (p *p2pDistributor) DistributeRegistry(deployHosts []net.IP, dataDir string logrus.Infof("Distributing %s", info.MountDir) - p.distributeImpl(deployHosts, info.MountDir, dataDir) + if err := p.distributeImpl(deployHosts, info.MountDir, dataDir); err != nil { + return fmt.Errorf("failed to distribute: %s", err) + } } return nil @@ -78,7 +80,9 @@ func (p *p2pDistributor) Distribute(hosts []net.IP, dest string) error { return err } - p.distributeImpl(hosts, info.MountDir, dest) + if err := p.distributeImpl(hosts, info.MountDir, dest); err != nil { + return fmt.Errorf("failed to distribute: %s", err) + } } return nil