Skip to content

Commit

Permalink
Merge pull request spidernet-io#4129 from ty-dc/release-v0.8
Browse files Browse the repository at this point in the history
robot-cherrypick: optimizate spiderpool upgrade CI
  • Loading branch information
cyclinder authored Sep 30, 2024
2 parents f3c0711 + a659ce0 commit 73f0197
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 26 deletions.
1 change: 0 additions & 1 deletion .github/workflows/auto-upgrade-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ jobs:
- name: Upgrade to version ${{ needs.get_ref.outputs.new_version }}
id: upgrade
continue-on-error: true
run: |
RESULT=0
make upgrade_e2e_spiderpool -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ clean_e2e_spiderpool:

.PHONY: upgrade_e2e_spiderpool
upgrade_e2e_spiderpool:
$(QUIET) make -C test upgrade_spiderpool
$(QUIET) make -C test helm_upgrade_spiderpool

.PHONY: codegen
codegen:
Expand Down
4 changes: 4 additions & 0 deletions docs/usage/install/upgrade-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ kubectl patch sp ${auto-pool} --type merge --patch '{"metadata": {"labels": {"ip
在 0.9.4 以下的版本中,statefulSet 应用在快速扩缩容场景下,Spiderpool GC 可能会错误的回收掉 IPPool 中的 IP 地址,导致同一个 IP 被分配给 K8S 集群的多个 Pod,从而出现 IP 地址冲突。该问题已修复,参考[修复](https://github.com/spidernet-io/spiderpool/pull/3778),但在升级后,冲突的 IP 地址并不能自动被 Spiderpool 纠正回来,您需要通过手动重启冲突 IP 的 Pod 来辅助解决,在新版本中不会再出现错误 GC IP 而导致 IP 冲突的问题。
### 低于 0.9.5 (不包含 0.9.5) 升级到最高版本的注意事项
在 0.9.5 以下的版本中,Spiderpool Charts values.yaml 中的 spiderSubnet 字段发生变更,由 `ipam.spidersubnet` 变更为 `ipam.spiderSubnet`,因此,您无法可以安全地使用 `--reuse-values` 标志从 0.9.5 以下版本升级到 0.9.5 及以上版本。请修改 values.yaml 文件,或者使用 `--set ipam.spiderSubnet.enable=true` 标志来覆盖 values.yaml 文件中的值。
### 更多版本升级的注意事项
*TODO.*
Expand Down
4 changes: 4 additions & 0 deletions docs/usage/install/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ Due to the addition of the `txQueueLen` field to the [SpiderCoordinator CRD](./.
In versions below 0.9.4, when statefulSet is rapidly scaling up or down, Spiderpool GC may mistakenly reclaim IP addresses in IPPool, causing the same IP to be assigned to multiple Pods in the K8S cluster, resulting in IP address conflicts. This issue has been fixed, see [Fix](https://github.com/spidernet-io/spiderpool/pull/3778), but after the upgrade, the conflicting IP addresses cannot be automatically corrected by Spiderpool. You need to manually restart the Pod with the conflicting IP to assist in resolving the issue. In the new version, there will no longer be an issue with IP conflicts caused by incorrect GC IPs.
### Upgrading from a version below 0.9.5 (Excludes 0.9.5) to a higher version
In versions lower than 0.9.5, the spiderSubnet field in Spiderpool Charts values.yaml changed from `ipam.spidersubnet` to `ipam.spiderSubnet`, so you cannot safely use the `--reuse-values` flag to upgrade from versions < 0.9.5 to 0.9.5 and above. Please modify the values.yaml file or use the `--set ipam.spiderSubnet.enable=true` flag to override the value in the values.yaml file.
### More notes on version upgrades
*TODO.*
Expand Down
8 changes: 1 addition & 7 deletions pkg/coordinatormanager/coordinator_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ func validateCoordinatorPodMACPrefix(prefix *string) *field.Error {
return errInvalid
}

// the lowest bit of first byte must be 0
// example: 0*:**
if string(parts[0][0]) != "0" {
return field.Invalid(podMACPrefixField, *prefix, "the lowest bit of the first byte must be 0")
}

fb, err := strconv.ParseInt(parts[0], 16, 0)
if err != nil {
return errInvalid
Expand All @@ -167,7 +161,7 @@ func validateCoordinatorPodMACPrefix(prefix *string) *field.Error {

bb := fmt.Sprintf("%08b", fb)
if string(bb[7]) != "0" {
return field.Invalid(podMACPrefixField, *prefix, "not a unicast MAC")
return field.Invalid(podMACPrefixField, *prefix, "not a unicast MAC: the lowest bit of the first byte must be 0")
}

return nil
Expand Down
47 changes: 32 additions & 15 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -399,28 +399,45 @@ uninstall_spiderpool:
done ; \
done

.PHONY: upgrade_spiderpool
upgrade_spiderpool:
@echo -e "\033[35m [upgrade spiderpool] \033[0m"
@make helm_upgrade_spiderpool

.PHONY: helm_upgrade_spiderpool
helm_upgrade_spiderpool:
@echo -e "\033[35m [helm upgrade spiderpool] \033[0m"
kubectl delete po -n $(RELEASE_NAMESPACE) spiderpool-init --kubeconfig $(E2E_KUBECONFIG) || true ;\
HELM_OPTION="";\
HELM_OPTION+=" --set spiderpoolController.replicas=1 " ; \
HELM_OPTION+=" --set spiderpoolAgent.image.registry="" \
--set spiderpoolAgent.image.repository=$(SPIDERPOOL_AGENT_IMAGE_NAME) \
--set spiderpoolAgent.image.tag=$(E2E_SPIDERPOOL_TAG) \
--set spiderpoolController.image.registry="" \
--set spiderpoolController.image.repository=$(SPIDERPOOL_CONTROLLER_IMAGE_NAME) \
--set spiderpoolController.image.tag=$(E2E_SPIDERPOOL_TAG) \
--set spiderpoolInit.image.registry="" \
--set spiderpoolInit.image.repository=$(SPIDERPOOL_CONTROLLER_IMAGE_NAME) \
--set spiderpoolInit.image.tag=$(E2E_SPIDERPOOL_TAG) " \
helm --kubeconfig $(E2E_KUBECONFIG) upgrade $(RELEASE_NAME) $(ROOT_DIR)/charts/spiderpool $${HELM_OPTION} \
-n $(RELEASE_NAMESPACE) ; \
--set spiderpoolAgent.image.repository=$(SPIDERPOOL_AGENT_IMAGE_NAME) \
--set spiderpoolAgent.image.tag=$(E2E_SPIDERPOOL_TAG) \
--set spiderpoolController.image.registry="" \
--set spiderpoolController.image.repository=$(SPIDERPOOL_CONTROLLER_IMAGE_NAME) \
--set spiderpoolController.image.tag=$(E2E_SPIDERPOOL_TAG) \
--set spiderpoolInit.image.registry="" \
--set spiderpoolInit.image.repository=$(SPIDERPOOL_CONTROLLER_IMAGE_NAME) \
--set spiderpoolInit.image.tag=$(E2E_SPIDERPOOL_TAG) \
--set multus.multusCNI.uninstall=false " ; \
if [ "$(E2E_SPIDERPOOL_ENABLE_SUBNET)" == "true" ] ; then \
HELM_OPTION+=" --set ipam.spiderSubnet.enable=true " ; \
HELM_OPTION+=" --set ipam.spiderSubnet.autoPool.enable=true " ; \
HELM_OPTION+=" --set ipam.spiderSubnet.autoPool.defaultRedundantIPNumber=1 " ; \
else \
HELM_OPTION+=" --set ipam.spiderSubnet.enable=false " ; \
HELM_OPTION+=" --set ipam.spiderSubnet.autoPool.enable=true " ; \
HELM_OPTION+=" --set ipam.spiderSubnet.autoPool.defaultRedundantIPNumber=1 " ; \
fi ; \
ALL_IMAGES=`helm template $(RELEASE_NAME) $(ROOT_DIR)/charts/spiderpool $${HELM_OPTION} | grep ' image: ' | tr -d '"' | awk -F 'image: ' '{print $$2}' | sort | uniq | tr '\n' ' '` ; \
echo "ALL_IMAGES: $${ALL_IMAGES} " ; \
for IMAGE in $${ALL_IMAGES}; do \
if ! grep "$${IMAGE}" <<< `docker images | awk '{printf("%s:%s\n",$$1,$$2)}'`; then \
echo "==> $${IMAGE} no found, pulling...." ; \
docker pull $${IMAGE} ; \
fi ; \
kind load docker-image $${IMAGE} --name $(E2E_CLUSTER_NAME); \
done ; \
echo "upgrade spiderpool with image $(SPIDERPOOL_AGENT_IMAGE_NAME):$(E2E_SPIDERPOOL_TAG) and $(SPIDERPOOL_CONTROLLER_IMAGE_NAME):$(E2E_SPIDERPOOL_TAG) " ; \
set -x ; \
helm --kubeconfig $(E2E_KUBECONFIG) upgrade $(RELEASE_NAME) $(ROOT_DIR)/charts/spiderpool \
$${HELM_OPTION} \
-n $(RELEASE_NAMESPACE) --debug --reuse-values ; \
cd $(ROOT_DIR)/charts/spiderpool/crds ; \
ls | grep '\.yaml$$' | xargs -I {} kubectl apply -f {} --kubeconfig $(E2E_KUBECONFIG) ; \
kubectl wait --for=condition=ready -l app.kubernetes.io/instance=spiderpool --timeout=300s pod -n kube-system --kubeconfig $(E2E_KUBECONFIG) || true; \
Expand Down
1 change: 1 addition & 0 deletions test/doc/spidermultus.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
| M00026 | set spidermultusconfig.spec to empty and see if works | p3 | | | |
| M00027 | test podRPFilter and hostRPFilter in spidermultusconfig | p3 | | done |
| M00028 | set hostRPFilter and podRPFilter to a invalid value | p3 | | done |
| M00029 | verify the podMACPrefix filed | p3 | | done | |
53 changes: 52 additions & 1 deletion test/e2e/spidermultus/spidermultus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() {

It("set hostRPFilter and podRPFilter to a invalid value", Label("M00028"), func() {
var smcName string = "invalid-rpfilter-multus-" + common.GenerateString(10, true)

smc := &spiderpoolv2beta1.SpiderMultusConfig{
ObjectMeta: metav1.ObjectMeta{
Name: smcName,
Expand All @@ -462,4 +461,56 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig"), func() {
err := frame.CreateSpiderMultusInstance(smc)
Expect(err).To(HaveOccurred(), "create spiderMultus instance failed: %v\n", err)
})

It("verify the podMACPrefix filed", Label("M00028"), func() {
smcName := "test-multus-" + common.GenerateString(10, true)
smc := &spiderpoolv2beta1.SpiderMultusConfig{
ObjectMeta: metav1.ObjectMeta{
Name: smcName,
Namespace: namespace,
},
Spec: spiderpoolv2beta1.MultusCNIConfigSpec{
CniType: constant.MacvlanCNI,
MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{
Master: []string{"eth0"},
SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{
IPv4IPPool: []string{"spiderpool-ipv4-ippool"},
},
},
EnableCoordinator: ptr.To(true),
CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{
PodMACPrefix: ptr.To("9e:10"),
},
},
}

By("create a spiderMultusConfig with valid podMACPrefix")
err := frame.CreateSpiderMultusInstance(smc)
Expect(err).NotTo(HaveOccurred())

tmpName := "invalid-macprefix" + common.GenerateString(10, true)
invalid := &spiderpoolv2beta1.SpiderMultusConfig{
ObjectMeta: metav1.ObjectMeta{
Name: tmpName,
Namespace: namespace,
},
Spec: spiderpoolv2beta1.MultusCNIConfigSpec{
CniType: constant.MacvlanCNI,
MacvlanConfig: &v2beta1.SpiderMacvlanCniConfig{
Master: []string{"eth0"},
SpiderpoolConfigPools: &v2beta1.SpiderpoolPools{
IPv4IPPool: []string{"spiderpool-ipv4-ippool"},
},
},
EnableCoordinator: ptr.To(true),
CoordinatorConfig: &spiderpoolv2beta1.CoordinatorSpec{
PodMACPrefix: ptr.To("01:10"),
},
},
}

By("create a spiderMultusConfig with invalid podMACPrefix")
err = frame.CreateSpiderMultusInstance(invalid)
Expect(err).To(HaveOccurred(), "create invalid spiderMultusConfig should fail: %v", err)
})
})
1 change: 0 additions & 1 deletion test/scripts/install-default-cni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ function install_cilium() {
CILIUM_HELM_OPTIONS+=" --set ipam.operator.clusterPoolIPv6PodCIDRList=${CILIUM_CLUSTER_POD_SUBNET_V6} \
--set ipv4.enabled=false \
--set ipv6.enabled=true \
--set tunnel=disabled \
--set ipv6NativeRoutingCIDR=${CILIUM_CLUSTER_POD_SUBNET_V6} \
--set autoDirectNodeRoutes=true \
--set enableIPv6Masquerade=true \
Expand Down

0 comments on commit 73f0197

Please sign in to comment.