Skip to content

Commit 945631f

Browse files
authored
Merge release v0.1.9
Release v0.1.9
2 parents f8a4e36 + e3cb600 commit 945631f

File tree

5 files changed

+276
-7
lines changed

5 files changed

+276
-7
lines changed

.github/workflows/main.yml

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
DO_TEST: true
1111

1212
jobs:
13-
build:
13+
production:
1414
runs-on: ubuntu-latest
1515

1616
steps:
@@ -61,7 +61,7 @@ jobs:
6161
# For PR event or merge event, tag example: 1.0.1.12-5667
6262
type=raw,value=${{ env.VERSION_TAG }}
6363
# For PR event or merge, tag example: 566769e04d2436cf5f42ae4f46092c7dff6e668e
64-
type=raw,value=${{ env.SHA_TAG }}
64+
type=raw,value=${{ env.SHA_TAG }}
6565
# For push to semver tag, tag example: 1.0.2
6666
# This also sets 'latest'.
6767
type=semver,pattern={{version}}
@@ -95,10 +95,99 @@ jobs:
9595
uses: docker/build-push-action@v3
9696
with:
9797
push: true
98+
target: production
99+
tags: ${{ steps.meta.outputs.tags }}
100+
101+
debug:
102+
runs-on: ubuntu-latest
103+
104+
steps:
105+
- name: "Build context"
106+
run: |
107+
echo "ref is ${{ github.ref }}"
108+
echo "ref_type is ${{ github.ref_type }}"
109+
110+
- name: "Checkout repository"
111+
id: checkout_repo
112+
uses: actions/checkout@v3
113+
with:
114+
fetch-depth: 0
115+
ref: ${{ github.event.pull_request.head.sha }}
116+
117+
- name: "Lowercase repository name for docker build"
118+
id: lowercase-repository-name
119+
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
120+
121+
- name: "Set tags for main/master"
122+
id: set_tags
123+
run: |
124+
echo "VERSION_TAG=$(./git-version-gen | grep -v UNKNOWN)" >> ${GITHUB_ENV}
125+
echo "TEST_TAG=$(git rev-parse HEAD)-test" >> ${GITHUB_ENV}
126+
echo "SHA_TAG=$(git rev-parse HEAD)" >> ${GITHUB_ENV}
127+
echo "${GITHUB_ENV}:"
128+
cat ${GITHUB_ENV}
129+
shell: bash
130+
131+
- name: "Verify auto-generated files"
132+
run: |
133+
make manifests generate
134+
if [[ $(git status -s | wc -l) -gt 0 ]]; then \
135+
git status; exit 1; \
136+
fi
137+
138+
- name: "Docker metadata"
139+
id: meta
140+
uses: docker/metadata-action@v4
141+
with:
142+
images: |
143+
ghcr.io/${{ env.REPO_NAME }}-debug
144+
tags: |
145+
# For merge to master branch, tag example: 'master'
146+
type=ref,event=branch
147+
# For PR event, tag example: 'pr-3'
148+
type=ref,event=pr
149+
# For PR event or merge event, tag example: 1.0.1.12-5667
150+
type=raw,value=${{ env.VERSION_TAG }}
151+
# For PR event or merge, tag example: 566769e04d2436cf5f42ae4f46092c7dff6e668e
152+
type=raw,value=${{ env.SHA_TAG }}
153+
# For push to semver tag, tag example: 1.0.2
154+
# This also sets 'latest'.
155+
type=semver,pattern={{version}}
156+
# For push to semver tag, tag example: 1.0
157+
type=semver,pattern={{major}}.{{minor}}
158+
159+
- name: "Docker login"
160+
id: docker_login
161+
uses: docker/login-action@v1
162+
with:
163+
registry: ghcr.io
164+
username: ${{ github.actor }}
165+
password: ${{ secrets.GITHUB_TOKEN }}
166+
167+
- name: "Build the test Docker image"
168+
id: docker_build_test_target
169+
if: ${{ env.DO_TEST == 'true' }}
170+
uses: docker/build-push-action@v2
171+
with:
172+
push: false
173+
target: ${{ env.TEST_TARGET }}
174+
tags: ${{ env.REPO_NAME }}:${{ env.TEST_TAG }}
175+
176+
- name: "Run the Docker image unit tests"
177+
id: docker_test
178+
if: ${{ env.DO_TEST == 'true' }}
179+
run: docker run ${{ env.REPO_NAME }}:${{ env.TEST_TAG }}
180+
181+
- name: "Build the debug Docker image"
182+
id: docker_build
183+
uses: docker/build-push-action@v3
184+
with:
185+
push: true
186+
target: debug
98187
tags: ${{ steps.meta.outputs.tags }}
99188

100189
create_release:
101-
needs: build
190+
needs: production
102191
if: startsWith(github.ref, 'refs/tags/v')
103192
runs-on: ubuntu-latest
104193
steps:

