From a4d66d7d9c3ea125f64819267e9ff4ce4118c6c5 Mon Sep 17 00:00:00 2001 From: Anthony Floeder Date: Thu, 16 Dec 2021 10:04:47 -0600 Subject: [PATCH] RABSW-637: DWS: Deploy to DP0 - Update to latest nnf-ec - Disable --mock in config/manager/manager.yaml to run on DP0 - add script to set $VERSION for a developer build setDevVersion.sh now locates the tag in artifactory that matches the current commit's SHA. --- .dws-operator | 2 +- .gitignore | 3 + Jenkinsfile | 8 ++- Makefile | 36 ++++++++++- config/crd/bases/crd.go | 2 +- config/dp0/kustomization.yaml | 6 ++ config/dp0/manager_volumes_patch.yaml | 52 +++++++++++++++ config/manager/kustomization.yaml | 2 +- config/samples/scripts/wfrLustre | 2 +- config/samples/scripts/wfrRaw | 24 +++---- go.mod | 4 +- go.sum | 4 ++ playground.sh | 40 +++++++++++- setDevVersion.sh | 37 +++++++++++ .../pkg/manager-fabric/switchtec_mock.go | 11 ++-- .../pkg/manager-nnf/file_share.go | 2 + .../pkg/manager-nnf/manager.go | 10 +-- .../hpc-rabsw-nnf-ec/pkg/manager-nvme/api.go | 19 ++++++ .../pkg/manager-nvme/manager.go | 64 +++++++++++-------- .../pkg/manager-nvme/servicer.go | 43 +++++++------ vendor/modules.txt | 4 +- 21 files changed, 287 insertions(+), 88 deletions(-) create mode 100644 config/dp0/kustomization.yaml create mode 100644 config/dp0/manager_volumes_patch.yaml create mode 100644 setDevVersion.sh diff --git a/.dws-operator b/.dws-operator index 2b73fb103..fcd578330 160000 --- a/.dws-operator +++ b/.dws-operator @@ -1 +1 @@ -Subproject commit 2b73fb1030f97b54f949ee258ff2938cb45f431b +Subproject commit fcd5783304c26002cec7e26059f0664ab7c165c1 diff --git a/.gitignore b/.gitignore index 3d79f5573..90d594bf1 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ commands.log kind-config.yaml standalone-playground nnf-sos + +# .vscode log files +.vscode/*.log \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index f443182a2..0196ed978 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,10 @@ -// Procedure for building NNF Element Controller +// Procedure for building NNF Storage Orchestration Services @Library('dst-shared@master') _ +// See https://github.hpe.com/hpe/hpc-dst-jenkins-shared-library for all +// the inputs to the dockerBuildPipeline. +// In particular: vars/dockerBuildPipeline.groovy dockerBuildPipeline { repository = "cray" imagePrefix = "cray" @@ -9,8 +12,7 @@ dockerBuildPipeline { name = "dp-nnf-sos" description = "Near Node Flash Storage Orchestration Services" dockerfile = "Dockerfile" - useLazyDocker = true autoJira = false createSDPManifest = false - product = "kj" + product = "rabsw" } diff --git a/Makefile b/Makefile index 917453390..fd0a89862 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # To re-generate a bundle for another specific version without changing the standard setup, you can: # - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) -VERSION=$(shell sed 1q .version) +VERSION ?= $(shell sed 1q .version) # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable") @@ -24,21 +24,47 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) endif BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) +# GIT_TAG is the SHA of the current commit +GIT_TAG=$(shell git rev-parse --short HEAD) + # IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. # This variable is used to construct full image tags for bundle and catalog images. # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both # cray.com/nnf-sos-bundle:$VERSION and cray.com/nnf-sos-catalog:$VERSION. -IMAGE_TAG_BASE ?= arti.dev.cray.com/kj-docker-master-local/cray-dp-nnf-sos +IMAGE_TAG_BASE ?= arti.dev.cray.com/rabsw-docker-master-local/cray-dp-nnf-sos # BUNDLE_IMG defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) # Image URL to use all building/pushing image targets -#IMG ?= controller:latest IMG ?= $(IMAGE_TAG_BASE):$(VERSION) +# Jenkins behaviors +# pipeline_service builds its target docker image and stores it into 1 of 3 destination folders. +# The behavior of where pipeline_service puts a build is dictated by name of the branch Jenkins +# is building. (See https://github.hpe.com/hpe/hpc-dst-jenkins-shared-library/vars/getArtiRepository.groovy) +# +# arti.dev.cray.com folder Contents +# --------------------------------------------- ----------------------------------------------------- +# arti.dev.cray.com/rabsw-docker-master-local master branch builds +# arti.dev.cray.com/rabsw-docker-stable-local release branch builds +# arti.dev.cray.com/rabsw-docker-unstable-local non-master && non-release branches, i.e. everything else +# +# pipeline_service tags the build with the following tag: +# +# VERSION = sh(returnStdout: true, script: "cat .version").trim() // .version file here +# def buildDate = new Date().format( 'yyyyMMddHHmmss' ) +# BUILD_DATE = "${buildDate}" +# GIT_TAG = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim() +# +# IMAGE_TAG = getDockerImageTag(version: "${VERSION}", buildDate: "${BUILD_DATE}", gitTag: "${GIT_TAG}", gitBranch: "${GIT_BRANCH}") +# +# Because of the build date stamp, this tag is a bit difficult to use. +# NOTE: master-local and stable-local have a 'latest' tag that can be used to fetch the latest of either +# the master or release branch. + # Produce CRDs that work back to Kubernetes 1.11 (no version conversion) CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false" @@ -46,6 +72,10 @@ CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false" # To use the 'craystack' overlay: # export KUBECONFIG=/my/craystack/kubeconfig.file # make deploy OVERLAY=craystack +# +# To use the 'dp0' overlay: +# export KUBECONFIG=/my/dp0/kubeconfig.file +# make deploy OVERLAY=dp0 OVERLAY ?= top # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) diff --git a/config/crd/bases/crd.go b/config/crd/bases/crd.go index af177221f..6cdebce42 100644 --- a/config/crd/bases/crd.go +++ b/config/crd/bases/crd.go @@ -1,3 +1,3 @@ package crd -// Empty file so other repositories can import the custom resource definitionss \ No newline at end of file +// Empty file so other repositories can import the custom resource definitions diff --git a/config/dp0/kustomization.yaml b/config/dp0/kustomization.yaml new file mode 100644 index 000000000..8ed0d7977 --- /dev/null +++ b/config/dp0/kustomization.yaml @@ -0,0 +1,6 @@ +bases: +- ../top + +patchesStrategicMerge: +# Let the node-manager daemonset mount host dirs for lustre tools and libs. +- manager_volumes_patch.yaml diff --git a/config/dp0/manager_volumes_patch.yaml b/config/dp0/manager_volumes_patch.yaml new file mode 100644 index 000000000..990e0f24d --- /dev/null +++ b/config/dp0/manager_volumes_patch.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: node-manager + namespace: system +spec: + template: + spec: + containers: + - name: manager + args: + - --controller=node + volumeMounts: + - mountPath: /mnt + name: mnt-dir + mountPropagation: Bidirectional + - mountPath: /dev + name: dev-dir + mountPropagation: HostToContainer + - mountPath: /var/run/dbus + name: dbus-dir + - mountPath: /run/udev + name: udev-dir + - mountPath: /usr/sbin + name: usbin-dir + - mountPath: /usr/lib64 + name: lib64-dir + - mountPath: /sys + name: sys-dir + mountPropagation: HostToContainer + volumes: + - name: mnt-dir + hostPath: + path: /mnt + - name: dev-dir + hostPath: + path: /dev + - name: dbus-dir + hostPath: + path: /var/run/dbus + - name: usbin-dir + hostPath: + path: /usr/sbin + - name: lib64-dir + hostPath: + path: /usr/lib64 + - name: sys-dir + hostPath: + path: /sys + - name: udev-dir + hostPath: + path: /run/udev diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 3ed7880c0..bba37f9ab 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -12,5 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: arti.dev.cray.com/kj-docker-master-local/cray-dp-nnf-sos + newName: arti.dev.cray.com/rabsw-docker-master-local/cray-dp-nnf-sos newTag: 0.0.1 diff --git a/config/samples/scripts/wfrLustre b/config/samples/scripts/wfrLustre index 89a17b93f..7b3638a30 100755 --- a/config/samples/scripts/wfrLustre +++ b/config/samples/scripts/wfrLustre @@ -25,7 +25,7 @@ data+=' "wlmID": "5f239bd8-30db-450b-8c2c-a1a7c8631a1a"' data+=' }' data+='}' -echo Attempting to create $rname ... +echo Attempting to create $rname on "$DWSHOST":"$DWSPORT" jsondata="$data" admitResponse=$(curl -s -X POST "http://${DWSHOST}:${DWSPORT}/apis/dws.cray.hpe.com/v1alpha1/namespaces/$NAMESPACE/workflows" -H "Content-Type: application/json" -d "$jsondata") diff --git a/config/samples/scripts/wfrRaw b/config/samples/scripts/wfrRaw index 522c38af9..b5988afe4 100755 --- a/config/samples/scripts/wfrRaw +++ b/config/samples/scripts/wfrRaw @@ -9,15 +9,15 @@ rname=$1 data='{' data+=' "metadata": {' -data+=' "name": "##RNAME##",' -data+=' "namespace": "##NAMESPACE##"' +data+=' "name": "'$rname'",' +data+=' "namespace": "'$NAMESPACE'"' data+=' },' data+=' "kind": "Workflow",' data+=' "apiVersion": "dws.cray.hpe.com/v1alpha1",' data+=' "spec": {' data+=' "desiredState": "proposal",' data+=' "dwDirectives": [' -data+=' "#DW jobdw type=raw capacity=10TB name=ajf"' +data+=' "#DW jobdw type=raw capacity=1GB name='$rname'"' data+=' ],' data+=' "jobID": 9000001,' data+=' "userID": 1001,' @@ -25,10 +25,10 @@ data+=' "wlmID": "5f239bd8-30db-450b-8c2c-a1a7c8631a1a"' data+=' }' data+='}' -echo Attempting to create $rname ... -jsondata=$(echo $data | sed -e s:##RNAME##:$rname:g -e s:##NAMESPACE##:"$NAMESPACE":g) +echo Attempting to create $rname on "$DWSHOST":"$DWSPORT" +jsondata="$data" -admitResponse=$(curl -X POST "http://${DWSHOST}:${DWSPORT}/apis/dws.cray.hpe.com/v1alpha1/namespaces/$NAMESPACE/workflows" -H "Content-Type: application/json" -d "$jsondata") +admitResponse=$(curl -s -X POST "http://${DWSHOST}:${DWSPORT}/apis/dws.cray.hpe.com/v1alpha1/namespaces/$NAMESPACE/workflows" -H "Content-Type: application/json" -d "$jsondata") retCode=$? # If the curl command failed, then we assume we failed to create the WFR... @@ -37,12 +37,6 @@ if [ $retCode -ne 0 ]; then exit $retCode fi -# curl command successful, look at the returned JSON to see if we were successful -echo "$admitResponse" | \ -jq 'if .kind == "Status" - then - "Failed to create: $admitResponse" - else - .metadata.name, . - end, .' -exit $retCode \ No newline at end of file +# Verify the resource was created. +kubectl get -n default workflow "$rname" +exit $? diff --git a/go.mod b/go.mod index 37e58d044..273a75dcd 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( github.com/go-logr/logr v0.4.0 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.17.0 - github.hpe.com/hpe/hpc-dpm-dws-operator v0.0.0-20211213160018-2b73fb1030f9 - github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211213185652-ece897e5fe46 + github.hpe.com/hpe/hpc-dpm-dws-operator v0.0.0-20220110213219-fcd5783304c2 + github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20220107171404-8b3a8cdbd9de k8s.io/api v0.22.2 k8s.io/apimachinery v0.22.2 k8s.io/client-go v0.22.2 diff --git a/go.sum b/go.sum index f80e82d94..34189ed0e 100644 --- a/go.sum +++ b/go.sum @@ -669,6 +669,10 @@ github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211213150822-62de995dac76 h1:8+gz github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211213150822-62de995dac76/go.mod h1:KTZsXDcX0VvrW79hC9eL3a3wTHfnnBD03X8IV/5+k0k= github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211213185652-ece897e5fe46 h1:FNiN76QwONYRtNhTsUQkuJdNJrM03P2T+K+lWcKlatE= github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211213185652-ece897e5fe46/go.mod h1:KTZsXDcX0VvrW79hC9eL3a3wTHfnnBD03X8IV/5+k0k= +github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211214153118-c080d8e8f741 h1:jIUZGJHK8/nbg/QfILKnQWDAKqt8fq8G75tiXZkaYsU= +github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211214153118-c080d8e8f741/go.mod h1:KTZsXDcX0VvrW79hC9eL3a3wTHfnnBD03X8IV/5+k0k= +github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20220107171404-8b3a8cdbd9de h1:ewkY6kL1sIjb0FXGCGIUFHCtiCYkyWG5Ey/QfBIIXnU= +github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20220107171404-8b3a8cdbd9de/go.mod h1:KTZsXDcX0VvrW79hC9eL3a3wTHfnnBD03X8IV/5+k0k= go.chromium.org/luci v0.0.0-20210915061045-7722a2154c29 h1:TgvWIQO0I0E7pKVLq/ARDhT2p2kHGKLtZhAN0EtUxiI= go.chromium.org/luci v0.0.0-20210915061045-7722a2154c29/go.mod h1:gk1qa1CBZAdya1PqugRJjkwk8LIymAoB5wf5UA7NrFk= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= diff --git a/playground.sh b/playground.sh index 168df0ead..8d2433dc1 100755 --- a/playground.sh +++ b/playground.sh @@ -47,7 +47,7 @@ EOF # Taint the kind workers as rabbit nodes for the NLCMs, to keep any # non-NLCM pods off of them. NODES=$(kubectl get nodes --no-headers -o custom-columns=:metadata.name | grep -v control-plane | paste -d" " -s -) - kubectl taint nodes $NODES cray.nnf.node=true:NoSchedule + kubectl taint nodes "$NODES" cray.nnf.node=true:NoSchedule # Label the kind-workers as rabbit nodes for the NLCMs. for NODE in $(kubectl get nodes --no-headers | grep --invert-match "control-plane" | awk '{print $1}'); do @@ -68,6 +68,42 @@ if [[ "$CMD" == kind-reset ]]; then ./playground.sh kind-create fi + +# The following commands apply to initializing the current DP0 environment +# Nodes containing 'cn' are considered to be worker nodes for the time being. +if [[ "$CMD" == dp0-init ]]; then + COMPUTE_NODES=$(kubectl get nodes --no-headers -o custom-columns=:metadata.name | grep cn | paste -d" " -s -) + RABBIT_NODES=$(kubectl get nodes --no-headers -o custom-columns=:metadata.name | grep -v cn | grep -v master | paste -d" " -s -) + MASTER_NODES=$(kubectl get nodes --no-headers -o custom-columns=:metadata.name | grep master | paste -d" " -s -) + + echo COMPUTE_NODES "$COMPUTE_NODES" + echo RABBIT_NODES "$RABBIT_NODES" + echo MASTER_NODES "$MASTER_NODES" + + # Label the COMPUTE_NODES to allow them to handle wlm and nnf-sos + # We are using COMPUTE_NODES as generic k8s workers + for NODE in $COMPUTE_NODES; do + # Label them for SLCMs. + kubectl label node "$NODE" cray.nnf.manager=true + kubectl label node "$NODE" cray.wlm.manager=true + done + + for NODE in $RABBIT_NODES; do + # Taint the rabbit nodes for the NLCMs, to keep any + # non-NLCM pods off of them. + kubectl taint node "$NODE" cray.nnf.node=true:NoSchedule + + # Label the rabbit nodes for the NLCMs. + kubectl label node "$NODE" cray.nnf.node=true + kubectl label node "$NODE" cray.nnf.x-name="$NODE" + done + + #Required for webhooks + # kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml + kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.yaml +fi + + if [[ "$CMD" == restart-pods ]]; then ./playground.sh pause all while : @@ -229,7 +265,7 @@ then mkdir $PLAY mkdir $DWSPLAY cp -r .dws-operator/config $DWSPLAY - cp .dws-operator/Makefile $DWSPLAY + cp .dws-operator/Makefile .dws-operator/.version $DWSPLAY cp -r config $PLAY cp .version Makefile playground.sh $PLAY fi diff --git a/setDevVersion.sh b/setDevVersion.sh new file mode 100644 index 000000000..fc843304f --- /dev/null +++ b/setDevVersion.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Use source to push the environment variables back into the calling shell +# "source ./setDevVersion.sh" + +# Command to access arti and list all of the docker images there filtering out the tag for the +# version matching the current git SHA +unset VERSION +unset IMAGE_TAG_BASE + +# Setup some artifactory paths to the developer and master branch locations +ARTI_URL_DEV=https://arti.dev.cray.com/artifactory/rabsw-docker-unstable-local/cray-dp-nnf-sos/ +ARTI_URL_MASTER=https://arti.dev.cray.com/artifactory/rabsw-docker-master-local/cray-dp-nnf-sos/ + +# Retrieve the name of the current branch. If we are in detached HEAD state, assume it is master. +CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) + +# Depending on whether we are on the master branch or not, setup for deployment from artifactory +# NOTE: Detached HEAD state is assumed to match 'master' +if [[ "$CURRENT_BRANCH_NAME" == "master" ]] || [[ "$CURRENT_BRANCH_NAME" == "HEAD" ]]; then + ARTI_URL="$ARTI_URL_MASTER" +else # not on the master branch + ARTI_URL="$ARTI_URL_DEV" + + # Deploying a developer build requires the IMAGE_TAG_BASE to change as well. + # Master branch is the default, so we don't change it when we are on the master branch. + IMAGE_TAG_BASE=arti.dev.cray.com/rabsw-docker-unstable-local/cray-dp-nnf-sos + export IMAGE_TAG_BASE + echo IMAGE_TAG_BASE: "$IMAGE_TAG_BASE" +fi + +# Locate the container tags in arti to set the VERSION environment variable +# which allows us to run `make deploy` and pull the correct version from ARTI. +LATEST_LOCAL_COMMIT=$(git rev-parse --short HEAD) +ARTI_TAG=$(wget --spider --recursive --no-parent -l1 "$ARTI_URL" 2>&1 | grep -- ^-- | awk '{print $3}' | grep "$LATEST_LOCAL_COMMIT" | tail -1) +VERSION=$(basename "$ARTI_TAG") +export VERSION +echo VERSION: "$VERSION" diff --git a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-fabric/switchtec_mock.go b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-fabric/switchtec_mock.go index ad908899c..e8617e881 100644 --- a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-fabric/switchtec_mock.go +++ b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-fabric/switchtec_mock.go @@ -185,6 +185,7 @@ func (d *MockSwitchtecDevice) GetSerialNumber() (string, error) { return "MockSerialNumber", nil } +var firstUpstreamPortDisabled bool // For test, record the first upstream port as being down. var firstDownstreamPortDisabled bool // For test, record the first downstream port as being down. func (d *MockSwitchtecDevice) GetPortStatus() ([]switchtec.PortLinkStat, error) { @@ -205,10 +206,12 @@ func (d *MockSwitchtecDevice) GetPortStatus() ([]switchtec.PortLinkStat, error) CurLinkRateGBps: switchtec.GetDataRateGBps(4) * float64(p.config.Width), } - // For test, record the first downstream port as being down. This replicates conditions for - // partially populated systems. - - if p.config.getPortType() == sf.DOWNSTREAM_PORT_PV130PT && firstDownstreamPortDisabled == false { + // For test, we take the first upstream port and downstream port and set them in a disabled state. + // This replicates conditions where a server or drive are not present + if p.config.getPortType() == sf.UPSTREAM_PORT_PV130PT && firstUpstreamPortDisabled == false { + firstUpstreamPortDisabled = true + stats[idx].LinkState = switchtec.PortLinkState_Disable + } else if p.config.getPortType() == sf.DOWNSTREAM_PORT_PV130PT && firstDownstreamPortDisabled == false { firstDownstreamPortDisabled = true stats[idx].LinkState = switchtec.PortLinkState_Disable } diff --git a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/file_share.go b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/file_share.go index 059170f80..8b72beacb 100644 --- a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/file_share.go +++ b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/file_share.go @@ -138,7 +138,9 @@ func (rh *fileShareRecoveryReplayHandler) Metadata(data []byte) error { fileSystem.shares = append(fileSystem.shares, FileShare{ id: rh.fileShareId, fileSystemId: metadata.FileSystemId, + mountRoot: *metadata.MountRoot, storageGroupId: *metadata.StorageGroupId, + storageService: rh.storageService, }) rh.fileSystem = fileSystem diff --git a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/manager.go b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/manager.go index f20ba0d3b..b6adc8821 100644 --- a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/manager.go +++ b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nnf/manager.go @@ -439,12 +439,12 @@ func (s *StorageService) EventHandler(e event.Event) error { endpoint := &s.endpoints[ep.Index()] - if linkEstablished { + endpoint.id = ep.Id() + endpoint.name = ep.Name() + endpoint.controllerId = ep.ControllerId() + endpoint.fabricId = fabric.FabricId - endpoint.id = ep.Id() - endpoint.name = ep.Name() - endpoint.controllerId = ep.ControllerId() - endpoint.fabricId = fabric.FabricId + if linkEstablished { opts := server.ServerControllerOptions{ Local: ep.Type() == sf.PROCESSOR_EV150ET, diff --git a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/api.go b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/api.go index c9d053cd5..d36f61305 100644 --- a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/api.go +++ b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/api.go @@ -15,6 +15,8 @@ package nvme import ( "net/http" + + sf "github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/rfsf/pkg/models" ) // Api - defines an interface for Near-Node Flash related methods @@ -37,3 +39,20 @@ type Api interface { RedfishV1StorageStorageIdVolumesVolumeIdGet(w http.ResponseWriter, r *http.Request) RedfishV1StorageStorageIdVolumesVolumeIdDelete(w http.ResponseWriter, r *http.Request) } + +type StorageApi interface { + Get(*sf.StorageCollectionStorageCollection) error + StorageIdGet(string, *sf.StorageV190Storage) error + + StorageIdStoragePoolsGet(string, *sf.StoragePoolCollectionStoragePoolCollection) error + StorageIdStoragePoolsStoragePoolIdGet(string, string, *sf.StoragePoolV150StoragePool) error + + StorageIdControllersGet(string, *sf.StorageControllerCollectionStorageControllerCollection) error + StorageIdControllersControllerIdGet(string, string, *sf.StorageControllerV100StorageController) error + + StorageIdVolumesGet(string, *sf.VolumeCollectionVolumeCollection) error + StorageIdVolumesPost(string, *sf.VolumeV161Volume) error + + StorageIdVolumeIdGet(string, string, *sf.VolumeV161Volume) error + StorageIdVolumeIdDelete(string, string) error +} diff --git a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/manager.go b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/manager.go index 5f4ba965e..c2d502a3b 100644 --- a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/manager.go +++ b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/manager.go @@ -31,6 +31,12 @@ const ( defaultStoragePoolId = "0" ) +var mgr = Manager{id: ResourceBlockId} + +func NewDefaultStorageService() StorageApi { + return &mgr +} + // Manager - type Manager struct { id string @@ -127,8 +133,6 @@ type Volume struct { // // /​redfish/​v1/​ResourceBlocks/{​ResourceBlockId}/​Systems/{​ComputerSystemId}/​Storage/​{StorageId}/​Controllers/​{ControllerId} -var mgr = Manager{id: ResourceBlockId} - func init() { RegisterNvmeInterface(&mgr) } @@ -228,7 +232,7 @@ func EnumerateStorage(storageHandlerFunc func(odataId string, capacityBytes uint return err } - storageHandlerFunc(s.fmt("/StoragePools"), s.capacityBytes, s.unallocatedBytes) + storageHandlerFunc(s.OdataId()+"/StoragePools", s.capacityBytes, s.unallocatedBytes) } return nil @@ -277,8 +281,12 @@ func (s *Storage) FindVolumeByNamespaceId(namespaceId nvme.NamespaceIdentifier) return nil, ec.NewErrNotFound() } -func (s *Storage) fmt(format string, a ...interface{}) string { - return fmt.Sprintf("/redfish/v1/Storage/%s", s.id) + fmt.Sprintf(format, a...) +func (s *Storage) OdataId() string { + return fmt.Sprintf("/redfish/v1/Storage/%s", s.id) +} + +func (s *Storage) OdataIdRef(ref string) sf.OdataV4IdRef { + return sf.OdataV4IdRef{OdataId: fmt.Sprintf("%s%s", s.OdataId(), ref)} } func (s *Storage) initialize() error { @@ -506,7 +514,7 @@ func (s *Storage) findVolume(volumeId string) *Volume { } func (v *Volume) Id() string { return v.id } -func (v *Volume) GetOdataId() string { return v.storage.fmt("/Volumes/%s", v.id) } +func (v *Volume) GetOdataId() string { return v.storage.OdataId() + "/Volumes/" + v.id } func (v *Volume) GetCapaityBytes() uint64 { return uint64(v.capacityBytes) } func (v *Volume) GetNamespaceId() nvme.NamespaceIdentifier { return v.namespaceId } @@ -853,17 +861,17 @@ func (s *Storage) LinkDroppedEventHandler() error { } // Get - -func Get(model *sf.StorageCollectionStorageCollection) error { +func (mgr *Manager) Get(model *sf.StorageCollectionStorageCollection) error { model.MembersodataCount = int64(len(mgr.storage)) model.Members = make([]sf.OdataV4IdRef, int(model.MembersodataCount)) for idx, s := range mgr.storage { - model.Members[idx].OdataId = s.fmt("") // fmt.Sprintf("/redfish/v1/Storage/%s", s.id) + model.Members[idx].OdataId = s.OdataId() } return nil } // StorageIdGet - -func StorageIdGet(storageId string, model *sf.StorageV190Storage) error { +func (mgr *Manager) StorageIdGet(storageId string, model *sf.StorageV190Storage) error { s := findStorage(storageId) if s == nil { return ec.NewErrNotFound() @@ -878,15 +886,15 @@ func StorageIdGet(storageId string, model *sf.StorageV190Storage) error { }, } - model.Controllers.OdataId = fmt.Sprintf("/redfish/v1/Storage/%s/Controllers", storageId) - model.StoragePools.OdataId = fmt.Sprintf("/redfish/v1/Storage/%s/StoragePools", storageId) - model.Volumes.OdataId = fmt.Sprintf("/redfish/v1/Storage/%s/Volumes", storageId) + model.Controllers = s.OdataIdRef("/Controllers") + model.StoragePools = s.OdataIdRef("/StoragePools") + model.Volumes = s.OdataIdRef("/Volumes") return nil } // StorageIdStoragePoolsGet - -func StorageIdStoragePoolsGet(storageId string, model *sf.StoragePoolCollectionStoragePoolCollection) error { +func (mgr *Manager) StorageIdStoragePoolsGet(storageId string, model *sf.StoragePoolCollectionStoragePoolCollection) error { s := findStorage(storageId) if s == nil { return ec.NewErrNotFound() @@ -894,13 +902,13 @@ func StorageIdStoragePoolsGet(storageId string, model *sf.StoragePoolCollectionS model.MembersodataCount = 1 model.Members = make([]sf.OdataV4IdRef, model.MembersodataCount) - model.Members[0].OdataId = fmt.Sprintf("/redfish/v1/Storage/%s/StoragePools/%s", storageId, defaultStoragePoolId) + model.Members[0] = s.OdataIdRef("/StoragePools/" + defaultStoragePoolId) return nil } -// StorageIdStoragePoolIdGet - -func StorageIdStoragePoolIdGet(storageId, storagePoolId string, model *sf.StoragePoolV150StoragePool) error { +// StorageIdStoragePoolsStoragePoolIdGet - +func (mgr *Manager) StorageIdStoragePoolsStoragePoolIdGet(storageId, storagePoolId string, model *sf.StoragePoolV150StoragePool) error { if storagePoolId != defaultStoragePoolId { return ec.NewErrNotFound().WithCause(fmt.Sprintf("storage pool %s not found", storagePoolId)) } @@ -930,7 +938,7 @@ func StorageIdStoragePoolIdGet(storageId, storagePoolId string, model *sf.Storag } // StorageIdControllersGet - -func StorageIdControllersGet(storageId string, model *sf.StorageControllerCollectionStorageControllerCollection) error { +func (mgr *Manager) StorageIdControllersGet(storageId string, model *sf.StorageControllerCollectionStorageControllerCollection) error { s := findStorage(storageId) if s == nil { return ec.NewErrNotFound() @@ -939,14 +947,14 @@ func StorageIdControllersGet(storageId string, model *sf.StorageControllerCollec model.MembersodataCount = int64(len(s.controllers)) model.Members = make([]sf.OdataV4IdRef, model.MembersodataCount) for idx, c := range s.controllers { - model.Members[idx].OdataId = fmt.Sprintf("/redfish/v1/Storage/%s/Controllers/%s", storageId, c.id) + model.Members[idx] = s.OdataIdRef("/Controllers/" + c.id) } return nil } -// StorageIdControllerIdGet - -func StorageIdControllerIdGet(storageId, controllerId string, model *sf.StorageControllerV100StorageController) error { +// StorageIdControllersControllerIdGet - +func (mgr *Manager) StorageIdControllersControllerIdGet(storageId, controllerId string, model *sf.StorageControllerV100StorageController) error { s, c := findStorageController(storageId, controllerId) if c == nil { return ec.NewErrNotFound().WithCause(fmt.Sprintf("Storage Controller not found: Storage: %s Controller: %s", storageId, controllerId)) @@ -995,7 +1003,7 @@ func StorageIdControllerIdGet(storageId, controllerId string, model *sf.StorageC } // StorageIdVolumesGet - -func StorageIdVolumesGet(storageId string, model *sf.VolumeCollectionVolumeCollection) error { +func (mgr *Manager) StorageIdVolumesGet(storageId string, model *sf.VolumeCollectionVolumeCollection) error { s := findStorage(storageId) if s == nil { return ec.NewErrNotFound() @@ -1006,14 +1014,14 @@ func StorageIdVolumesGet(storageId string, model *sf.VolumeCollectionVolumeColle model.MembersodataCount = int64(len(s.volumes)) model.Members = make([]sf.OdataV4IdRef, model.MembersodataCount) for idx, volume := range s.volumes { - model.Members[idx].OdataId = s.fmt("/Volumes/%s", volume.id) + model.Members[idx] = s.OdataIdRef("/Volumes/" + volume.id) } return nil } // StorageIdVolumeIdGet - -func StorageIdVolumeIdGet(storageId, volumeId string, model *sf.VolumeV161Volume) error { +func (mgr *Manager) StorageIdVolumeIdGet(storageId, volumeId string, model *sf.VolumeV161Volume) error { s, v := findStorageVolume(storageId, volumeId) if v == nil { return ec.NewErrNotFound() @@ -1063,6 +1071,8 @@ func StorageIdVolumeIdGet(storageId, volumeId string, model *sf.VolumeV161Volume model.VolumeType = sf.RAW_DEVICE_VVT + model.Links.OwningStorageResource.OdataId = s.OdataId() + // TODO: Find the attached status of the volume - if it is attached via a connection // to an endpoint that should go in model.Links.ClientEndpoints or model.Links.ServerEndpoints @@ -1074,8 +1084,8 @@ func StorageIdVolumeIdGet(storageId, volumeId string, model *sf.VolumeV161Volume return nil } -// StorageIdVolumePost - -func StorageIdVolumePost(storageId string, model *sf.VolumeV161Volume) error { +// StorageIdVolumesPost - +func (mgr *Manager) StorageIdVolumesPost(storageId string, model *sf.VolumeV161Volume) error { s := findStorage(storageId) if s == nil { return ec.NewErrNotFound() @@ -1088,11 +1098,11 @@ func StorageIdVolumePost(storageId string, model *sf.VolumeV161Volume) error { return err } - return StorageIdVolumeIdGet(storageId, volume.id, model) + return mgr.StorageIdVolumeIdGet(storageId, volume.id, model) } // StorageIdVolumeIdDelete - -func StorageIdVolumeIdDelete(storageId, volumeId string) error { +func (mgr *Manager) StorageIdVolumeIdDelete(storageId, volumeId string) error { s, v := findStorageVolume(storageId, volumeId) if v == nil { return ec.NewErrBadRequest().WithCause(fmt.Sprintf("storage volume id %s not found", volumeId)) diff --git a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/servicer.go b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/servicer.go index 3a0c744ce..e622d28e6 100644 --- a/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/servicer.go +++ b/vendor/github.hpe.com/hpe/hpc-rabsw-nnf-ec/pkg/manager-nvme/servicer.go @@ -11,15 +11,16 @@ import ( // DefaultApiService - type DefaultApiService struct { + api StorageApi } // NewDefaultApiService - func NewDefaultApiService() Api { - return &DefaultApiService{} + return &DefaultApiService{api: NewDefaultStorageService()} } // RedfishV1StorageGet -func (*DefaultApiService) RedfishV1StorageGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageGet(w http.ResponseWriter, r *http.Request) { model := sf.StorageCollectionStorageCollection{ OdataId: fmt.Sprintf("/redfish/v1/Storage"), @@ -27,13 +28,13 @@ func (*DefaultApiService) RedfishV1StorageGet(w http.ResponseWriter, r *http.Req Name: "Storage Collection", } - err := Get(&model) + err := s.api.Get(&model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdGet -func (*DefaultApiService) RedfishV1StorageStorageIdGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] @@ -43,13 +44,13 @@ func (*DefaultApiService) RedfishV1StorageStorageIdGet(w http.ResponseWriter, r Name: "Storage", } - err := StorageIdGet(storageId, &model) + err := s.api.StorageIdGet(storageId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdStoragePoolsGet -func (*DefaultApiService) RedfishV1StorageStorageIdStoragePoolsGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdStoragePoolsGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] @@ -59,13 +60,13 @@ func (*DefaultApiService) RedfishV1StorageStorageIdStoragePoolsGet(w http.Respon Name: "Storage Pool Collection", } - err := StorageIdStoragePoolsGet(storageId, &model) + err := s.api.StorageIdStoragePoolsGet(storageId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet -func (*DefaultApiService) RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] storagePoolId := params["StoragePoolId"] @@ -76,13 +77,13 @@ func (*DefaultApiService) RedfishV1StorageStorageIdStoragePoolsStoragePoolIdGet( Name: "Storage Pool", } - err := StorageIdStoragePoolIdGet(storageId, storagePoolId, &model) + err := s.api.StorageIdStoragePoolsStoragePoolIdGet(storageId, storagePoolId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdControllersGet -func (*DefaultApiService) RedfishV1StorageStorageIdControllersGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdControllersGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] @@ -92,13 +93,13 @@ func (*DefaultApiService) RedfishV1StorageStorageIdControllersGet(w http.Respons Name: "Storage Controller Collection", } - err := StorageIdControllersGet(storageId, &model) + err := s.api.StorageIdControllersGet(storageId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdControllersControllerIdGet -func (*DefaultApiService) RedfishV1StorageStorageIdControllersControllerIdGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdControllersControllerIdGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] controllerId := params["ControllerId"] @@ -109,13 +110,13 @@ func (*DefaultApiService) RedfishV1StorageStorageIdControllersControllerIdGet(w Name: "Storage Controller", } - err := StorageIdControllerIdGet(storageId, controllerId, &model) + err := s.api.StorageIdControllersControllerIdGet(storageId, controllerId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdVolumesGet -func (*DefaultApiService) RedfishV1StorageStorageIdVolumesGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] @@ -125,13 +126,13 @@ func (*DefaultApiService) RedfishV1StorageStorageIdVolumesGet(w http.ResponseWri Name: "Volume Collection", } - err := StorageIdVolumesGet(storageId, &model) + err := s.api.StorageIdVolumesGet(storageId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdVolumesPost -func (*DefaultApiService) RedfishV1StorageStorageIdVolumesPost(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesPost(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] @@ -142,7 +143,7 @@ func (*DefaultApiService) RedfishV1StorageStorageIdVolumesPost(w http.ResponseWr return } - if err := StorageIdVolumePost(storageId, &model); err != nil { + if err := s.api.StorageIdVolumesPost(storageId, &model); err != nil { EncodeResponse(model, err, w) return } @@ -155,7 +156,7 @@ func (*DefaultApiService) RedfishV1StorageStorageIdVolumesPost(w http.ResponseWr } // RedfishV1StorageStorageIdVolumesVolumeIdGet - -func (*DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdGet(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdGet(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] volumeId := params["VolumeId"] @@ -166,18 +167,18 @@ func (*DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdGet(w http.Res Name: "Volume", } - err := StorageIdVolumeIdGet(storageId, volumeId, &model) + err := s.api.StorageIdVolumeIdGet(storageId, volumeId, &model) EncodeResponse(model, err, w) } // RedfishV1StorageStorageIdVolumesVolumeIdDelete - -func (*DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdDelete(w http.ResponseWriter, r *http.Request) { +func (s *DefaultApiService) RedfishV1StorageStorageIdVolumesVolumeIdDelete(w http.ResponseWriter, r *http.Request) { params := Params(r) storageId := params["StorageId"] volumeId := params["VolumeId"] - err := StorageIdVolumeIdDelete(storageId, volumeId) + err := s.api.StorageIdVolumeIdDelete(storageId, volumeId) EncodeResponse(nil, err, w) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 45b080968..b4fad0822 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -183,12 +183,12 @@ github.com/sigurn/utils github.com/sirupsen/logrus # github.com/spf13/pflag v1.0.5 github.com/spf13/pflag -# github.hpe.com/hpe/hpc-dpm-dws-operator v0.0.0-20211213160018-2b73fb1030f9 => ./.dws-operator +# github.hpe.com/hpe/hpc-dpm-dws-operator v0.0.0-20220110213219-fcd5783304c2 => ./.dws-operator ## explicit github.hpe.com/hpe/hpc-dpm-dws-operator/api/v1alpha1 github.hpe.com/hpe/hpc-dpm-dws-operator/controllers github.hpe.com/hpe/hpc-dpm-dws-operator/utils/dwdparse -# github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20211213185652-ece897e5fe46 +# github.hpe.com/hpe/hpc-rabsw-nnf-ec v1.0.6-0.20220107171404-8b3a8cdbd9de ## explicit github.hpe.com/hpe/hpc-rabsw-nnf-ec/internal/kvstore github.hpe.com/hpe/hpc-rabsw-nnf-ec/internal/switchtec/pkg/nvme