Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
visheshtanksale committed Jun 25, 2024
2 parents 82c22b6 + 6cf4f2b commit 8f10948
Show file tree
Hide file tree
Showing 20 changed files with 667 additions and 106 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Run this workflow on new tags
name: Publish Helm Chart

on:
release:
types:
- published

jobs:
update-helm-charts:
name: Update gh-pages branch helm charts and index
runs-on: ubuntu-latest
env:
HELM_REPO_PATH: releases/helm-${{ github.event.release.tag_name }}/
steps:
- name: Install Helm
uses: azure/setup-helm@v4.2.0
with:
version: 3.14.4

- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update helm index
env:
VERSION: ${{ github.event.release.tag_name }}
DOWNLOAD_URL: ${{ join(github.event.release.assets.*.browser_download_url, ' ') }}
run: |
git config user.name "Github Actions"
git config user.email "no-reply@github.com"
./hack/update-helm-index.sh --helm-repo-path $HELM_REPO_PATH $DOWNLOAD_URL
- name: Push updated Helm charts and index to gh-pages branch
run: |
git -C $HELM_REPO_PATH push https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
43 changes: 43 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Run this workflow on new tags
name: Release

on:
push:
tags:
- v*

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Check out code

- name: Install Helm
uses: azure/setup-helm@v4.2.0
with:
version: 3.14.4

- name: Generate Helm Charts
run: |
./hack/package-helm-charts.sh ${{ github.ref_name }}
- name: Create Draft Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./hack/create-release.sh ${{ github.ref_name }}
54 changes: 41 additions & 13 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,45 @@ The device plugin consists in two artifacts:
- The Device Plugin container
- The Device Plugin helm chart

