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

Use NnfDataMovementProfiles #191

Merged
merged 1 commit into from
Aug 7, 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
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
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
1 change: 0 additions & 1 deletion 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 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: 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
60 changes: 57 additions & 3 deletions daemons/compute/server/servers/server_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,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 @@ -237,7 +238,7 @@ 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{
Expand Down Expand Up @@ -355,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 @@ -398,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 @@ -459,7 +515,6 @@ func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataM
Name: lustrefs.Name,
},
},
Profile: req.Profile,
},
}

Expand Down Expand Up @@ -489,7 +544,6 @@ func (s *defaultServer) createNnfNodeDataMovement(ctx context.Context, req *pb.D
Destination: &nnfv1alpha1.NnfDataMovementSpecSourceDestination{
Path: req.Destination,
},
Profile: req.Profile,
},
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.20240729130730-8f01fd2116ea
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240801190336-58f2d99dd6cb
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
github.com/prometheus/client_golang v1.16.0
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.20240726140248-bd9f85356c73
github.com/DataWorkflowServices/dws v0.0.1-0.20240801173757-1fb2188d84b9
go.openly.dev/pointy v1.3.0
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
github.com/DataWorkflowServices/dws v0.0.1-0.20240726140248-bd9f85356c73 h1:bq1AaHhdaeuaq+ibNk/UIMExXuLicfQCir25xKHnEck=
github.com/DataWorkflowServices/dws v0.0.1-0.20240726140248-bd9f85356c73/go.mod h1:6MrEEHISskyooSKcKU6R3mFqH6Yh6KzWgajhcw2s+nM=
github.com/DataWorkflowServices/dws v0.0.1-0.20240801173757-1fb2188d84b9 h1:Jf5AxKXNxNtDC4YBbnJfpKWr4DicrEJ0aCtIgarIIqU=
github.com/DataWorkflowServices/dws v0.0.1-0.20240801173757-1fb2188d84b9/go.mod h1:6MrEEHISskyooSKcKU6R3mFqH6Yh6KzWgajhcw2s+nM=
github.com/NearNodeFlash/lustre-fs-operator v0.0.1-0.20240709160956-40dcbac0aadf h1:ArBI1LR+BBZ9lF+Aohv49RhTpmRqIXLz4L/h45qQT4k=
github.com/NearNodeFlash/lustre-fs-operator v0.0.1-0.20240709160956-40dcbac0aadf/go.mod h1:N5X1obpl0mBI0VoCJdQhv7cFXOC6g3VlXj712qWj0JE=
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20240708183336-34d1295977f5 h1:7eT5mOVSNwtacIcGhzMAsi8EVbeS4zk9QwThG2f0GHE=
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20240708183336-34d1295977f5/go.mod h1:oxdwMqfttOF9dabJhqrWlirCnMk8/8eyLMwl+hducjk=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240729130730-8f01fd2116ea h1:WZCoDgPMs8+3jle4iJnx4EaPlBLd6pr2ks+o8U4yy10=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240729130730-8f01fd2116ea/go.mod h1:WBbrMgTEGvnFbbuQglDBoLl/KvcsC3F/CKY9jq5hWgU=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240801190336-58f2d99dd6cb h1:tHAn3aqU61vQ+FCo+6uLZrhamrfwq4qV5EBlBlqDOpk=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20240801190336-58f2d99dd6cb/go.mod h1:uJvjwkSLrPk4A/13U/E4vnO8R+utDE/lGclsKVp/88s=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
Loading
Loading