mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-11 08:20:16 -04:00
AB#2033 Remove redundant "failed" in error wrapping
Remove "failed" from wrapped errors Where appropriate rephrase "unable to/could not" to "failed" in root errors Start error log messages with "Failed"
This commit is contained in:
parent
0c9ca50be8
commit
9441e46e4b
56 changed files with 204 additions and 204 deletions
|
@ -43,17 +43,17 @@ func (d *Download) DownloadCoordinator(ctx context.Context, ip string) error {
|
|||
d.attemptedDownloads[serverAddr] = time.Now()
|
||||
conn, err := d.dial(ctx, serverAddr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error connecting to other instance via gRPC: %w", err)
|
||||
return fmt.Errorf("connecting to other instance via gRPC: %w", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
client := pb.NewDebugdClient(conn)
|
||||
|
||||
stream, err := client.DownloadCoordinator(ctx, &pb.DownloadCoordinatorRequest{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("starting coordinator download from other instance failed: %w", err)
|
||||
return fmt.Errorf("starting coordinator download from other instance: %w", err)
|
||||
}
|
||||
if err := d.writer.WriteStream(debugd.CoordinatorDeployFilename, stream, true); err != nil {
|
||||
return fmt.Errorf("streaming coordinator from other instance failed: %w", err)
|
||||
return fmt.Errorf("streaming coordinator from other instance: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Successfully downloaded coordinator from %s\n", ip)
|
||||
|
@ -64,7 +64,7 @@ func (d *Download) DownloadCoordinator(ctx context.Context, ip string) error {
|
|||
Action: Restart,
|
||||
}
|
||||
if err := d.serviceManager.SystemdAction(ctx, restartAction); err != nil {
|
||||
return fmt.Errorf("restarting coordinator failed: %w", err)
|
||||
return fmt.Errorf("restarting coordinator: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -157,7 +157,7 @@ func (f *fakeStreamToFileWriter) WriteStream(filename string, stream coordinator
|
|||
if errors.Is(err, io.EOF) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("reading stream failed: %w", err)
|
||||
return fmt.Errorf("reading stream: %w", err)
|
||||
}
|
||||
f.chunks = append(f.chunks, chunk.Content)
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ type fakeOnlyDownloadServer struct {
|
|||
func (f *fakeOnlyDownloadServer) DownloadCoordinator(request *pb.DownloadCoordinatorRequest, stream pb.Debugd_DownloadCoordinatorServer) error {
|
||||
for _, chunk := range f.chunks {
|
||||
if err := stream.Send(&pb.Chunk{Content: chunk}); err != nil {
|
||||
return fmt.Errorf("sending chunk failed: %w", err)
|
||||
return fmt.Errorf("sending chunk: %w", err)
|
||||
}
|
||||
}
|
||||
return f.downladErr
|
||||
|
|
|
@ -80,7 +80,7 @@ type dbusConn interface {
|
|||
func (s *ServiceManager) SystemdAction(ctx context.Context, request ServiceManagerRequest) error {
|
||||
conn, err := s.dbus.NewSystemdConnectionContext(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("establishing systemd connection failed: %w", err)
|
||||
return fmt.Errorf("establishing systemd connection: %w", err)
|
||||
}
|
||||
|
||||
resultChan := make(chan string)
|
||||
|
@ -97,7 +97,7 @@ func (s *ServiceManager) SystemdAction(ctx context.Context, request ServiceManag
|
|||
return errors.New("unknown systemd action: " + request.Action.String())
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to perform systemd action %v on unit %v: %w", request.Action, request.Unit, err)
|
||||
return fmt.Errorf("performing systemd action %v on unit %v: %w", request.Action, request.Unit, err)
|
||||
}
|
||||
|
||||
if request.Action == Reload {
|
||||
|
@ -124,11 +124,11 @@ func (s *ServiceManager) WriteSystemdUnitFile(ctx context.Context, unit SystemdU
|
|||
s.systemdUnitFilewriteLock.Lock()
|
||||
defer s.systemdUnitFilewriteLock.Unlock()
|
||||
if err := afero.WriteFile(s.fs, fmt.Sprintf("%s/%s", systemdUnitFolder, unit.Name), []byte(unit.Contents), 0o644); err != nil {
|
||||
return fmt.Errorf("writing systemd unit file \"%v\" failed: %w", unit.Name, err)
|
||||
return fmt.Errorf("writing systemd unit file \"%v\": %w", unit.Name, err)
|
||||
}
|
||||
|
||||
if err := s.SystemdAction(ctx, ServiceManagerRequest{Unit: unit.Name, Action: Reload}); err != nil {
|
||||
return fmt.Errorf("performing systemd daemon-reload failed: %w", err)
|
||||
return fmt.Errorf("performing systemd daemon-reload: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("Wrote systemd unit file: %s/%s and performed daemon-reload\n", systemdUnitFolder, unit.Name)
|
||||
|
@ -142,7 +142,7 @@ func DeployDefaultServiceUnit(ctx context.Context, serviceManager *ServiceManage
|
|||
Name: debugd.CoordinatorSystemdUnitName,
|
||||
Contents: debugd.CoordinatorSystemdUnitContents,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("writing systemd unit file %q failed: %w", debugd.CoordinatorSystemdUnitName, err)
|
||||
return fmt.Errorf("writing systemd unit file %q: %w", debugd.CoordinatorSystemdUnitName, err)
|
||||
}
|
||||
|
||||
// try to start the default service if the binary exists but ignore failure.
|
||||
|
|
|
@ -51,11 +51,11 @@ func NewAzure(ctx context.Context) (*Fetcher, error) {
|
|||
func (f *Fetcher) DiscoverDebugdIPs(ctx context.Context) ([]string, error) {
|
||||
self, err := f.metaAPI.Self(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving own instance failed: %w", err)
|
||||
return nil, fmt.Errorf("retrieving own instance: %w", err)
|
||||
}
|
||||
instances, err := f.metaAPI.List(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving instances failed: %w", err)
|
||||
return nil, fmt.Errorf("retrieving instances: %w", err)
|
||||
}
|
||||
// filter own instance from instance list
|
||||
for i, instance := range instances {
|
||||
|
@ -75,7 +75,7 @@ func (f *Fetcher) DiscoverDebugdIPs(ctx context.Context) ([]string, error) {
|
|||
func (f *Fetcher) FetchSSHKeys(ctx context.Context) ([]ssh.UserKey, error) {
|
||||
self, err := f.metaAPI.Self(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving ssh keys from cloud provider metadata failed: %w", err)
|
||||
return nil, fmt.Errorf("retrieving ssh keys from cloud provider metadata: %w", err)
|
||||
}
|
||||
|
||||
keys := []ssh.UserKey{}
|
||||
|
|
|
@ -77,7 +77,7 @@ func (s *debugdServer) UploadCoordinator(stream pb.Debugd_UploadCoordinatorServe
|
|||
}
|
||||
log.Printf("Uploading coordinator failed: %v\n", err)
|
||||
responseStatus = pb.UploadCoordinatorStatus_UPLOAD_COORDINATOR_UPLOAD_FAILED
|
||||
return fmt.Errorf("uploading coordinator failed: %w", err)
|
||||
return fmt.Errorf("uploading coordinator: %w", err)
|
||||
}
|
||||
|
||||
log.Println("Successfully uploaded coordinator")
|
||||
|
@ -110,7 +110,7 @@ func Start(wg *sync.WaitGroup, serv pb.DebugdServer) {
|
|||
pb.RegisterDebugdServer(grpcServer, serv)
|
||||
lis, err := net.Listen("tcp", net.JoinHostPort("0.0.0.0", debugd.DebugdPort))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
log.Fatalf("listening failed: %v", err)
|
||||
}
|
||||
log.Println("gRPC server is waiting for connections")
|
||||
grpcServer.Serve(lis)
|
||||
|
|
|
@ -381,7 +381,7 @@ func (f *fakeStreamer) WriteStream(filename string, stream coordinator.ReadChunk
|
|||
if errors.Is(err, io.EOF) {
|
||||
return f.writeStreamErr
|
||||
}
|
||||
return fmt.Errorf("reading stream failed: %w", err)
|
||||
return fmt.Errorf("reading stream: %w", err)
|
||||
}
|
||||
f.writeStreamChunks = append(f.writeStreamChunks, chunk.Content)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue