Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/helm-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
- name: Run chart-testing (install)
id: install
run: |
timeout 120 bash -c 'until kubectl get node -l node-role.kubernetes.io/control-plane -o name 2>/dev/null | grep -q .; do echo "Waiting for control-plane nodes to be labeled..."; sleep 2; done'
kubectl label node --overwrite -l node-role.kubernetes.io/control-plane kube-ovn/role=master
ct install --target-branch ${{ github.event.repository.default_branch }} --config charts/kube-ovn-v2/ct.yaml

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ check-kube-ovn-pod-restarts:

.PHONY: install-chart
install-chart:
@timeout 120 bash -c 'until kubectl get node -l node-role.kubernetes.io/control-plane -o name 2>/dev/null | grep -q .; do echo "Waiting for control-plane nodes to be labeled..."; sleep 2; done'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This command is duplicated in the install-chart-v2 target on line 254. To improve maintainability and avoid duplication, consider extracting this logic into a reusable define block, similar to other wait helpers in this Makefile like kubectl_wait_exist.

For example, you could add the following definition alongside the other define blocks:

define wait_for_labeled_nodes
	@timeout 120 bash -c 'until kubectl get node -l "$(1)" -o name 2>/dev/null | grep -q .; do echo "Waiting for nodes with label $(1) to appear..."; sleep 2; done'
endef

And then call it in both install-chart and install-chart-v2 targets. This also makes the waiting message clearer.

	$(call wait_for_labeled_nodes,node-role.kubernetes.io/control-plane)

kubectl label node --overwrite -l node-role.kubernetes.io/control-plane kube-ovn/role=master
helm install kubeovn ./charts/kube-ovn --wait \
--set global.images.kubeovn.tag=$(VERSION) \
Expand Down Expand Up @@ -250,6 +251,7 @@ upgrade-chart:

.PHONY: install-chart-v2
install-chart-v2:
@timeout 120 bash -c 'until kubectl get node -l node-role.kubernetes.io/control-plane -o name 2>/dev/null | grep -q .; do echo "Waiting for control-plane nodes to be labeled..."; sleep 2; done'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This command is a duplicate of the one in the install-chart target on line 189. To improve maintainability, please see my suggestion on that line to refactor this into a reusable define block.

	$(call wait_for_labeled_nodes,node-role.kubernetes.io/control-plane)

kubectl label node --overwrite -l node-role.kubernetes.io/control-plane kube-ovn/role=master
helm install kubeovn ./charts/kube-ovn-v2 --wait \
--set global.images.kubeovn.tag=$(VERSION) \
Expand Down
Loading