Skip to content

Commit

Permalink
Fix backward incompatibility regression.
Browse files Browse the repository at this point in the history
The introduction of argo-rollouts introduced a call to the new
traffic-manager function `GetKnownWorkloadKinds` from the user client,
and a client connecting to older traffic-managers that don't have this
method would therefore fail with an error.

This commit checks if the returned error has code `Unimplemented`, and
if so, assumes the default set of workload kinds.

Signed-off-by: Thomas Hallgren <thomas@tada.se>
  • Loading branch information
thallgren committed Aug 18, 2024
1 parent ea72611 commit 564074a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion pkg/client/userd/daemon/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,18 @@ func (s *service) List(c context.Context, lr *rpc.ListRequest) (result *rpc.Work
func (s *service) GetKnownWorkloadKinds(ctx context.Context, _ *empty.Empty) (result *manager.KnownWorkloadKinds, err error) {
err = s.WithSession(ctx, "GetKnownWorkloadKinds", func(ctx context.Context, session userd.Session) error {
result, err = session.ManagerClient().GetKnownWorkloadKinds(ctx, session.SessionInfo())
return err
if err != nil {
if status.Code(err) != codes.Unimplemented {
return err
}
// Talking to an older traffic-manager, use legacy default types
result = &manager.KnownWorkloadKinds{Kinds: []manager.WorkloadInfo_Kind{
manager.WorkloadInfo_DEPLOYMENT,
manager.WorkloadInfo_REPLICASET,
manager.WorkloadInfo_STATEFULSET,
}}
}
return nil
})
return result, err
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/client/userd/trafficmgr/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,15 @@ func connectMgr(

knownWorkloadKinds, err := mClient.GetKnownWorkloadKinds(ctx, si)
if err != nil {
return nil, fmt.Errorf("failed to get known workload kinds: %w", err)
if status.Code(err) != codes.Unimplemented {
return nil, fmt.Errorf("failed to get known workload kinds: %w", err)
}
// Talking to an older traffic-manager, use legacy default types
knownWorkloadKinds = &manager.KnownWorkloadKinds{Kinds: []manager.WorkloadInfo_Kind{
manager.WorkloadInfo_DEPLOYMENT,
manager.WorkloadInfo_REPLICASET,
manager.WorkloadInfo_STATEFULSET,
}}
}

sess := &session{
Expand Down

0 comments on commit 564074a

Please sign in to comment.