@@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "net"
78 "os"
@@ -11,7 +12,6 @@ import (
1112 "syscall"
1213 "time"
1314
14- "github.com/pkg/errors"
1515 "github.com/sirupsen/logrus"
1616 "github.com/spf13/cobra"
1717 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -90,12 +90,12 @@ func newGatherBootstrapCmd(ctx context.Context) *cobra.Command {
9090func runGatherBootstrapCmd (ctx context.Context , directory string ) (string , error ) {
9191 assetStore , err := assetstore .NewStore (directory )
9292 if err != nil {
93- return "" , errors . Wrap ( err , "failed to create asset store" )
93+ return "" , fmt . Errorf ( "failed to create asset store: %w" , err )
9494 }
9595 // add the default bootstrap key pair to the sshKeys list
9696 bootstrapSSHKeyPair := & tls.BootstrapSSHKeyPair {}
9797 if err := assetStore .Fetch (ctx , bootstrapSSHKeyPair ); err != nil {
98- return "" , errors . Wrapf ( err , "failed to fetch %s" , bootstrapSSHKeyPair .Name ())
98+ return "" , fmt . Errorf ( "failed to fetch %s: %w " , bootstrapSSHKeyPair .Name (), err )
9999 }
100100 tmpfile , err := os .CreateTemp ("" , "bootstrap-ssh" )
101101 if err != nil {
@@ -119,7 +119,7 @@ func runGatherBootstrapCmd(ctx context.Context, directory string) (string, error
119119 if ha .Bootstrap == "" && len (ha .Masters ) == 0 {
120120 config := & installconfig.InstallConfig {}
121121 if err := assetStore .Fetch (ctx , config ); err != nil {
122- return "" , errors . Wrapf ( err , "failed to fetch %s" , config .Name ())
122+ return "" , fmt . Errorf ( "failed to fetch %s: %w " , config .Name (), err )
123123 }
124124
125125 provider , err := infra .ProviderForPlatform (config .Config .Platform .Name (), config .Config .EnabledFeatureGates ())
@@ -145,7 +145,7 @@ func gatherBootstrap(bootstrap string, port int, masters []string, directory str
145145 serialLogBundle := filepath .Join (directory , fmt .Sprintf ("serial-log-bundle-%s.tar.gz" , gatherID ))
146146 serialLogBundlePath , err := filepath .Abs (serialLogBundle )
147147 if err != nil {
148- return "" , errors . Wrap ( err , "failed to stat log file" )
148+ return "" , fmt . Errorf ( "failed to stat log file: %w" , err )
149149 }
150150
151151 consoleGather , err := serialgather .New (logrus .StandardLogger (), serialLogBundlePath , bootstrap , masters , directory )
@@ -174,7 +174,7 @@ func gatherBootstrap(bootstrap string, port int, masters []string, directory str
174174 logBundlePath := filepath .Join (directory , fmt .Sprintf ("log-bundle-%s.tar.gz" , gatherID ))
175175 err = serialgather .CombineArchives (logBundlePath , archives )
176176 if err != nil {
177- return "" , errors . Wrap ( err , "failed to combine archives" )
177+ return "" , fmt . Errorf ( "failed to combine archives: %w" , err )
178178 }
179179
180180 return logBundlePath , nil
@@ -185,23 +185,23 @@ func pullLogsFromBootstrap(gatherID string, bootstrap string, port int, masters
185185 client , err := ssh .NewClient ("core" , net .JoinHostPort (bootstrap , strconv .Itoa (port )), gatherBootstrapOpts .sshKeys )
186186 if err != nil {
187187 if errors .Is (err , syscall .ECONNREFUSED ) || errors .Is (err , syscall .ETIMEDOUT ) {
188- return "" , errors . Wrap ( err , "failed to connect to the bootstrap machine" )
188+ return "" , fmt . Errorf ( "failed to connect to the bootstrap machine: %w" , err )
189189 }
190- return "" , errors . Wrap ( err , "failed to create SSH client" )
190+ return "" , fmt . Errorf ( "failed to create SSH client: %w" , err )
191191 }
192192
193193 if err := ssh .Run (client , fmt .Sprintf ("/usr/local/bin/installer-gather.sh --id %s %s" , gatherID , strings .Join (masters , " " ))); err != nil {
194- return "" , errors . Wrap ( err , "failed to run remote command" )
194+ return "" , fmt . Errorf ( "failed to run remote command: %w" , err )
195195 }
196196
197197 file := filepath .Join (directory , fmt .Sprintf ("cluster-log-bundle-%s.tar.gz" , gatherID ))
198198 if err := ssh .PullFileTo (client , fmt .Sprintf ("/home/core/log-bundle-%s.tar.gz" , gatherID ), file ); err != nil {
199- return "" , errors . Wrap ( err , "failed to pull log file from remote" )
199+ return "" , fmt . Errorf ( "failed to pull log file from remote: %w" , err )
200200 }
201201
202202 clusterLogBundlePath , err := filepath .Abs (file )
203203 if err != nil {
204- return "" , errors . Wrap ( err , "failed to stat log file" )
204+ return "" , fmt . Errorf ( "failed to stat log file: %w" , err )
205205 }
206206
207207 return clusterLogBundlePath , nil
@@ -210,12 +210,12 @@ func pullLogsFromBootstrap(gatherID string, bootstrap string, port int, masters
210210func logClusterOperatorConditions (ctx context.Context , config * rest.Config ) error {
211211 client , err := configclient .NewForConfig (config )
212212 if err != nil {
213- return errors . Wrap ( err , "creating a config client" )
213+ return fmt . Errorf ( "creating a config client: %w" , err )
214214 }
215215
216216 operators , err := client .ConfigV1 ().ClusterOperators ().List (ctx , metav1.ListOptions {})
217217 if err != nil {
218- return errors . Wrap ( err , "listing ClusterOperator objects" )
218+ return fmt . Errorf ( "listing ClusterOperator objects: %w" , err )
219219 }
220220
221221 for _ , operator := range operators .Items {
0 commit comments