Skip to content

Commit 073b142

Browse files
authored
Merge pull request #67 from consideRatio/pr/apply-workaround-only-when-needed
Apply workaround added in 3.0.1 only when possible
2 parents 5590e9e + e856938 commit 073b142

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

action.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ runs:
129129
- name: Setup k3s ${{ inputs.k3s-version }}${{ inputs.k3s-channel }}
130130
run: |
131131
echo "::group::Setup k3s ${{ inputs.k3s-version }}${{ inputs.k3s-channel }}"
132+
132133
if [[ "${{ inputs.metrics-enabled }}" != true ]]; then
133134
k3s_disable_metrics="--disable metrics-server"
134135
fi
@@ -138,8 +139,26 @@ runs:
138139
if [[ "${{ inputs.docker-enabled }}" == true ]]; then
139140
k3s_docker=--container-runtime-endpoint=/run/cri-dockerd.sock
140141
fi
141-
if [[ "${{ inputs.extra-setup-args }}" != *--egress-selector-mode* && "${{ inputs.k3s-version }}${{ inputs.k3s-channel }}" != v1.20* ]]; then
142-
default_extra_setup_args=--egress-selector-mode=disabled
142+
# We want to provide a new default value for the --egress-selector-mode
143+
# flag to workaround the intermittent issue tracked here:
144+
# https://github.com/k3s-io/k3s/issues/5633#issuecomment-1181424511.
145+
#
146+
if [[ "${{ inputs.extra-setup-args }}" != *--egress-selector-mode* ]]; then
147+
# We check for k3s versions 1.22.10+, 1.23.7+, or 1.24.1+ or more
148+
# recent where we know the --egress-selector-mode flag is defined.
149+
# This includes when the version isn't specified or is specified as
150+
# latest or stable.
151+
#
152+
# The verlte function was taken from this stackoverflow post:
153+
# https://stackoverflow.com/a/4024263/2220152
154+
#
155+
verlte() {
156+
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
157+
}
158+
v=${{ inputs.k3s-version }}${{ inputs.k3s-channel }}
159+
if ([[ "$v" != v* ]]) || ([[ "$v" == v1.22.* ]] && verlte "v1.22.10" "$v") || ([[ "$v" == v1.23.* ]] && verlte "v1.23.7" "$v") || (verlte "v1.24.1" "$v"); then
160+
default_extra_setup_args=--egress-selector-mode=disabled
161+
fi
143162
fi
144163
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="${{ inputs.k3s-version }}" INSTALL_K3S_CHANNEL="${{ inputs.k3s-channel }}" sh -s - \
145164
${k3s_disable_metrics} \

0 commit comments

Comments
 (0)