Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.1.4 #200

Merged
merged 15 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ jobs:
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
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"-ginkgo.failFast",
],
"env": {
"KUBEBUILDER_ASSETS": "${workspaceRoot}/bin/k8s/1.25.0-darwin-amd64",
"KUBEBUILDER_ASSETS": "${workspaceRoot}/bin/k8s/1.28.0-darwin-arm64",
"GOMEGA_DEFAULT_EVENTUALLY_TIMEOUT": "10m",
"GOMEGA_DEFAULT_EVENTUALLY_POLLING_INTERVAL": "500ms",
},
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
# These ARGs must be before the first FROM. This allows them to be valid for
# use in FROM instructions.
ARG NNFMFU_TAG_BASE=ghcr.io/nearnodeflash/nnf-mfu
ARG NNFMFU_VERSION=0.1.0
ARG NNFMFU_VERSION=0.1.1

# Build the manager binary
FROM golang:1.21-alpine as builder
FROM golang:1.21-alpine AS builder

ARG TARGETARCH
ARG TARGETOS
Expand All @@ -48,7 +48,7 @@ COPY internal/ internal/
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

###############################################################################
FROM builder as testing
FROM builder AS testing

WORKDIR /workspace

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ IMAGE_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-dm

# The NNF-MFU container image to use in NNFContainerProfile resources.
NNFMFU_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-mfu
NNFMFU_VERSION ?= 0.1.0
NNFMFU_VERSION ?= 0.1.1

CONTAINER_BUILDARGS=--build-arg NNFMFU_TAG_BASE=$(NNFMFU_TAG_BASE) --build-arg NNFMFU_VERSION=$(NNFMFU_VERSION)

Expand All @@ -59,7 +59,7 @@ CONTAINER_BUILDARGS=--build-arg NNFMFU_TAG_BASE=$(NNFMFU_TAG_BASE) --build-arg N
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.28.0
ENVTEST_K8S_VERSION = 1.29.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (*defaultController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha1.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha1.DataMovementProfileNamespace] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}

Expand All @@ -205,6 +206,7 @@ func (*nodeController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha1.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha1.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[os.Getenv("NNF_NODE_NAME")] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}
Expand Down
11 changes: 5 additions & 6 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namePrefix: nnf-dm-
resources:
- ../rbac
- ../manager
- ../dm_config
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
# - ../webhook
Expand All @@ -24,24 +23,24 @@ resources:
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus

patchesStrategicMerge:
patches:
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- manager_auth_proxy_patch.yaml
- path: manager_auth_proxy_patch.yaml

# Mount the controller config file for loading manager configurations
# through a ComponentConfig type
#- manager_config_patch.yaml
#- path: manager_config_patch.yaml

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
# - manager_webhook_patch.yaml
# - path: manager_webhook_patch.yaml

# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'.
# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks.
# 'CERTMANAGER' needs to be enabled to use ca injection
# - webhookcainjection_patch.yaml
# - path: webhookcainjection_patch.yaml

# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
# Uncomment the following replacements to add the cert-manager CA injection annotations
Expand Down
10 changes: 0 additions & 10 deletions config/dm_config/kustomization.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions config/dm_config/nnf-dm-config.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ resources:
generatorOptions:
disableNameSuffixHash: true

#patchesStrategicMerge:
#- manager_imagepullsecret_patch.yaml
#patches:
#- path: manager_imagepullsecret_patch.yaml

