Skip to content

Commit

Permalink
Merge release v0.1.9
Browse files Browse the repository at this point in the history
Release v0.1.9
  • Loading branch information
roehrich-hpe authored Sep 16, 2024
2 parents f8a4e36 + e3cb600 commit 945631f
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 7 deletions.
95 changes: 92 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
DO_TEST: true

jobs:
build:
production:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
# For PR event or merge event, tag example: 1.0.1.12-5667
type=raw,value=${{ env.VERSION_TAG }}
# For PR event or merge, tag example: 566769e04d2436cf5f42ae4f46092c7dff6e668e
type=raw,value=${{ env.SHA_TAG }}
type=raw,value=${{ env.SHA_TAG }}
# For push to semver tag, tag example: 1.0.2
# This also sets 'latest'.
type=semver,pattern={{version}}
Expand Down Expand Up @@ -95,10 +95,99 @@ jobs:
uses: docker/build-push-action@v3
with:
push: true
target: production
tags: ${{ steps.meta.outputs.tags }}

debug:
runs-on: ubuntu-latest

steps:
- name: "Build context"
run: |
echo "ref is ${{ github.ref }}"
echo "ref_type is ${{ github.ref_type }}"
- name: "Checkout repository"
id: checkout_repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: "Lowercase repository name for docker build"
id: lowercase-repository-name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: "Set tags for main/master"
id: set_tags
run: |
echo "VERSION_TAG=$(./git-version-gen | grep -v UNKNOWN)" >> ${GITHUB_ENV}
echo "TEST_TAG=$(git rev-parse HEAD)-test" >> ${GITHUB_ENV}
echo "SHA_TAG=$(git rev-parse HEAD)" >> ${GITHUB_ENV}
echo "${GITHUB_ENV}:"
cat ${GITHUB_ENV}
shell: bash

- name: "Verify auto-generated files"
run: |
make manifests generate
if [[ $(git status -s | wc -l) -gt 0 ]]; then \
git status; exit 1; \
fi
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.REPO_NAME }}-debug
tags: |
# For merge to master branch, tag example: 'master'
type=ref,event=branch
# For PR event, tag example: 'pr-3'
type=ref,event=pr
# For PR event or merge event, tag example: 1.0.1.12-5667
type=raw,value=${{ env.VERSION_TAG }}
# For PR event or merge, tag example: 566769e04d2436cf5f42ae4f46092c7dff6e668e
type=raw,value=${{ env.SHA_TAG }}
# For push to semver tag, tag example: 1.0.2
# This also sets 'latest'.
type=semver,pattern={{version}}
# For push to semver tag, tag example: 1.0
type=semver,pattern={{major}}.{{minor}}
- name: "Docker login"
id: docker_login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Build the test Docker image"
id: docker_build_test_target
if: ${{ env.DO_TEST == 'true' }}
uses: docker/build-push-action@v2
with:
push: false
target: ${{ env.TEST_TARGET }}
tags: ${{ env.REPO_NAME }}:${{ env.TEST_TAG }}

- name: "Run the Docker image unit tests"
id: docker_test
if: ${{ env.DO_TEST == 'true' }}
run: docker run ${{ env.REPO_NAME }}:${{ env.TEST_TAG }}

- name: "Build the debug Docker image"
id: docker_build
uses: docker/build-push-action@v3
with:
push: true
target: debug
tags: ${{ steps.meta.outputs.tags }}

create_release:
needs: build
needs: production
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
Expand Down
22 changes: 21 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ENV CGO_ENABLED=0
ENTRYPOINT [ "make", "test" ]

###############################################################################
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION AS production

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

###############################################################################
# Use the nnf-mfu-debug image as a base
FROM $NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION AS debug

# The following lines are from the mpiFileUtils (nnf-mfu) Dockerfile;
# do not change them unless you know what it is you are doing
RUN sed -i "s/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g" /etc/ssh/ssh_config \
&& echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config

# Copy the executable and execute
WORKDIR /
COPY --from=builder /workspace/manager .

ENTRYPOINT ["/manager"]

# Make it easy to figure out which nnf-mfu was used.
# docker inspect --format='{{json .Config.Labels}}' image:tag
ARG NNFMFU_TAG_BASE
ARG NNFMFU_VERSION
LABEL nnf-mfu="$NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION"
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# cray.hpe.com/nnf-dm-bundle:$VERSION and cray.hpe.com/nnf-dm-catalog:$VERSION.
IMAGE_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-dm
IMAGE_TARGET ?= production