Publishing the container is automated through gitlab-ci and only requires one to tag the commit and push it to gitlab.
Publishing the helm chart is currently manual, and we should move to an automated process ASAP
# Release Process Checklist:
- [ ] Create a release PR:
- [ ] Run the `./hack/prepare-release.sh` script to update the version in all the needed files. This also creates a [release issue](https://github.com/NVIDIA/cloud-native-team/issues?q=is%3Aissue+is%3Aopen+label%3Arelease)
- [ ] Run the `./hack/generate-changelog.sh` script to generate the a draft changelog and update `CHANGELOG.md` with the changes.
- [ ] Create a PR from the created `bump-release-{{ .VERSION }}` branch.
- [ ] Merge the release PR
- [ ] Tag the release and push the tag to the `internal` mirror:
- [ ] Image release pipeline:
- [ ] Wait for the image release to complete.
- [ ] Push the tag to the the upstream GitHub repo.
- [ ] Wait for the [`Release`](https://github.com/NVIDIA/k8s-device-plugin/actions/workflows/release.yaml) GitHub Action to complete
- [ ] Publish the [draft release](https://github.com/NVIDIA/k8s-device-plugin/releases) created by the GitHub Action
- [ ] Wait for the [`Publish Helm Chart`](https://github.com/NVIDIA/k8s-device-plugin/actions/workflows/helm.yaml) GitHub Action to complete

# Release Process Checklist
- [ ] Run the `./hack/prepare-release.sh` script to update the version in all the needed files
- [ ] Run the `./hack/package-helm-charts.sh` script to generate the helm charts
- [ ] Run the `./hack/generate-changelog.sh` script to generate the a draft changelog
- [ ] Update the CHANGELOG.md file with the generated changelog
- [ ] Commit, Tag and Push to Gitlab
- [ ] Switch to the `gh-pages` branch and move the newly generated package to the `stable` helm repo
- [ ] While on the `gh-pages` branch, run the `./build-index.sh` script to rebuild the indices for each repo
- [ ] Commit and push the `gh-pages` branch to GitHub
- [ ] Wait for the [CI job associated with your tag] (https://gitlab.com/nvidia/kubernetes/device-plugin/-/pipelines) to complete
- [ ] Create a [new release](https://github.com/NVIDIA/k8s-device-plugin/releases) on Github with the changelog
## Troubleshooting

*Note*: This assumes that we have the release tag checked out locally.

- If the `Release` GitHub Action fails:
- Check the logs for the error first.
- Create the helm packages locally by running:
```bash
./hack/package-helm-charts.sh {{ .VERSION }}
```
- Create the draft release by running:
```bash
./hack/create-release.sh {{ .VERSION }}
```
- If the `Publish Helm Chart` GitHub Action fails:
- Check the logs for the error.
- Download the release artifacts:

- Update the Helm package index on the `gh-pages` branch by running:
```
./hack/update-helm-index.sh --version {{ .VERSION }}
```
(this pulls the packages from the release created in the previous step)
- Push the change to the `gh-pages` branch:
```
git -C releases/{{ .VERSION }} remote set-url origin git@github.com:NVIDIA/k8s-device-plugin.git
git -C releases/{{ .VERSION }} push origin gh-pages
```
4 changes: 2 additions & 2 deletions cmd/gpu-feature-discovery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func main() {
Usage: "Use NFD NodeFeature API to publish labels",
EnvVars: []string{"GFD_USE_NODE_FEATURE_API", "USE_NODE_FEATURE_API"},
},
&cli.StringSliceFlag{
&cli.StringFlag{
Name: "device-discovery-strategy",
Value: cli.NewStringSlice("auto"),
Value: "auto",
Usage: "the strategy to use to discover devices: 'auto', 'nvml', 'tegra' or 'vfio'",
EnvVars: []string{"DEVICE_DISCOVERY_STRATEGY"},
},
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/NVIDIA/go-gpuallocator v0.5.0
github.com/NVIDIA/go-nvlib v0.6.0
github.com/NVIDIA/go-nvml v0.12.4-0
github.com/NVIDIA/nvidia-container-toolkit v1.15.1-0.20240528113255-e4b46a09a77e
github.com/NVIDIA/nvidia-container-toolkit v1.16.0-rc.1
github.com/fsnotify/fsnotify v1.7.0
github.com/google/uuid v1.6.0
github.com/mittwald/go-helm-client v0.12.9
Expand All @@ -23,7 +23,7 @@ require (
k8s.io/apiextensions-apiserver v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
k8s.io/klog/v2 v2.130.0
k8s.io/klog/v2 v2.130.1
k8s.io/kubelet v0.30.2
k8s.io/mount-utils v0.30.2
sigs.k8s.io/node-feature-discovery v0.15.4
Expand Down Expand Up @@ -134,7 +134,7 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ github.com/NVIDIA/go-nvlib v0.6.0 h1:zAMBzCYT9xeyRQo0tb7HJbStkzajD6e5joyaQqJ2OGU
github.com/NVIDIA/go-nvlib v0.6.0/go.mod h1:9UrsLGx/q1OrENygXjOuM5Ey5KCtiZhbvBlbUIxtGWY=
github.com/NVIDIA/go-nvml v0.12.4-0 h1:4tkbB3pT1O77JGr0gQ6uD8FrsUPqP1A/EOEm2wI1TUg=
github.com/NVIDIA/go-nvml v0.12.4-0/go.mod h1:8Llmj+1Rr+9VGGwZuRer5N/aCjxGuR5nPb/9ebBiIEQ=
github.com/NVIDIA/nvidia-container-toolkit v1.15.1-0.20240528113255-e4b46a09a77e h1:1xxK51xOXiqqziqMdgEMWVmjfvRu1b265LgQQZBqRaE=
github.com/NVIDIA/nvidia-container-toolkit v1.15.1-0.20240528113255-e4b46a09a77e/go.mod h1:Xzovqe8g9W8DiJe93gBD8FPjfduDpT+nfKIpc5s8IPE=
github.com/NVIDIA/nvidia-container-toolkit v1.16.0-rc.1 h1:aGXBx+qRasmCEpDOcvNrCtSd7vQr0tx9dwtMqLSpCYg=
github.com/NVIDIA/nvidia-container-toolkit v1.16.0-rc.1/go.mod h1:FwJJjw21CCIAomHp0Yv0zFO9sNLpBwK0YKNlOM3nADc=
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs=
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -366,8 +366,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down Expand Up @@ -516,8 +516,8 @@ k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50=
k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs=
k8s.io/component-base v0.30.2 h1:pqGBczYoW1sno8q9ObExUqrYSKhtE5rW3y6gX88GZII=
k8s.io/component-base v0.30.2/go.mod h1:yQLkQDrkK8J6NtP+MGJOws+/PPeEXNpwFixsUI7h/OE=
k8s.io/klog/v2 v2.130.0 h1:5nB3+3HpqKqXJIXNtJdtxcDCfaa9KL8StJgMzGJkUkM=
k8s.io/klog/v2 v2.130.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/kubectl v0.29.3 h1:RuwyyIU42MAISRIePaa8Q7A3U74Q9P4MoJbDFz9o3us=
Expand Down
44 changes: 44 additions & 0 deletions hack/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [ -z "$1" ]; then
VERSION=$(awk -F= '/^VERSION/ { print $2 }' versions.mk | tr -d '[:space:]')
else
VERSION=$1
fi

PRERELEASE_FLAG=""
if [[ ${VERSION} == v*-rc.* ]]; then
PRERELEASE_FLAG="--prerelease"
fi

REPOSITORY=NVIDIA/k8s-device-plugin

echo "Creating draft release"
./hack/generate-changelog.sh --version ${VERSION} --since ${REFERENCE} | \
grep -v "### Version v" | \
gh release create ${VERSION} --notes-file "-" \
--draft \
--title "${VERSION}" \
-R "${REPOSITORY}" \
--verify-tag \
--prerelease

HELM_PACKAGE_VERSION=${VERSION#v}
echo "Uploading release artifacts"

gh release upload ${VERSION} \
./nvidia-device-plugin-${HELM_PACKAGE_VERSION}.tgz \
./gpu-feature-discovery-${HELM_PACKAGE_VERSION}.tgz \
-R ${REPOSITORY}
19 changes: 9 additions & 10 deletions hack/generate-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ Usage: $this --reference <tag> [--remote <remote_name>]
Options:
--since specify the tag to start the changelog from (default: latest tag)
--remote specify the remote to fetch tags from (default: upstream)
--version specify the version to be released
--help/-h show this help and exit
EOF
}

REMOTE="upstream"
VERSION=""
REFERENCE=

Expand All @@ -44,11 +42,6 @@ while [[ $# -gt 0 ]]; do
shift # past argument
shift # past value
;;
--remote)
REMOTE="$2"
shift # past argument
shift # past value
;;
--version)
VERSION="$2"
shift # past argument
Expand All @@ -64,11 +57,17 @@ while [[ $# -gt 0 ]]; do
done

# Fetch the latest tags from the remote
git fetch $REMOTE --tags
remote=$( git remote -v | grep -E "NVIDIA/k8s-device-plugin(\.git)?\s" | grep -oE "^[a-z]+" | sort -u )
git fetch ${remote} --tags

# if REFERENCE is not set, get the latest tag
if [ -z "$REFERENCE" ]; then
REFERENCE=$(git describe --tags $(git rev-list --tags --max-count=1))
most_recent_tag=$(git tag --sort=-creatordate | head -1)
if [ "${VERSION}" == "${most_recent_tag}" ]; then
REFERENCE=$(git tag --sort=-creatordate | head -2 | tail -1)
else
REFERENCE=${most_recent_tag}
fi
fi

# Print the changelog
Expand All @@ -77,4 +76,4 @@ echo ""
echo "### Version $VERSION"

# Iterate over the commit messages and ignore the ones that start with "Merge" or "Bump"
git log --pretty=format:"%s" $REFERENCE..@ | grep -Ev "(^Merge )|(^Bump)" | sed 's/^\(.*\)/- \1/g'
git log --pretty=format:"%s" $REFERENCE..@ | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g'
12 changes: 10 additions & 2 deletions hack/package-helm-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

set -o pipefail

# if arg1 is set, it will be used as the version number
if [ -z "$1" ]; then
VERSION=$(awk -F= '/^VERSION/ { print $2 }' versions.mk | tr -d '[:space:]')
else
VERSION=$1
fi
VERSION=${VERSION#v}

# Create temporary directory for GFD Helm chart
rm -rf deployments/helm/gpu-feature-discovery
mkdir -p deployments/helm/gpu-feature-discovery
Expand All @@ -24,5 +32,5 @@ yq e -i '.devicePlugin.enabled = false | .gfd.enabled = true' deployments/helm/
yq e -i '.name = "gpu-feature-discovery" | .description = "A Helm chart for gpu-feature-discovery on Kubernetes"' deployments/helm/gpu-feature-discovery/Chart.yaml

# Create release assets to be uploaded
helm package deployments/helm/gpu-feature-discovery/
helm package deployments/helm/nvidia-device-plugin/
helm package deployments/helm/gpu-feature-discovery/ --version $VERSION --app-version $VERSION
helm package deployments/helm/nvidia-device-plugin/ --version $VERSION --app-version $VERSION
Loading

0 comments on commit 8f10948

Please sign in to comment.