Skip to content

Commit

Permalink
service: make global services validation backward compatible
Browse files Browse the repository at this point in the history
2819d7c ("service: add extra validation for global services")
introduced a validation function to prevent unmarshalling invalid global
service objects retrieved from remote clusters. In particular, it
flags a ClusterID=0 as invalid, unless it matches the one of the local
cluster (as that case is supported for external workloads).

Yet, the ClusterID field was not present as part of the ClusterService
struct in v1.13, causing a failure when the v1.14 agents connect to
a cluster still running the v1.13 clustermesh-apiserver. Hence, let's
relax this validation to support ClusterID=0 and prevent issues during
upgrades.

Fixes: 2819d7c ("service: add extra validation for global services")
Reported-by:  Luke <lifeixiangchina@gmail.com>
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
  • Loading branch information
giorio94 authored and bimmlerd committed Sep 7, 2023
1 parent 622781b commit d6ab500
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/service/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/cilium/cilium/pkg/loadbalancer"
"github.com/cilium/cilium/pkg/lock"
"github.com/cilium/cilium/pkg/logging/logfields"
"github.com/cilium/cilium/pkg/option"
)

var (
Expand Down Expand Up @@ -124,9 +123,9 @@ func (s *ClusterService) Unmarshal(_ string, data []byte) error {
}

func (s *ClusterService) validate() error {
// Skip the ClusterID check if it matches the local one, as we assume that
// it has already been validated, and to allow it to be zero.
if s.ClusterID != option.Config.ClusterID {
// Explicitly allow the ClusterID to be zero for backward compatibility,
// as this field was not present in v1.13.
if s.ClusterID != 0 {
if err := cmtypes.ValidateClusterID(s.ClusterID); err != nil {
return err
}
Expand Down

0 comments on commit d6ab500

Please sign in to comment.