Skip to content

Commit

Permalink
Merge pull request #233 from NearNodeFlash/api-nnf-sos-v1alpha3
Browse files Browse the repository at this point in the history
CRDBUMPER-vendor-new-api
  • Loading branch information
bdevcich authored Nov 15, 2024
2 parents 2b0ad8a + c540aa7 commit f347fdf
Show file tree
Hide file tree
Showing 64 changed files with 25,564 additions and 260 deletions.
16 changes: 8 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

lusv1beta1 "github.com/NearNodeFlash/lustre-fs-operator/api/v1beta1"
nnfv1alpha3 "github.com/NearNodeFlash/nnf-sos/api/v1alpha3"
nnfv1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"

controllers "github.com/NearNodeFlash/nnf-dm/internal/controller"
//+kubebuilder:scaffold:imports
Expand All @@ -57,7 +57,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(lusv1beta1.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha3.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha4.AddToScheme(scheme))

//+kubebuilder:scaffold:scheme
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func (*managerController) GetType() string { return ManagerController }
func (*managerController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementNamespace] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}

Expand All @@ -200,16 +200,16 @@ func (*defaultController) GetType() string { return DefaultController }
func (*defaultController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementProfileNamespace] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}

func (c *defaultController) SetupReconcilers(mgr manager.Manager) (err error) {
if err = (&controllers.DataMovementReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
WatchNamespace: nnfv1alpha3.DataMovementNamespace,
WatchNamespace: nnfv1alpha4.DataMovementNamespace,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", c.GetType())
os.Exit(1)
Expand All @@ -227,8 +227,8 @@ func (*nodeController) GetType() string { return NodeController }
func (*nodeController) SetOptions(opts *ctrl.Options) {
namespaceCache := make(map[string]cache.Config)
namespaceCache[corev1.NamespaceDefault] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha4.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[os.Getenv("NNF_NODE_NAME")] = cache.Config{}
opts.Cache = cache.Options{DefaultNamespaces: namespaceCache}
}
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ spec:
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
---
apiVersion: nnf.cray.hpe.com/v1alpha3
apiVersion: nnf.cray.hpe.com/v1alpha4
kind: NnfDataMovementManager
metadata:
name: manager-controller-manager
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager_imagepullsecret_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
imagePullSecrets:
- name: name_of_secret
---
apiVersion: nnf.cray.hpe.com/v1alpha3
apiVersion: nnf.cray.hpe.com/v1alpha4
kind: NnfDataMovementManager
metadata:
name: manager-controller-manager
Expand Down
84 changes: 42 additions & 42 deletions daemons/compute/server/servers/server_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import (

dwsv1alpha2 "github.com/DataWorkflowServices/dws/api/v1alpha2"
lusv1beta1 "github.com/NearNodeFlash/lustre-fs-operator/api/v1beta1"
nnfv1alpha3 "github.com/NearNodeFlash/nnf-sos/api/v1alpha3"
nnfv1alpha4 "github.com/NearNodeFlash/nnf-sos/api/v1alpha4"

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

Expand All @@ -76,7 +76,7 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(dwsv1alpha2.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha3.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha4.AddToScheme(scheme))
utilruntime.Must(lusv1beta1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}
Expand Down Expand Up @@ -244,7 +244,7 @@ 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()[nnfv1alpha3.DataMovementInitiatorLabel]; initiator == s.name {
if initiator := ue.ObjectNew.GetLabels()[nnfv1alpha4.DataMovementInitiatorLabel]; initiator == s.name {
return true
}
return false
Expand All @@ -253,7 +253,7 @@ func (s *defaultServer) setupWithManager(mgr ctrl.Manager) error {
}

err := ctrl.NewControllerManagedBy(mgr).
For(&nnfv1alpha3.NnfDataMovement{}, builder.WithPredicates(p)).
For(&nnfv1alpha4.NnfDataMovement{}, builder.WithPredicates(p)).
Complete(&dataMovementReconciler{s})
if err != nil {
return err
Expand All @@ -268,7 +268,7 @@ type dataMovementReconciler struct {

func (r *dataMovementReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

dm := &nnfv1alpha3.NnfDataMovement{}
dm := &nnfv1alpha4.NnfDataMovement{}
if err := r.server.client.Get(ctx, req.NamespacedName, dm); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
Expand Down Expand Up @@ -321,7 +321,7 @@ func (s *defaultServer) Create(ctx context.Context, req *pb.DataMovementCreateRe
}, nil
}

var dm *nnfv1alpha3.NnfDataMovement
var dm *nnfv1alpha4.NnfDataMovement
dmFunc := ""
switch computeMountInfo.Type {
case "lustre":
Expand Down Expand Up @@ -365,7 +365,7 @@ func (s *defaultServer) Create(ctx context.Context, req *pb.DataMovementCreateRe
}, nil
}
dm.Spec.ProfileReference = corev1.ObjectReference{
Kind: reflect.TypeOf(nnfv1alpha3.NnfDataMovementProfile{}).Name(),
Kind: reflect.TypeOf(nnfv1alpha4.NnfDataMovementProfile{}).Name(),
Name: profile.Name,
Namespace: profile.Namespace,
}
Expand All @@ -379,7 +379,7 @@ func (s *defaultServer) Create(ctx context.Context, req *pb.DataMovementCreateRe

// Label the NnfDataMovement with a teardown state of "post_run" so the NNF workflow
// controller can identify compute initiated data movements.
nnfv1alpha3.AddDataMovementTeardownStateLabel(dm, dwsv1alpha2.StatePostRun)
nnfv1alpha4.AddDataMovementTeardownStateLabel(dm, dwsv1alpha2.StatePostRun)

// Allow the user to override/supplement certain settings
setUserConfig(req, dm)
Expand All @@ -398,8 +398,8 @@ func (s *defaultServer) Create(ctx context.Context, req *pb.DataMovementCreateRe
}

// Set the DM's UserConfig options based on the incoming requests's options
func setUserConfig(req *pb.DataMovementCreateRequest, dm *nnfv1alpha3.NnfDataMovement) {
dm.Spec.UserConfig = &nnfv1alpha3.NnfDataMovementConfig{}
func setUserConfig(req *pb.DataMovementCreateRequest, dm *nnfv1alpha4.NnfDataMovement) {
dm.Spec.UserConfig = &nnfv1alpha4.NnfDataMovementConfig{}
dm.Spec.UserConfig.Dryrun = req.Dryrun
dm.Spec.UserConfig.MpirunOptions = req.MpirunOptions
dm.Spec.UserConfig.DcpOptions = req.DcpOptions
Expand All @@ -414,13 +414,13 @@ func setUserConfig(req *pb.DataMovementCreateRequest, dm *nnfv1alpha3.NnfDataMov
}
}

func (s *defaultServer) getProfile(ctx context.Context, profileName string) (*nnfv1alpha3.NnfDataMovementProfile, error) {
func (s *defaultServer) getProfile(ctx context.Context, profileName string) (*nnfv1alpha4.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 := &nnfv1alpha3.NnfDataMovementProfileList{}
NnfDataMovementProfiles := &nnfv1alpha4.NnfDataMovementProfileList{}
if err := s.client.List(ctx, NnfDataMovementProfiles, &client.ListOptions{Namespace: ns}); err != nil {
return nil, err
}
Expand All @@ -440,7 +440,7 @@ func (s *defaultServer) getProfile(ctx context.Context, profileName string) (*nn
profileName = profilesFound[0]
}

profile := &nnfv1alpha3.NnfDataMovementProfile{
profile := &nnfv1alpha4.NnfDataMovementProfile{
ObjectMeta: metav1.ObjectMeta{
Name: profileName,
Namespace: ns,
Expand All @@ -462,15 +462,15 @@ func getDirectiveIndexFromClientMount(object *dwsv1alpha2.ClientMount) (string,
return "", fmt.Errorf("unable to find labels on compute ClientMount, namespaces=%s, name=%s", object.Namespace, object.Name)
}

dwIndex, found := labels[nnfv1alpha3.DirectiveIndexLabel]
dwIndex, found := labels[nnfv1alpha4.DirectiveIndexLabel]
if !found {
return "", fmt.Errorf("unable to find directive index label on compute ClientMount, namespace=%s name=%s", object.Namespace, object.Name)
}

return dwIndex, nil
}

func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataMovementCreateRequest, computeMountInfo *dwsv1alpha2.ClientMountInfo, computeClientMount *dwsv1alpha2.ClientMount) (*nnfv1alpha3.NnfDataMovement, error) {
func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataMovementCreateRequest, computeMountInfo *dwsv1alpha2.ClientMountInfo, computeClientMount *dwsv1alpha2.ClientMount) (*nnfv1alpha4.NnfDataMovement, error) {

// Find the ClientMount for the rabbit.
source, err := s.findRabbitRelativeSource(ctx, computeMountInfo, req)
Expand All @@ -490,25 +490,25 @@ func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataM
return nil, err
}

dm := &nnfv1alpha3.NnfDataMovement{
dm := &nnfv1alpha4.NnfDataMovement{
ObjectMeta: metav1.ObjectMeta{
// Be careful about how much you put into GenerateName.
// The MPI operator will use the resulting name as a
// prefix for its own names.
GenerateName: nameBase,
// Use the data movement namespace.
Namespace: nnfv1alpha3.DataMovementNamespace,
Namespace: nnfv1alpha4.DataMovementNamespace,
Labels: map[string]string{
nnfv1alpha3.DataMovementInitiatorLabel: s.name,
nnfv1alpha3.DirectiveIndexLabel: dwIndex,
nnfv1alpha4.DataMovementInitiatorLabel: s.name,
nnfv1alpha4.DirectiveIndexLabel: dwIndex,
},
},
Spec: nnfv1alpha3.NnfDataMovementSpec{
Source: &nnfv1alpha3.NnfDataMovementSpecSourceDestination{
Spec: nnfv1alpha4.NnfDataMovementSpec{
Source: &nnfv1alpha4.NnfDataMovementSpecSourceDestination{
Path: source,
StorageReference: computeMountInfo.Device.DeviceReference.ObjectReference,
},
Destination: &nnfv1alpha3.NnfDataMovementSpecSourceDestination{
Destination: &nnfv1alpha4.NnfDataMovementSpecSourceDestination{
Path: req.Destination,
StorageReference: corev1.ObjectReference{
Kind: reflect.TypeOf(*lustrefs).Name(),
Expand All @@ -522,27 +522,27 @@ func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataM
return dm, nil
}

func (s *defaultServer) createNnfNodeDataMovement(ctx context.Context, req *pb.DataMovementCreateRequest, computeMountInfo *dwsv1alpha2.ClientMountInfo) (*nnfv1alpha3.NnfDataMovement, error) {
func (s *defaultServer) createNnfNodeDataMovement(ctx context.Context, req *pb.DataMovementCreateRequest, computeMountInfo *dwsv1alpha2.ClientMountInfo) (*nnfv1alpha4.NnfDataMovement, error) {
// Find the ClientMount for the rabbit.
source, err := s.findRabbitRelativeSource(ctx, computeMountInfo, req)
if err != nil {
return nil, err
}

dm := &nnfv1alpha3.NnfDataMovement{
dm := &nnfv1alpha4.NnfDataMovement{
ObjectMeta: metav1.ObjectMeta{
GenerateName: nodeNameBase,
Namespace: s.namespace, // Use the rabbit
Labels: map[string]string{
nnfv1alpha3.DataMovementInitiatorLabel: s.name,
nnfv1alpha4.DataMovementInitiatorLabel: s.name,
},
},
Spec: nnfv1alpha3.NnfDataMovementSpec{
Source: &nnfv1alpha3.NnfDataMovementSpecSourceDestination{
Spec: nnfv1alpha4.NnfDataMovementSpec{
Source: &nnfv1alpha4.NnfDataMovementSpecSourceDestination{
Path: source,
StorageReference: computeMountInfo.Device.DeviceReference.ObjectReference,
},
Destination: &nnfv1alpha3.NnfDataMovementSpecSourceDestination{
Destination: &nnfv1alpha4.NnfDataMovementSpecSourceDestination{
Path: req.Destination,
},
},
Expand All @@ -561,7 +561,7 @@ func (s *defaultServer) List(ctx context.Context, req *pb.DataMovementListReques
}),
}

list := nnfv1alpha3.NnfDataMovementList{}
list := nnfv1alpha4.NnfDataMovementList{}
if err := s.client.List(ctx, &list, opts...); err != nil {
return nil, err
}
Expand All @@ -580,7 +580,7 @@ func (s *defaultServer) Status(ctx context.Context, req *pb.DataMovementStatusRe

ns := s.getNamespace(req.Uid)

dm := &nnfv1alpha3.NnfDataMovement{}
dm := &nnfv1alpha4.NnfDataMovement{}
if err := s.client.Get(ctx, types.NamespacedName{Name: req.Uid, Namespace: ns}, dm); err != nil {
if errors.IsNotFound(err) {
return &pb.DataMovementStatusResponse{
Expand Down Expand Up @@ -608,7 +608,7 @@ func (s *defaultServer) Status(ctx context.Context, req *pb.DataMovementStatusRe
}
}

if dm.Status.StartTime.IsZero() && dm.Status.Status != nnfv1alpha3.DataMovementConditionReasonInvalid {
if dm.Status.StartTime.IsZero() && dm.Status.Status != nnfv1alpha4.DataMovementConditionReasonInvalid {
return &pb.DataMovementStatusResponse{
State: pb.DataMovementStatusResponse_PENDING,
Status: pb.DataMovementStatusResponse_UNKNOWN_STATUS,
Expand All @@ -617,9 +617,9 @@ func (s *defaultServer) Status(ctx context.Context, req *pb.DataMovementStatusRe

stateMap := map[string]pb.DataMovementStatusResponse_State{
"": pb.DataMovementStatusResponse_UNKNOWN_STATE,
nnfv1alpha3.DataMovementConditionTypeStarting: pb.DataMovementStatusResponse_STARTING,
nnfv1alpha3.DataMovementConditionTypeRunning: pb.DataMovementStatusResponse_RUNNING,
nnfv1alpha3.DataMovementConditionTypeFinished: pb.DataMovementStatusResponse_COMPLETED,
nnfv1alpha4.DataMovementConditionTypeStarting: pb.DataMovementStatusResponse_STARTING,
nnfv1alpha4.DataMovementConditionTypeRunning: pb.DataMovementStatusResponse_RUNNING,
nnfv1alpha4.DataMovementConditionTypeFinished: pb.DataMovementStatusResponse_COMPLETED,
}

state, ok := stateMap[dm.Status.State]
Expand All @@ -637,10 +637,10 @@ func (s *defaultServer) Status(ctx context.Context, req *pb.DataMovementStatusRe

statusMap := map[string]pb.DataMovementStatusResponse_Status{
"": pb.DataMovementStatusResponse_UNKNOWN_STATUS,
nnfv1alpha3.DataMovementConditionReasonFailed: pb.DataMovementStatusResponse_FAILED,
nnfv1alpha3.DataMovementConditionReasonSuccess: pb.DataMovementStatusResponse_SUCCESS,
nnfv1alpha3.DataMovementConditionReasonInvalid: pb.DataMovementStatusResponse_INVALID,
nnfv1alpha3.DataMovementConditionReasonCancelled: pb.DataMovementStatusResponse_CANCELLED,
nnfv1alpha4.DataMovementConditionReasonFailed: pb.DataMovementStatusResponse_FAILED,
nnfv1alpha4.DataMovementConditionReasonSuccess: pb.DataMovementStatusResponse_SUCCESS,
nnfv1alpha4.DataMovementConditionReasonInvalid: pb.DataMovementStatusResponse_INVALID,
nnfv1alpha4.DataMovementConditionReasonCancelled: pb.DataMovementStatusResponse_CANCELLED,
}

status, ok := statusMap[dm.Status.Status]
Expand Down Expand Up @@ -744,7 +744,7 @@ func (s *defaultServer) Cancel(ctx context.Context, req *pb.DataMovementCancelRe
ns := s.getNamespace(req.Uid)

err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
dm := &nnfv1alpha3.NnfDataMovement{}
dm := &nnfv1alpha4.NnfDataMovement{}
if err := s.client.Get(ctx, types.NamespacedName{Name: req.Uid, Namespace: ns}, dm); err != nil {
return err
}
Expand Down Expand Up @@ -784,7 +784,7 @@ func (s *defaultServer) Delete(ctx context.Context, req *pb.DataMovementDeleteRe

ns := s.getNamespace(req.Uid)

dm := &nnfv1alpha3.NnfDataMovement{}
dm := &nnfv1alpha4.NnfDataMovement{}
if err := s.client.Get(ctx, types.NamespacedName{Name: req.Uid, Namespace: ns}, dm); err != nil {
if errors.IsNotFound(err) {
return &pb.DataMovementDeleteResponse{
Expand All @@ -795,7 +795,7 @@ func (s *defaultServer) Delete(ctx context.Context, req *pb.DataMovementDeleteRe
return nil, err
}

if dm.Status.State != nnfv1alpha3.DataMovementConditionTypeFinished {
if dm.Status.State != nnfv1alpha4.DataMovementConditionTypeFinished {
return &pb.DataMovementDeleteResponse{
Status: pb.DataMovementDeleteResponse_ACTIVE,
}, nil
Expand Down Expand Up @@ -922,5 +922,5 @@ func (s *defaultServer) getNamespace(uid string) string {
return s.namespace
}

return nnfv1alpha3.DataMovementNamespace
return nnfv1alpha4.DataMovementNamespace
}
2 changes: 1 addition & 1 deletion 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.20240925185149-26d9d6071a1c
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241107172130-4ef2c58da119
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241114160945-1b8980a4df2e
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/NearNodeFlash/lustre-fs-operator v0.0.1-0.20240925185149-26d9d6071a1c
github.com/NearNodeFlash/lustre-fs-operator v0.0.1-0.20240925185149-26d9d6071a1c/go.mod h1:3wENUqk1b7V0q5L5kNQ2ZE3z/NywL4sqXqVYolsiJ94=
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20241017152925-afc4d0cf1a4b h1:Foz6dsOk49tPimuKOxHAijX2BPuLxLH3Z+IegBMKHsU=
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20241017152925-afc4d0cf1a4b/go.mod h1:oxdwMqfttOF9dabJhqrWlirCnMk8/8eyLMwl+hducjk=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241107172130-4ef2c58da119 h1:KdA/shecdj4J1LRs0VwZ2MjAndi/smCkQRm2eACgOsg=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241107172130-4ef2c58da119/go.mod h1:oV8wj0tG6qxlCbYWDsKuL+dLXQd6hNtxdyYsIjrMrBI=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241114160945-1b8980a4df2e h1:q6ET0Gjp+2JExd6N1iAw7hmj8cuHE6UGwHt/iVcWq5M=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241114160945-1b8980a4df2e/go.mod h1:oV8wj0tG6qxlCbYWDsKuL+dLXQd6hNtxdyYsIjrMrBI=
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

0 comments on commit f347fdf

Please sign in to comment.