configMapGenerator:
- files:
Expand All @@ -16,7 +16,7 @@ kind: Kustomization
images:
- name: controller
newName: ghcr.io/nearnodeflash/nnf-dm
newTag: 0.1.3
newTag: 0.1.4
- name: nnf-mfu
newName: ghcr.io/nearnodeflash/nnf-mfu
newTag: 0.1.0
newTag: 0.1.1
8 changes: 8 additions & 0 deletions config/rbac/daemon_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ rules:
- patch
- update
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
- nnfdatamovementprofiles
verbs:
- get
- list
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ rules:
- get
- patch
- update
- apiGroups:
- nnf.cray.hpe.com
resources:
- nnfdatamovementprofiles
verbs:
- get
- list
- watch
- apiGroups:
- nnf.cray.hpe.com
resources:
Expand Down
70 changes: 61 additions & 9 deletions daemons/compute/server/servers/server_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ import (
lusv1beta1 "github.com/NearNodeFlash/lustre-fs-operator/api/v1beta1"
nnfv1alpha1 "github.com/NearNodeFlash/nnf-sos/api/v1alpha1"

dmctrl "github.com/NearNodeFlash/nnf-dm/internal/controller"

pb "github.com/NearNodeFlash/nnf-dm/daemons/compute/client-go/api"

"github.com/NearNodeFlash/nnf-dm/daemons/compute/server/auth"
Expand Down Expand Up @@ -98,6 +96,7 @@ type defaultServer struct {
// Ensure permissions are granted to access the system configuration; this is done so the NNF
// Node Name can be found given a Node Name.
//+kubebuilder:rbac:groups=dataworkflowservices.github.io,resources=systemconfigurations,verbs=get;list;watch
//+kubebuilder:rbac:groups=nnf.cray.hpe.com,resources=nnfdatamovementprofiles,verbs=get;list;watch

func CreateDefaultServer(opts *ServerOptions) (*defaultServer, error) {

Expand Down Expand Up @@ -239,13 +238,13 @@ func (s *defaultServer) StartManager() error {
}

// Setup two managers for watching the individual data movement type resources. They behave
// similarily, performing a reconcile only for updates to this node
// similarly, performing a reconcile only for updates to this node
func (s *defaultServer) setupWithManager(mgr ctrl.Manager) error {

p := predicate.Funcs{
CreateFunc: func(ce event.CreateEvent) bool { return false },
UpdateFunc: func(ue event.UpdateEvent) bool {
if initiator := ue.ObjectNew.GetLabels()[dmctrl.InitiatorLabel]; initiator == s.name {
if initiator := ue.ObjectNew.GetLabels()[nnfv1alpha1.DataMovementInitiatorLabel]; initiator == s.name {
return true
}
return false
Expand Down Expand Up @@ -357,6 +356,20 @@ func (s *defaultServer) Create(ctx context.Context, req *pb.DataMovementCreateRe
}, nil
}

// Dm Profile - no pinned profiles here since copy_offload could use any profile
profile, err := s.getProfile(ctx, req.Profile)
if err != nil {
return &pb.DataMovementCreateResponse{
Status: pb.DataMovementCreateResponse_FAILED,
Message: "Error finding profile: " + err.Error(),
}, nil
}
dm.Spec.ProfileReference = corev1.ObjectReference{
Kind: reflect.TypeOf(nnfv1alpha1.NnfDataMovementProfile{}).Name(),
Name: profile.Name,
Namespace: profile.Namespace,
}

dm.Spec.UserId = userId
dm.Spec.GroupId = groupId

Expand Down Expand Up @@ -400,6 +413,47 @@ func setUserConfig(req *pb.DataMovementCreateRequest, dm *nnfv1alpha1.NnfDataMov
}
}

func (s *defaultServer) getProfile(ctx context.Context, profileName string) (*nnfv1alpha1.NnfDataMovementProfile, error) {
ns := "nnf-system"

// If a profile is named then verify that it exists. Otherwise, verify that a default profile
// can be found.
if len(profileName) == 0 {
NnfDataMovementProfiles := &nnfv1alpha1.NnfDataMovementProfileList{}
if err := s.client.List(ctx, NnfDataMovementProfiles, &client.ListOptions{Namespace: ns}); err != nil {
return nil, err
}
profilesFound := make([]string, 0, len(NnfDataMovementProfiles.Items))
for _, profile := range NnfDataMovementProfiles.Items {
if profile.Data.Default {
objkey := client.ObjectKeyFromObject(&profile)
profilesFound = append(profilesFound, objkey.Name)
}
}
// Require that there be one and only one default.
if len(profilesFound) == 0 {
return nil, fmt.Errorf("unable to find a default NnfDataMovementProfile to use")
} else if len(profilesFound) > 1 {
return nil, fmt.Errorf("more than one default NnfDataMovementProfile found; unable to pick one: %v", profilesFound)
}
profileName = profilesFound[0]
}

profile := &nnfv1alpha1.NnfDataMovementProfile{
ObjectMeta: metav1.ObjectMeta{
Name: profileName,
Namespace: ns,
},
}

err := s.client.Get(ctx, client.ObjectKeyFromObject(profile), profile)
if err != nil {
return nil, fmt.Errorf("unable to retrieve NnfDataMovementProfile: %s", profileName)
}

return profile, nil
}

func getDirectiveIndexFromClientMount(object *dwsv1alpha2.ClientMount) (string, error) {
// Find the DW index for our work.
labels := object.GetLabels()
Expand Down Expand Up @@ -444,8 +498,8 @@ func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataM
// Use the data movement namespace.
Namespace: nnfv1alpha1.DataMovementNamespace,
Labels: map[string]string{
dmctrl.InitiatorLabel: s.name,
nnfv1alpha1.DirectiveIndexLabel: dwIndex,
nnfv1alpha1.DataMovementInitiatorLabel: s.name,
nnfv1alpha1.DirectiveIndexLabel: dwIndex,
},
},
Spec: nnfv1alpha1.NnfDataMovementSpec{
Expand All @@ -461,7 +515,6 @@ func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataM
Name: lustrefs.Name,
},
},
Profile: req.Profile,
},
}

Expand All @@ -480,7 +533,7 @@ func (s *defaultServer) createNnfNodeDataMovement(ctx context.Context, req *pb.D
GenerateName: nodeNameBase,
Namespace: s.namespace, // Use the rabbit
Labels: map[string]string{
dmctrl.InitiatorLabel: s.name,
nnfv1alpha1.DataMovementInitiatorLabel: s.name,
},
},
Spec: nnfv1alpha1.NnfDataMovementSpec{
Expand All @@ -491,7 +544,6 @@ func (s *defaultServer) createNnfNodeDataMovement(ctx context.Context, req *pb.D
Destination: &nnfv1alpha1.NnfDataMovementSpecSourceDestination{
Path: req.Destination,
},
Profile: req.Profile,
},
}

Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/NearNodeFlash/nnf-dm
go 1.21

require (
github.com/NearNodeFlash/lustre-fs-operator v0.0.1-0.20240709160956-40dcbac0aadf
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240716150554-cdaa6e380157
github.com/NearNodeFlash/lustre-fs-operator v0.0.1-0.20240820214524-99d5da17471d
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240821141947-f61076751e0f
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
github.com/prometheus/client_golang v1.16.0
Expand All @@ -22,7 +22,7 @@ require (
)

require (
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20240708183336-34d1295977f5 // indirect
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20240820195316-cb407b151cb4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -69,11 +69,11 @@ require (
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0
sigs.k8s.io/yaml v1.3.0 // indirect
)

require (
github.com/DataWorkflowServices/dws v0.0.1-0.20240710175416-1e4b39039a88
github.com/DataWorkflowServices/dws v0.0.1-0.20240820212105-5950825b3d74
go.openly.dev/pointy v1.3.0
)

Expand Down
Loading
Loading