Dockerfile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ENV CGO_ENABLED=0
6363
ENTRYPOINT [ "make", "test" ]
6464

6565
###############################################################################
66-
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION
66+
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION AS production
6767

6868
# The following lines are from the mpiFileUtils (nnf-mfu) Dockerfile;
6969
# do not change them unless you know what it is you are doing
@@ -82,3 +82,23 @@ ARG NNFMFU_TAG_BASE
8282
ARG NNFMFU_VERSION
8383
LABEL nnf-mfu="$NNFMFU_TAG_BASE:$NNFMFU_VERSION"
8484

85+
###############################################################################
86+
# Use the nnf-mfu-debug image as a base
87+
FROM $NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION AS debug
88+
89+
# The following lines are from the mpiFileUtils (nnf-mfu) Dockerfile;
90+
# do not change them unless you know what it is you are doing
91+
RUN sed -i "s/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g" /etc/ssh/ssh_config \
92+
&& echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config
93+
94+
# Copy the executable and execute
95+
WORKDIR /
96+
COPY --from=builder /workspace/manager .
97+
98+
ENTRYPOINT ["/manager"]
99+
100+
# Make it easy to figure out which nnf-mfu was used.
101+
# docker inspect --format='{{json .Config.Labels}}' image:tag
102+
ARG NNFMFU_TAG_BASE
103+
ARG NNFMFU_VERSION
104+
LABEL nnf-mfu="$NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION"

Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
4747
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
4848
# cray.hpe.com/nnf-dm-bundle:$VERSION and cray.hpe.com/nnf-dm-catalog:$VERSION.
4949
IMAGE_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-dm
50+
IMAGE_TARGET ?= production
5051