# The NNF-MFU container image to use in NNFContainerProfile resources.
NNFMFU_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-mfu
Expand Down Expand Up @@ -163,13 +164,22 @@ run: manifests generate fmt vet ## Run a controller from your host.
.PHONY: docker-build
docker-build: VERSION ?= $(shell cat .version)
docker-build: .version ## Build docker image with the manager.
${CONTAINER_TOOL} build -t $(IMAGE_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .
${CONTAINER_TOOL} build --target $(IMAGE_TARGET) -t $(IMAGE_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .

.PHONY: docker-build-debug
docker-build-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
docker-build-debug: IMAGE_TARGET := debug
docker-build-debug: docker-build

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

.PHONY: docker-push-debug
docker-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
docker-push-debug: docker-push

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

.PHONY: docker-buildx-debug
docker-buildx-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
docker-buildx-debug: IMAGE_TARGET := debug
docker-buildx-debug: docker-buildx

kind-push: VERSION ?= $(shell cat .version)
kind-push: .version ## Push docker image to kind
# Nnf-dm is used on all nodes. It's on the management node for the
Expand All @@ -197,6 +212,10 @@ kind-push: .version ## Push docker image to kind
${CONTAINER_TOOL} pull gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0

kind-push-debug: VERSION ?= $(shell cat .version)
kind-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
kind-push-debug: kind-push

minikube-push: VERSION ?= $(shell cat .version)
minikube-push: .version
minikube image load $(IMAGE_TAG_BASE):$(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kind: Kustomization
images:
- name: controller
newName: ghcr.io/nearnodeflash/nnf-dm
newTag: 0.1.8
newTag: 0.1.9
- name: nnf-mfu
newName: ghcr.io/nearnodeflash/nnf-mfu
newTag: 0.1.2
141 changes: 141 additions & 0 deletions create-dms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/bin/bash

# This script is used to create NnfDataMovement resources via kubectl apply. This mimics the Copy
# Offload API and is useful for testing. It assumes that a workflow is in the PreRun state. You can
# create a large number of resources simulteanously and each request is sequentially numbered. This
# is a script used for development.

# User must exist on the compute node
USER=
COMPUTE=rabbit-compute-5

WORKFLOW=
PROFILE=default

# Options
CREATE=""
DELETE_ALL=""
DELETE_SUCCESS=""
GET_FAILED=""
NUM_REQUESTS=1
WAIT=""

OPTSTRING="CDdgn:p:w"
while getopts "${OPTSTRING}" opt; do
case ${opt} in

C)
CREATE="true"
;;
D)
DELETE_ALL="true"
;;
d)
DELETE_SUCCESS="true"
;;
g)
GET_FAILED="true"
;;
n)
NUM_REQUESTS=${OPTARG}
;;
p)
PROFILE=${OPTARG}
;;
w)
WAIT="true"
;;
*)
echo "invalid option"
exit 1
;;
esac
done

shift $((OPTIND - 1))

if [[ "$#" -ne 2 ]]; then
echo "Usage: $0 [--options] <user> <workflow>"
exit 1
fi

# Assign positional arguments to variables
USER=$1
WORKFLOW=$2

# testfile needs to present in this directory - create this manually (with the right perms too)
# might need to have i number of testfiles
# source=3d32f595-3bbd-4cef-a17c-e10c123c02bc-0
wf_yaml=$(kubectl get workflow "${WORKFLOW}" -oyaml)
source=$(echo "${wf_yaml}" -oyaml | yq '.metadata.uid')-0
testfile=/mnt/nnf/${source}/testfile

if [[ -n "${CREATE}" ]]; then
# create a file to move
echo -n "Creating ${testfile} on ${COMPUTE}..."
set -e
ssh ${COMPUTE} "fallocate -x -l 100M ${testfile}"
ssh ${COMPUTE} "chown ${USER}:users ${testfile}"
set +e
echo "done"

# creat requests
echo -n "Creating ${NUM_REQUESTS} requests..."
for ((i = 1; i <= NUM_REQUESTS; i++)); do
echo "
apiVersion: nnf.cray.hpe.com/v1alpha2
kind: NnfDataMovement
metadata:
name: ${WORKFLOW}-${i}
namespace: nnf-dm-system
spec:
cancel: false
destination:
path: /lus/global/${USER}/testdir
storageReference:
kind: LustreFileSystem
name: lushtx
namespace: default
groupId: 100
profileReference:
kind: NnfDataMovementProfile
name: ${PROFILE}
namespace: nnf-system
source:
path: /mnt/nnf/${source}/testfile
storageReference:
kind: NnfStorage
name: ${WORKFLOW}-0
namespace: default
userId: 1060
" | kubectl apply -f - &
done
echo "done"

# wait for all of them to complete data movement
if [[ -n "${WAIT}" ]]; then
echo -n "Waiting for completion of all data movement resources..."
while :; do
num_done=$(kubectl get nnfdatamovements -A --no-headers | grep -c Success || true)
if [[ "${num_done}" -eq "${NUM_REQUESTS}" ]]; then
break
fi
done
echo "done"
fi

fi

if [[ -n "${DELETE_ALL}" ]]; then
echo -n "Deleting all nnfdatamovements..."
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
echo "done"
elif [[ -n "${DELETE_SUCCESS}" ]]; then
echo -n "Deleting Successful nnfdatamovements..."
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
echo "done"
fi

if [[ -n "${GET_FAILED}" ]]; then
kubectl get nnfdatamovements -A -oyaml | yq '.items[].status' || true
fi

0 comments on commit 945631f

Please sign in to comment.