Visitar URL original
Record removed scheduling.k8s.io group/versions and detect future rem… · pulumi/pulumi-kubernetes@ace9010 · GitHub
Skip to content

Commit ace9010

Browse files
Record removed scheduling.k8s.io group/versions and detect future removals (#4585)
Adds the `scheduling.k8s.io/v1alpha1` `Workload`/`WorkloadList` lifecycle entries that #4570 missed. Without them `RemovedAPIVersion` reports the group/version as still live, so applying one against a 1.36+ cluster hits a retry timeout with a generic API error instead of the actionable removal message. The upgrade workflow now diffs the group/version directories of the old and new `k8s.io/api`. When Kubernetes removed something, it appends the list and the two required hand edits to the generated PR body and fails the run, so the bump still opens a PR but cannot merge unnoticed. ## Test plan - `go test ./pkg/kinds/...` passes; deleting either new entry fails the added test under both the full and truncated group spellings. - Detection checked against the real modules: `v0.35.0` to `v0.36.0` reports `scheduling/v1alpha1`, and `v0.36.3` to `v0.37.0` reports `scheduling/v1alpha2`. The two `autoscaling` betas it also reports for 1.36 already have entries, so it is not over-reporting. - `actionlint` and `golangci-lint` clean.
1 parent aaf05e0 commit ace9010

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎.github/workflows/kubernetes-update-check.yml‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
# Update k8s.io client libraries (convert e.g. v1.30.0 -> v0.30.0)
8888
CLIENT_VERSION=$(echo "v${KUBE_VERSION}" | sed 's/^v1\./v0./')
8989
echo "client_version=$CLIENT_VERSION" >> "$GITHUB_OUTPUT"
90+
# Record the version we are upgrading from, so the next step can diff group/versions against it.
91+
OLD_CLIENT_VERSION=$(grep -E "^\s+k8s.io/api v" provider/go.mod | head -1 | awk '{print $2}')
92+
echo "old_client_version=$OLD_CLIENT_VERSION" >> "$GITHUB_OUTPUT"
9093
cd provider
9194
K8S_DEPS=$(cat go.mod | grep "^\sk8s.io" | grep -v "// indirect" | awk '{print $1}')
9295
for dep in $K8S_DEPS; do
@@ -130,6 +133,28 @@ jobs:
130133
git commit -m "Update Kubernetes to v${KUBE_VERSION}"
131134
git push origin update-kubernetes/${{ github.run_id }}-${{ github.run_number }}
132135
136+
# A group/version Kubernetes deletes is gone from k8s.io/api, so nothing downstream can
137+
# discover it. Diffing the old and new module is the only place it is still visible.
138+
- name: Detect removed API group/versions
139+
id: removed-apis
140+
if: steps.get-kubernetes-version.outputs.needs_update != 0
141+
run: |
142+
OLD="${{ steps.update-files.outputs.old_client_version }}"
143+
NEW="${{ steps.update-files.outputs.client_version }}"
144+
for version in "$OLD" "$NEW"; do
145+
go mod download "k8s.io/api@${version}"
146+
find "$(go env GOMODCACHE)/k8s.io/api@${version}" -maxdepth 3 -name types.go | sed "s|.*/k8s.io/api@${version}/||; s|/types.go||" | sort > "$RUNNER_TEMP/gv-${version}.txt"
147+
done
148+
comm -23 "$RUNNER_TEMP/gv-${OLD}.txt" "$RUNNER_TEMP/gv-${NEW}.txt" > "$RUNNER_TEMP/removed-group-versions.txt"
149+
if [ -s "$RUNNER_TEMP/removed-group-versions.txt" ]; then
150+
echo "found=1" >> "$GITHUB_OUTPUT"
151+
echo "Removed group/versions:"
152+
cat "$RUNNER_TEMP/removed-group-versions.txt"
153+
else
154+
echo "found=0" >> "$GITHUB_OUTPUT"
155+
echo "No group/versions removed in this release."
156+
fi
157+
133158
- name: Create PR
134159
id: create-pr
135160
if: steps.get-kubernetes-version.outputs.needs_update != 0
@@ -144,7 +169,19 @@ jobs:
144169
- Built provider and SDKs with \`make k8sprovider build\`
145170
146171
Closes #${{ steps.create-issue.outputs.issue_number }}."
147-
172+
if [ "${{ steps.removed-apis.outputs.found }}" = "1" ]; then
173+
body="${body}
174+
175+
## Removed API group/versions
176+
177+
These are gone from k8s.io/api v${version} and need hand edits before this merges:
178+
179+
\`\`\`
180+
$(cat "$RUNNER_TEMP/removed-group-versions.txt")
181+
\`\`\`
182+
183+
For each one, add \`addManualEntry\` lines to \`provider/pkg/kinds/deprecated.go\` above the block that indexes truncated group names, and append the last Kubernetes minor that served it to the legacy spec list in \`provider/cmd/pulumi-gen-kubernetes/main.go\`."
184+
fi
148185
gh pr create -t "$title" -b "$body"
149186
env:
150187
GITHUB_TOKEN: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}

‎provider/pkg/kinds/deprecated.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ func init() {
165165
1, 10, 1, 17, &schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1", Kind: "PriorityClass"})
166166
addManualEntry("scheduling.k8s.io", "v1alpha1", "PriorityClassList",
167167
1, 10, 1, 17, &schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1", Kind: "PriorityClassList"})
168+
addManualEntry("scheduling.k8s.io", "v1alpha1", "Workload",
169+
1, 35, 1, 36, &schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1beta1", Kind: "Workload"})
170+
addManualEntry("scheduling.k8s.io", "v1alpha1", "WorkloadList",
171+
1, 35, 1, 36, &schema.GroupVersionKind{Group: "scheduling.k8s.io", Version: "v1beta1", Kind: "WorkloadList"})
168172

169173
// scheduling.k8s.io/v1alpha2 (no lifecycle files in k8s.io/api)
170174
addManualEntry("scheduling.k8s.io", "v1alpha2", "Workload",

0 commit comments

Comments
 (0)