5152
# The NNF-MFU container image to use in NNFContainerProfile resources.
5253
NNFMFU_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-mfu
@@ -163,13 +164,22 @@ run: manifests generate fmt vet ## Run a controller from your host.
163164
.PHONY: docker-build
164165
docker-build: VERSION ?= $(shell cat .version)
165166
docker-build: .version ## Build docker image with the manager.
166-
${CONTAINER_TOOL} build -t $(IMAGE_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .
167+
${CONTAINER_TOOL} build --target $(IMAGE_TARGET) -t $(IMAGE_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .
168+
169+
.PHONY: docker-build-debug
170+
docker-build-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
171+
docker-build-debug: IMAGE_TARGET := debug
172+
docker-build-debug: docker-build
167173

168174
.PHONY: docker-push
169175
docker-push: VERSION ?= $(shell cat .version)
170176
docker-push: .version ## Push docker image with the manager.
171177
${CONTAINER_TOOL} push $(IMAGE_TAG_BASE):$(VERSION)
172178

179+
.PHONY: docker-push-debug
180+
docker-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
181+
docker-push-debug: docker-push
182+
173183
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
174184
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
175185
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
@@ -184,10 +194,15 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
184194
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
185195
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
186196
$(CONTAINER_TOOL) buildx use project-v3-builder
187-
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag $(IMAGE_TAG_BASE):$(VERSION) -f Dockerfile.cross .
197+
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --target $(IMAGE_TARGET) --tag $(IMAGE_TAG_BASE):$(VERSION) -f Dockerfile.cross .
188198
- $(CONTAINER_TOOL) buildx rm project-v3-builder
189199
rm Dockerfile.cross
190200

201+
.PHONY: docker-buildx-debug
202+
docker-buildx-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
203+
docker-buildx-debug: IMAGE_TARGET := debug
204+
docker-buildx-debug: docker-buildx
205+
191206
kind-push: VERSION ?= $(shell cat .version)
192207
kind-push: .version ## Push docker image to kind
193208
# Nnf-dm is used on all nodes. It's on the management node for the
@@ -197,6 +212,10 @@ kind-push: .version ## Push docker image to kind
197212
${CONTAINER_TOOL} pull gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
198213
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
199214

215+
kind-push-debug: VERSION ?= $(shell cat .version)
216+
kind-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
217+
kind-push-debug: kind-push
218+
200219
minikube-push: VERSION ?= $(shell cat .version)
201220
minikube-push: .version
202221
minikube image load $(IMAGE_TAG_BASE):$(VERSION)

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ kind: Kustomization
1717
images:
1818
- name: controller
1919
newName: ghcr.io/nearnodeflash/nnf-dm
20-
newTag: 0.1.8
20+
newTag: 0.1.9
2121
- name: nnf-mfu
2222
newName: ghcr.io/nearnodeflash/nnf-mfu
2323
newTag: 0.1.2

create-dms.sh

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/bin/bash
2+
3+
# This script is used to create NnfDataMovement resources via kubectl apply. This mimics the Copy
4+
# Offload API and is useful for testing. It assumes that a workflow is in the PreRun state. You can
5+
# create a large number of resources simulteanously and each request is sequentially numbered. This
6+
# is a script used for development.
7+
8+
# User must exist on the compute node
9+
USER=
10+
COMPUTE=rabbit-compute-5
11+
12+
WORKFLOW=
13+
PROFILE=default
14+
15+
# Options
16+
CREATE=""
17+
DELETE_ALL=""
18+
DELETE_SUCCESS=""
19+
GET_FAILED=""
20+
NUM_REQUESTS=1
21+
WAIT=""
22+
23+
OPTSTRING="CDdgn:p:w"
24+
while getopts "${OPTSTRING}" opt; do
25+
case ${opt} in
26+
27+
C)
28+
CREATE="true"
29+
;;
30+
D)
31+
DELETE_ALL="true"
32+
;;
33+
d)
34+
DELETE_SUCCESS="true"
35+
;;
36+
g)
37+
GET_FAILED="true"
38+
;;
39+
n)
40+
NUM_REQUESTS=${OPTARG}
41+
;;
42+
p)
43+
PROFILE=${OPTARG}
44+
;;
45+
w)
46+
WAIT="true"
47+
;;
48+
*)
49+
echo "invalid option"
50+
exit 1
51+
;;
52+
esac
53+
done
54+
55+
shift $((OPTIND - 1))
56+
57+
if [[ "$#" -ne 2 ]]; then
58+
echo "Usage: $0 [--options] <user> <workflow>"
59+
exit 1
60+
fi
61+
62+
# Assign positional arguments to variables
63+
USER=$1
64+
WORKFLOW=$2
65+
66+
# testfile needs to present in this directory - create this manually (with the right perms too)
67+
# might need to have i number of testfiles
68+
# source=3d32f595-3bbd-4cef-a17c-e10c123c02bc-0
69+
wf_yaml=$(kubectl get workflow "${WORKFLOW}" -oyaml)
70+
source=$(echo "${wf_yaml}" -oyaml | yq '.metadata.uid')-0
71+
testfile=/mnt/nnf/${source}/testfile
72+
73+
if [[ -n "${CREATE}" ]]; then
74+
# create a file to move
75+
echo -n "Creating ${testfile} on ${COMPUTE}..."
76+
set -e
77+
ssh ${COMPUTE} "fallocate -x -l 100M ${testfile}"
78+
ssh ${COMPUTE} "chown ${USER}:users ${testfile}"
79+
set +e
80+
echo "done"
81+
82+
# creat requests
83+
echo -n "Creating ${NUM_REQUESTS} requests..."
84+
for ((i = 1; i <= NUM_REQUESTS; i++)); do
85+
echo "
86+
apiVersion: nnf.cray.hpe.com/v1alpha2
87+
kind: NnfDataMovement
88+
metadata:
89+
name: ${WORKFLOW}-${i}
90+
namespace: nnf-dm-system
91+
spec:
92+
cancel: false
93+
destination:
94+
path: /lus/global/${USER}/testdir
95+
storageReference:
96+
kind: LustreFileSystem
97+
name: lushtx
98+
namespace: default
99+
groupId: 100
100+
profileReference:
101+
kind: NnfDataMovementProfile
102+
name: ${PROFILE}
103+
namespace: nnf-system
104+
source:
105+
path: /mnt/nnf/${source}/testfile
106+
storageReference:
107+
kind: NnfStorage
108+
name: ${WORKFLOW}-0
109+
namespace: default
110+
userId: 1060
111+
" | kubectl apply -f - &
112+
done
113+
echo "done"
114+
115+
# wait for all of them to complete data movement
116+
if [[ -n "${WAIT}" ]]; then
117+
echo -n "Waiting for completion of all data movement resources..."
118+
while :; do
119+
num_done=$(kubectl get nnfdatamovements -A --no-headers | grep -c Success || true)
120+
if [[ "${num_done}" -eq "${NUM_REQUESTS}" ]]; then
121+
break
122+
fi
123+
done
124+
echo "done"
125+
fi
126+
127+
fi
128+
129+
if [[ -n "${DELETE_ALL}" ]]; then
130+
echo -n "Deleting all nnfdatamovements..."
131+
kubectl get nnfdatamovements -n nnf-dm-system --no-headers | awk '{print $1}' | xargs -n 1 -P 0 kubectl delete -n nnf-dm-system nnfdatamovement || true
132+
echo "done"
133+
elif [[ -n "${DELETE_SUCCESS}" ]]; then
134+
echo -n "Deleting Successful nnfdatamovements..."
135+
kubectl get nnfdatamovements -n nnf-dm-system --no-headers | grep Success | awk '{print $1}' | xargs -n 1 -P 0 kubectl delete -n nnf-dm-system nnfdatamovement || true
136+
echo "done"
137+
fi
138+
139+
if [[ -n "${GET_FAILED}" ]]; then
140+
kubectl get nnfdatamovements -A -oyaml | yq '.items[].status' || true
141+
fi

0 commit comments

Comments
 (0)