Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Richerson <[email protected]>
  • Loading branch information
matthew-richerson committed Nov 16, 2023
1 parent ff88eaf commit f6637b9
Show file tree
Hide file tree
Showing 45 changed files with 3,278 additions and 1,071 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
TEST_TARGET: testing

# DO_TEST - true to build and run unit tests, false to skip the tests
DO_TEST: true
DO_TEST: false

# DO_PUSH - true to push to the HPE_DEPLOY_REPO, false to not push
DO_PUSH: true
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ COPY go.sum go.sum
COPY cmd/ cmd/
COPY api/ api/
COPY internal/ internal/
COPY pkg/ pkg/
COPY vendor/ vendor/
COPY config/ config/

Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ resources:
kind: NnfNodeStorage
path: github.com/NearNodeFlash/nnf-sos/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cray.hpe.com
group: nnf
kind: NnfNodeBlockStorage
path: github.com/NearNodeFlash/nnf-sos/api/v1alpha1
version: v1alpha1
- controller: true
domain: github.io
group: dataworkflowservices
Expand Down
120 changes: 120 additions & 0 deletions api/v1alpha1/nnf_node_block_storage_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright 2021-2023 Hewlett Packard Enterprise Development LP
* Other additional copyright holders may be indicated within.
*
* The entirety of this work is 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.
*/

package v1alpha1

import (
dwsv1alpha2 "github.com/DataWorkflowServices/dws/api/v1alpha2"
"github.com/DataWorkflowServices/dws/utils/updater"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type NnfNodeBlockStorageAllocationSpec struct {
Capacity int64 `json:"capacity,omitempty"`

Access []string `json:"access,omitempty"`
}

// NnfNodeBlockStorageSpec defines the desired storage attributes on a NNF Node.
// Storage spec are created on bequest of the user and fullfilled by the NNF Node Controller.
type NnfNodeBlockStorageSpec struct {
Allocations []NnfNodeBlockStorageAllocationSpec `json:"allocations,omitempty"`
}

type NnfNodeBlockStorageStatus struct {
// Allocations is the list of storage allocations that were made
Allocations []NnfNodeBlockStorageAllocationStatus `json:"allocations,omitempty"`

dwsv1alpha2.ResourceError `json:",inline"`

Ready bool `json:"ready"`
}

type NnfNodeBlockStorageDeviceStatus struct {
// NQN of the base NVMe device
NQN string `json:"NQN"`

// Id of the Namespace on the NVMe device (e.g., "2")
NamespaceId string `json:"namespaceId"`

// Total capacity allocated for the storage. This may differ from the requested storage
// capacity as the system may round up to the requested capacity satisify underlying
// storage requirements (i.e. block size / stripe size).
CapacityAllocated int64 `json:"capacityAllocated,omitempty"`
}

type NnfNodeBlockStorageAccessStatus struct {
DevicePaths []string `json:"devicePaths,omitempty"`

StorageGroupId string `json:"storageGroupId,omitempty"`
}

type NnfNodeBlockStorageAllocationStatus struct {
Accesses map[string]NnfNodeBlockStorageAccessStatus `json:"accesses,omitempty"`

// List of NVMe namespaces used by this allocation
Devices []NnfNodeBlockStorageDeviceStatus `json:"devices,omitempty"`

// Total capacity allocated for the storage. This may differ from the requested storage
// capacity as the system may round up to the requested capacity satisify underlying
// storage requirements (i.e. block size / stripe size).
CapacityAllocated int64 `json:"capacityAllocated,omitempty"`

StoragePoolId string `json:"storagePoolId,omitempty"`
}

//+kubebuilder:object:root=true

type NnfNodeBlockStorage struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NnfNodeBlockStorageSpec `json:"spec,omitempty"`
Status NnfNodeBlockStorageStatus `json:"status,omitempty"`
}

func (ns *NnfNodeBlockStorage) GetStatus() updater.Status[*NnfNodeBlockStorageStatus] {
return &ns.Status
}

//+kubebuilder:object:root=true
//+kubebuilder:printcolumn:name="ERROR",type="string",JSONPath=".status.error.severity"
//+kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"

// NnfNodeBlockStorageList contains a list of NNF Nodes
type NnfNodeBlockStorageList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NnfNodeBlockStorage `json:"items"`
}

