Skip to content

Commit

Permalink
Merge pull request #4249 from spidernet-io/robot/cherrypick/pr4157/re…
Browse files Browse the repository at this point in the history
…lease-v1.0

fix: scanAll typo
  • Loading branch information
cyclinder authored Nov 4, 2024
2 parents e8bea7e + 824be9b commit 31035eb
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/spiderpool-agent/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func DaemonMain() {

// Load spiderpool's global Comfigmap.
if err := agentContext.LoadConfigmap(); err != nil {
logger.Sugar().Fatal("Failed to load Configmap spiderpool-conf: %v", err)
logger.Sugar().Fatalf("Failed to load Configmap spiderpool-conf: %v", err)
}
logger.Sugar().Infof("Spiderpool-agent config: %+v", agentContext.Cfg)

Expand Down
2 changes: 1 addition & 1 deletion cmd/spiderpool-controller/cmd/crd_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type _webhookHealthCheck struct{}
// ServeHTTP only serves for SpiderIPPool webhook health check, it will return http status code 200 for GET request
func (*_webhookHealthCheck) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
if request.Method == http.MethodGet {
//logger.Debug("SpiderIPPool webhook health check ready")
writer.WriteHeader(http.StatusOK)
logger.Info("Webhook health check successful")
}
}
22 changes: 11 additions & 11 deletions cmd/spiderpool-init/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ func (c *CoreClient) WaitForIPPoolCreated(ctx context.Context, ipPool *spiderpoo
logger := logutils.FromContext(ctx)

for {
err := c.Create(ctx, ipPool)
if err == nil {
logger.Sugar().Infof("Succeed to create default IPv%d IPPool: %+v", *ipPool.Spec.IPVersion, *ipPool)
return nil
}

if apierrors.IsAlreadyExists(err) {
logger.Sugar().Infof("Default IPv%d IPPool %s is already exists, ignore creating", *ipPool.Spec.IPVersion, ipPool.Name)
return nil
}

select {
case <-ctx.Done():
return ctx.Err()
default:
err := c.Create(ctx, ipPool)
if err == nil {
logger.Sugar().Infof("Succeed to create default IPv%d IPPool: %+v", *ipPool.Spec.IPVersion, *ipPool)
return nil
}

if apierrors.IsAlreadyExists(err) {
logger.Sugar().Infof("Default IPv%d IPPool %s is already exists, ignore creating", *ipPool.Spec.IPVersion, ipPool.Name)
return nil
}

interval := retryIntervalSec * time.Second
logger.Sugar().Infof("Failed to create default IPv%d IPPool %s, recreate in %s: %v", *ipPool.Spec.IPVersion, ipPool.Name, interval, err)
time.Sleep(interval)
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/arch-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Spiderpool 架构如上所示,包含了以下组件:
[RDMA CNI](https://github.com/k8snetworkplumbingwg/rdma-cni): 实现 RDMA 网卡的网络命名空间隔离

[SR-IOV network operator](https://github.com/k8snetworkplumbingwg/sriov-network-operator): 便于安装和配置使用 sriov-cni

## 应用场景:Pod 接入一个 overlay CNI 和若干个 underlay CNI 网卡

![arch_underlay](../images/spiderpool-overlay.jpg)
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/coordinator-zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Coordinator

**简体中文** | [**English**](coordinator.md)
**简体中文** | [**English**](coordinator.md)

Spiderpool 内置一个叫 `coordinator` 的 CNI meta-plugin, 它在 Main CNI 被调用之后再工作,它主要提供以下几个主要功能:

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/coordinator.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Spiderpool incorporates a CNI meta-plugin called `coordinator` that works after
- Check the reachability of Pod gateways
- Support fixed Mac address prefixes for Pods

Note: If your OS(such as Fedora, CentOS, etc.) uses NetworkManager, highly recommend configuring following configuration file at `/etc/NetworkManager/conf.d/spidernet.conf` to
Note: If your OS(such as Fedora, CentOS, etc.) uses NetworkManager, highly recommend configuring following configuration file at `/etc/NetworkManager/conf.d/spidernet.conf` to
prevent interference from NetworkManager with veth interfaces created through `coordinator`:

```shell
Expand Down
1 change: 1 addition & 0 deletions docs/usage/network-topology-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ spec:
{
"ipv4": ["test-ippool-6", "test-ippool-7"]
}
v1.multus-cni.io/default-network: kube-system/macvlan-conf
labels:
app: test-app
spec:
Expand Down
1 change: 1 addition & 0 deletions docs/usage/network-topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ spec:
{
"ipv4": ["test-ippool-6", "test-ippool-7"]
}
v1.multus-cni.io/default-network: kube-system/macvlan-conf
labels:
app: test-app
spec:
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/route-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
我们也可为 SpiderIPPool 资源配置路由(`spec.routes`),创建 Pod 时会继承该路由:

> - 当 SpiderIPPool 资源配置了网关地址后,请勿为路由字段配置默认路由。
> - 当 SpiderIPPool 资源配置了网关地址后,请勿为路由字段配置默认路由。
> - `dst` 和 `gw` 字段都为必填

```yaml
Expand Down
6 changes: 1 addition & 5 deletions pkg/coordinatormanager/coordinator_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ func validateCoordinatorExtraCIDR(cidrs []string) *field.Error {
}

func validateCoordinatorPodMACPrefix(prefix *string) *field.Error {
if prefix == nil {
return nil
}

if *prefix == "" {
if prefix == nil || *prefix == "" {
return nil
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/gcmanager/scanAll_IPPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ func (s *SpiderGC) monitorGCSignal(ctx context.Context) {
// executeScanAll scans the whole pod and whole IPPoolList
func (s *SpiderGC) executeScanAll(ctx context.Context) {
poolList, err := s.ippoolMgr.ListIPPools(ctx, constant.UseCache)
if nil != err {
if err != nil {
if apierrors.IsNotFound(err) {
logger.Sugar().Warnf("scan all failed, ippoolList not found!")
return
}

logger.Sugar().Errorf("scan all failed: '%v'", err)
return
}
Expand Down Expand Up @@ -137,7 +136,7 @@ func (s *SpiderGC) executeScanAll(ctx context.Context) {
flagGCEndpoint = false
goto GCIP
} else {
scanAllLogger.Sugar().Errorf("pod %s/%s does not exist and failed to get endpoint %s/%s, ignore handle IP %s and endpoint, error: '%v'", podNS, podName, podNS, podName, poolIP, err)
scanAllLogger.Sugar().Errorf("pod %s/%s does not exist and failed to get endpoint %s/%s, ignore handle IP %s and endpoint, error: '%v'", podNS, podName, podNS, podName, poolIP, endpointErr)
continue
}
} else {
Expand All @@ -157,7 +156,7 @@ func (s *SpiderGC) executeScanAll(ctx context.Context) {
}
}
} else {
scanAllLogger.Sugar().Errorf("failed to get pod from kubernetes, error '%v'", err)
scanAllLogger.Sugar().Errorf("failed to get pod from kubernetes, error '%v'", podErr)
continue
}
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/ip/cidr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ func ParseCIDR(version types.IPVersion, subnet string) (*net.IPNet, error) {
if err := IsCIDR(version, subnet); err != nil {
return nil, err
}
_, ipNet, _ := net.ParseCIDR(subnet)

_, ipNet, err := net.ParseCIDR(subnet)
if err != nil {
return nil, fmt.Errorf("failed to parse CIDR '%s': %v", subnet, err)
}
return ipNet, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/multuscniconfig/multusconfig_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func checkExistedConfig(spec *spiderpoolv2beta1.MultusCNIConfigSpec, exclude str

func validateCNIConfig(multusConfig *spiderpoolv2beta1.SpiderMultusConfig) *field.Error {
// with Kubernetes OpenAPI validation and Mutating Webhook, multusConfSpec.CniType must not be nil and default to "custom"
if multusConfig.Spec.CniType == nil {
return field.Invalid(cniTypeField, nil, "CniType must not be nil")
}

switch *multusConfig.Spec.CniType {
case constant.MacvlanCNI:
if multusConfig.Spec.MacvlanConfig == nil {
Expand Down

0 comments on commit 31035eb

Please sign in to comment.