From 5e9b883ad5b6dca594494b146f14618e61f818c8 Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Wed, 26 Feb 2025 12:19:04 +1000 Subject: [PATCH] fix: increase wait time for machine to 5 min, discard unknown when decoding json to proto --- cmd/uncloud/machine/add.go | 2 +- internal/machine/store/store.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/uncloud/machine/add.go b/cmd/uncloud/machine/add.go index d9e5d289..1db44f77 100644 --- a/cmd/uncloud/machine/add.go +++ b/cmd/uncloud/machine/add.go @@ -149,7 +149,7 @@ func add(ctx context.Context, uncli *cli.CLI, remoteMachine cli.RemoteMachine, o func waitClusterInitialised(ctx context.Context, client *client.Client) error { boff := backoff.WithContext(backoff.NewExponentialBackOff( backoff.WithMaxInterval(1*time.Second), - backoff.WithMaxElapsedTime(30*time.Second), + backoff.WithMaxElapsedTime(5*time.Minute), ), ctx) check := func() error { diff --git a/internal/machine/store/store.go b/internal/machine/store/store.go index 099b2078..546cddca 100644 --- a/internal/machine/store/store.go +++ b/internal/machine/store/store.go @@ -79,10 +79,13 @@ func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error) { if err = rows.Scan(&mJSON); err != nil { return nil, err } + + protojsonParser := protojson.UnmarshalOptions{DiscardUnknown: true} var m pb.MachineInfo - if err = protojson.Unmarshal([]byte(mJSON), &m); err != nil { + if err = protojsonParser.Unmarshal([]byte(mJSON), &m); err != nil { return nil, fmt.Errorf("unmarshal machine info: %w", err) } + if err = m.Network.Validate(); err != nil { slog.Error("Invalid network configuration for machine in store", "id", m.Id, "err", err) continue