Fix global service incompatibility when v1.14 agents connect to a v1.13 cluster #27882
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: this fix targets v1.14 only, as the ClusterID field of the ClusterService struct has been introduced in v1.14, and thus on v1.15 we can safely assume that it is present (as we support one minor version skew between clusters).
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: @LukeFrostmourne