func (n *NnfNodeBlockStorageList) GetObjectList() []client.Object {
objectList := []client.Object{}

for i := range n.Items {
objectList = append(objectList, &n.Items[i])
}

return objectList
}

func init() {
SchemeBuilder.Register(&NnfNodeBlockStorage{}, &NnfNodeBlockStorageList{})
}
78 changes: 6 additions & 72 deletions api/v1alpha1/nnf_node_storage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ type NnfNodeStorageSpec struct {
// Group ID for file system
GroupID uint32 `json:"groupID"`

// Set the owner and group permissions specified by UserID and GroupID. This is for
// Lustre file systems only, and should be set only after all Lustre targets are created.
// +kubebuilder:default:=false
SetOwnerGroup bool `json:"setOwnerGroup"`

// Capacity defines the capacity, in bytes, of this storage specification. The NNF Node itself
// may split the storage among the available drives operating in the NNF Node.
Capacity int64 `json:"capacity,omitempty"`
Expand All @@ -61,19 +56,6 @@ type NnfNodeStorageSpec struct {
// LustreStorageSpec describes the Lustre target created here, if
// FileSystemType specifies a Lustre target.
LustreStorage LustreStorageSpec `json:"lustreStorage,omitempty"`

// ClientEndpoints sets which endpoints should have access to an allocation.
ClientEndpoints []ClientEndpointsSpec `json:"clientEndpoints"`
}

// ClientEndpointsSpec contains information about which nodes a storage allocation
// should be visible to
type ClientEndpointsSpec struct {
// Index of the allocation in the NnfNodeStorage
AllocationIndex int `json:"allocationIndex"`

// List of nodes that should see the allocation
NodeNames []string `json:"nodeNames"`
}

// LustreStorageSpec describes the Lustre target to be created here.
Expand All @@ -93,9 +75,9 @@ type LustreStorageSpec struct {
// +kubebuilder:validation:Minimum:=0
StartIndex int `json:"startIndex,omitempty"`

// MgsNode is the NID of the MGS to use. This is used only when
// MgsAddress is the NID of the MGS to use. This is used only when
// creating MDT and OST targets.
MgsNode string `json:"mgsNode,omitempty"`
MgsAddress string `json:"mgsAddress,omitempty"`

// BackFs is the type of backing filesystem to use.
// +kubebuilder:validation:Enum=ldiskfs;zfs
Expand All @@ -107,75 +89,27 @@ type NnfNodeStorageStatus struct {
// Allocations is the list of storage allocations that were made
Allocations []NnfNodeStorageAllocationStatus `json:"allocations,omitempty"`

dwsv1alpha2.ResourceError `json:",inline"`

// LustreStorageStatus describes the Lustre targets created here.
LustreStorage LustreStorageStatus `json:"lustreStorage,omitempty"`

// OwnerGroupStatus is the status of the operation for setting the owner and group
// of a file system
OwnerGroupStatus NnfResourceStatusType `json:"ownerGroupStatus,omitempty"`
}

// NnfNodeStorageNVMeStatus provides a way to uniquely identify an NVMe namespace
// in the system
type NnfNodeStorageNVMeStatus struct {
// Serial number of the base NVMe device
DeviceSerial string `json:"deviceSerial"`

// Id of the Namespace on the NVMe device (e.g., "2")
NamespaceID string `json:"namespaceID"`
Ready bool `json:"ready,omitempty"`

// Globally unique namespace ID
NamespaceGUID string `json:"namespaceGUID"`
dwsv1alpha2.ResourceError `json:",inline"`
}

// NnfNodeStorageAllocationStatus defines the allocation status for each allocation in the NnfNodeStorage
type NnfNodeStorageAllocationStatus struct {
// Represents the time when the storage was created by the controller
// It is represented in RFC3339 form and is in UTC.
CreationTime *metav1.Time `json:"creationTime,omitempty"`

// Represents the time when the storage was deleted by the controller. This field
// is updated when the Storage specification State transitions to 'Delete' by the
// client.
// It is represented in RFC3339 form and is in UTC.
DeletionTime *metav1.Time `json:"deletionTime,omitempty"`

// Total capacity allocated for the storage. This may differ from the requested storage
// capacity as the system may round up to the requested capacity satisify underlying
// storage requirements (i.e. block size / stripe size).
CapacityAllocated int64 `json:"capacityAllocated,omitempty"`

// Represents the storage group that is supporting this server. A storage group is
// the mapping from a group of drive namespaces to an individual server. This value
// can be safely ignored by the client.
StorageGroup NnfResourceStatus `json:"storageGroup,omitempty"`

// Name of the LVM VG
VolumeGroup string `json:"volumeGroup,omitempty"`

// Name of the LVM LV
LogicalVolume string `json:"logicalVolume,omitempty"`

// List of NVMe namespaces used by this allocation
NVMeList []NnfNodeStorageNVMeStatus `json:"nvmeList,omitempty"`

// Represents the file share that is supporting this server. A file share is the
// combination of a storage group and the associated file system parameters (type, mountpoint)
// that makes up the available storage.
FileShare NnfResourceStatus `json:"fileShare,omitempty"`
Ready bool `json:"ready,omitempty"`

StoragePool NnfResourceStatus `json:"storagePool,omitempty"`

FileSystem NnfResourceStatus `json:"fileSystem,omitempty"`
}

// LustreStorageStatus describes the Lustre target created here.
type LustreStorageStatus struct {

// Nid (LNet Network Identifier) of this node. This is populated on MGS nodes only.
Nid string `json:"nid,omitempty"`
dwsv1alpha2.ResourceError `json:",inline"`
}

//+kubebuilder:object:root=true
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/nnf_node_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ type NnfNodeStatus struct {
// Fenced is true when the NNF Node is fenced by the STONITH agent, and false otherwise.
Fenced bool `json:"fenced,omitempty"`

// LNetNid is the LNet address for the NNF node
LNetNid string `json:"lnetNid,omitempty"`

Capacity int64 `json:"capacity,omitempty"`
CapacityAllocated int64 `json:"capacityAllocated,omitempty"`

Expand Down
14 changes: 3 additions & 11 deletions api/v1alpha1/nnf_storage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ type NnfStorageSpec struct {

// NnfStorageAllocationSetStatus contains the status information for an allocation set
type NnfStorageAllocationSetStatus struct {
// Status reflects the status of this allocation set
Status NnfResourceStatusType `json:"status,omitempty"`

// Health reflects the health of this allocation set
Health NnfResourceHealthType `json:"health,omitempty"`
Ready bool `json:"ready,omitempty"`

// AllocationCount is the total number of allocations that currently
// exist
Expand All @@ -118,8 +114,6 @@ type NnfStorageAllocationSetStatus struct {

// NnfStorageStatus defines the observed status of NNF Storage.
type NnfStorageStatus struct {
// Important: Run "make" to regenerate code after modifying this file

// MgsNode is the NID of the MGS.
MgsNode string `json:"mgsNode,omitempty"`

Expand All @@ -129,10 +123,8 @@ type NnfStorageStatus struct {

dwsv1alpha2.ResourceError `json:",inline"`

// Status reflects the status of this NNF Storage
Status NnfResourceStatusType `json:"status,omitempty"`

// TODO: Conditions
// Ready reflects the status of this NNF Storage
Ready bool `json:"ready,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
32 changes: 32 additions & 0 deletions api/v1alpha1/nnfstorageprofile_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"os"
"reflect"
"strings"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -143,3 +144,34 @@ func (r *NnfStorageProfile) validateLustreTargetMiscOptions(targetMiscOptions Nn

return nil
}

type VarHandler struct {
VarMap map[string]string
}

func NewVarHandler(vars map[string]string) *VarHandler {
v := &VarHandler{}
v.VarMap = vars
return v
}

// ListToVars splits the value of one of its variables, and creates a new
// indexed variable for each of the items in the split.
func (v *VarHandler) ListToVars(listVarName, newVarPrefix string) error {
theList, ok := v.VarMap[listVarName]
if !ok {
return fmt.Errorf("Unable to find the variable named %s", listVarName)
}

for i, val := range strings.Split(theList, " ") {
v.VarMap[fmt.Sprintf("%s%d", newVarPrefix, i+1)] = val
}
return nil
}

func (v *VarHandler) ReplaceAll(s string) string {
for key, value := range v.VarMap {
s = strings.ReplaceAll(s, key, value)
}
return s
}
Loading

0 comments on commit f6637b9

Please sign in to comment.