From df0099036c4f47ef262d846dbe7db9ecdd16ead3 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Thu, 11 Feb 2021 00:03:42 +0300 Subject: [PATCH] fix: correctly extract wrapped error messages In our client API, as the request goes through `apid` proxying, actual error might be wrapped into the response (to support multi-node requests), so it should always be correctly unwrapped. This has UX issue: `talosctl apply-config` silently doesn't work (server API fails, but no errror is shown in `talosctl`). Signed-off-by: Andrey Smirnov --- pkg/machinery/client/client.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/machinery/client/client.go b/pkg/machinery/client/client.go index aa9906dcf3..a80d18f85a 100644 --- a/pkg/machinery/client/client.go +++ b/pkg/machinery/client/client.go @@ -384,7 +384,13 @@ func (c *Client) Kubeconfig(ctx context.Context) ([]byte, error) { // ApplyConfiguration implements proto.MachineServiceClient interface. func (c *Client) ApplyConfiguration(ctx context.Context, req *machineapi.ApplyConfigurationRequest, callOptions ...grpc.CallOption) (resp *machineapi.ApplyConfigurationResponse, err error) { - return c.MachineClient.ApplyConfiguration(ctx, req, callOptions...) + resp, err = c.MachineClient.ApplyConfiguration(ctx, req, callOptions...) + + var filtered interface{} + filtered, err = FilterMessages(resp, err) + resp, _ = filtered.(*machineapi.ApplyConfigurationResponse) //nolint: errcheck + + return } // GenerateConfiguration implements proto.MachineServiceClient interface. @@ -394,7 +400,13 @@ func (c *Client) GenerateConfiguration(ctx context.Context, req *machineapi.Gene // Disks returns the list of block devices. func (c *Client) Disks(ctx context.Context, callOptions ...grpc.CallOption) (resp *storageapi.DisksResponse, err error) { - return c.StorageClient.Disks(ctx, &empty.Empty{}, callOptions...) + resp, err = c.StorageClient.Disks(ctx, &empty.Empty{}, callOptions...) + + var filtered interface{} + filtered, err = FilterMessages(resp, err) + resp, _ = filtered.(*storageapi.DisksResponse) //nolint: errcheck + + return } // Stats implements the proto.MachineServiceClient interface.