Skip to content

Commit

Permalink
fix coordinator webhook (#2284)
Browse files Browse the repository at this point in the history
Signed-off-by: Icarus9913 <icaruswu66@qq.com>
  • Loading branch information
Icarus9913 authored Aug 31, 2023
1 parent 99e8fe7 commit 095c4f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/v1/agent/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ definitions:
items:
type: string
required:
- mode
- overlayPodCIDR
- serviceCIDR
- mode
- tunePodRoutes
GetCoordinatorArgs:
description: Get Coordinator Args
Expand Down
4 changes: 2 additions & 2 deletions api/v1/agent/server/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions cmd/spiderpool-agent/cmd/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,13 @@ func (g *_unixGetCoordinatorConfig) Handle(params daemonset.GetCoordinatorConfig
DetectIPConflict: *coord.Spec.DetectIPConflict,
PodNICs: spNics,
}

if config.OverlayPodCIDR == nil {
config.OverlayPodCIDR = []string{}
}
if config.ServiceCIDR == nil {
config.OverlayPodCIDR = []string{}
}

return daemonset.NewGetCoordinatorConfigOK().WithPayload(config)
}
3 changes: 2 additions & 1 deletion pkg/coordinatormanager/coordinator_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/utils/strings/slices"

spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1"
)
Expand Down Expand Up @@ -86,7 +87,7 @@ func ValidateCoordinatorSpec(spec *spiderpoolv2beta1.CoordinatorSpec, requireOpt
}

func validateCoordinatorPodCIDRType(t string) *field.Error {
if t != cluster && t != calico && t != cilium {
if !slices.Contains(SupportedPodCIDRType, t) {
return field.NotSupported(
podCIDRTypeField,
t,
Expand Down

0 comments on commit 095c4f2

Please sign in to comment.