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

CRDBUMPER-vendor-new-api #225

Merged
merged 1 commit into from
Oct 9, 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
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"
nnfv1alpha2 "github.com/NearNodeFlash/nnf-sos/api/v1alpha2"
nnfv1alpha3 "github.com/NearNodeFlash/nnf-sos/api/v1alpha3"

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(nnfv1alpha2.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha3.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[nnfv1alpha2.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.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[nnfv1alpha2.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha2.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.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: nnfv1alpha2.DataMovementNamespace,
WatchNamespace: nnfv1alpha3.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[nnfv1alpha2.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha2.DataMovementProfileNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.DataMovementNamespace] = cache.Config{}
namespaceCache[nnfv1alpha3.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/v1alpha2
apiVersion: nnf.cray.hpe.com/v1alpha3
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/v1alpha2
apiVersion: nnf.cray.hpe.com/v1alpha3
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"
nnfv1alpha2 "github.com/NearNodeFlash/nnf-sos/api/v1alpha2"
nnfv1alpha3 "github.com/NearNodeFlash/nnf-sos/api/v1alpha3"

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(nnfv1alpha2.AddToScheme(scheme))
utilruntime.Must(nnfv1alpha3.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()[nnfv1alpha2.DataMovementInitiatorLabel]; initiator == s.name {
if initiator := ue.ObjectNew.GetLabels()[nnfv1alpha3.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(&nnfv1alpha2.NnfDataMovement{}, builder.WithPredicates(p)).
For(&nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovement{}
dm := &nnfv1alpha3.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 *nnfv1alpha2.NnfDataMovement
var dm *nnfv1alpha3.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(nnfv1alpha2.NnfDataMovementProfile{}).Name(),
Kind: reflect.TypeOf(nnfv1alpha3.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.
nnfv1alpha2.AddDataMovementTeardownStateLabel(dm, dwsv1alpha2.StatePostRun)
nnfv1alpha3.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 *nnfv1alpha2.NnfDataMovement) {
dm.Spec.UserConfig = &nnfv1alpha2.NnfDataMovementConfig{}
func setUserConfig(req *pb.DataMovementCreateRequest, dm *nnfv1alpha3.NnfDataMovement) {
dm.Spec.UserConfig = &nnfv1alpha3.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 *nnfv1alpha2.NnfDataMov
}
}

func (s *defaultServer) getProfile(ctx context.Context, profileName string) (*nnfv1alpha2.NnfDataMovementProfile, error) {
func (s *defaultServer) getProfile(ctx context.Context, profileName string) (*nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovementProfileList{}
NnfDataMovementProfiles := &nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovementProfile{
profile := &nnfv1alpha3.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[nnfv1alpha2.DirectiveIndexLabel]
dwIndex, found := labels[nnfv1alpha3.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) (*nnfv1alpha2.NnfDataMovement, error) {
func (s *defaultServer) createNnfDataMovement(ctx context.Context, req *pb.DataMovementCreateRequest, computeMountInfo *dwsv1alpha2.ClientMountInfo, computeClientMount *dwsv1alpha2.ClientMount) (*nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovement{
dm := &nnfv1alpha3.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: nnfv1alpha2.DataMovementNamespace,
Namespace: nnfv1alpha3.DataMovementNamespace,
Labels: map[string]string{
nnfv1alpha2.DataMovementInitiatorLabel: s.name,
nnfv1alpha2.DirectiveIndexLabel: dwIndex,
nnfv1alpha3.DataMovementInitiatorLabel: s.name,
nnfv1alpha3.DirectiveIndexLabel: dwIndex,
},
},
Spec: nnfv1alpha2.NnfDataMovementSpec{
Source: &nnfv1alpha2.NnfDataMovementSpecSourceDestination{
Spec: nnfv1alpha3.NnfDataMovementSpec{
Source: &nnfv1alpha3.NnfDataMovementSpecSourceDestination{
Path: source,
StorageReference: computeMountInfo.Device.DeviceReference.ObjectReference,
},
Destination: &nnfv1alpha2.NnfDataMovementSpecSourceDestination{
Destination: &nnfv1alpha3.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) (*nnfv1alpha2.NnfDataMovement, error) {
func (s *defaultServer) createNnfNodeDataMovement(ctx context.Context, req *pb.DataMovementCreateRequest, computeMountInfo *dwsv1alpha2.ClientMountInfo) (*nnfv1alpha3.NnfDataMovement, error) {
// Find the ClientMount for the rabbit.
source, err := s.findRabbitRelativeSource(ctx, computeMountInfo, req)
if err != nil {
return nil, err
}

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

list := nnfv1alpha2.NnfDataMovementList{}
list := nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovement{}
dm := &nnfv1alpha3.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 != nnfv1alpha2.DataMovementConditionReasonInvalid {
if dm.Status.StartTime.IsZero() && dm.Status.Status != nnfv1alpha3.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,
nnfv1alpha2.DataMovementConditionTypeStarting: pb.DataMovementStatusResponse_STARTING,
nnfv1alpha2.DataMovementConditionTypeRunning: pb.DataMovementStatusResponse_RUNNING,
nnfv1alpha2.DataMovementConditionTypeFinished: pb.DataMovementStatusResponse_COMPLETED,
nnfv1alpha3.DataMovementConditionTypeStarting: pb.DataMovementStatusResponse_STARTING,
nnfv1alpha3.DataMovementConditionTypeRunning: pb.DataMovementStatusResponse_RUNNING,
nnfv1alpha3.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,
nnfv1alpha2.DataMovementConditionReasonFailed: pb.DataMovementStatusResponse_FAILED,
nnfv1alpha2.DataMovementConditionReasonSuccess: pb.DataMovementStatusResponse_SUCCESS,
nnfv1alpha2.DataMovementConditionReasonInvalid: pb.DataMovementStatusResponse_INVALID,
nnfv1alpha2.DataMovementConditionReasonCancelled: pb.DataMovementStatusResponse_CANCELLED,
nnfv1alpha3.DataMovementConditionReasonFailed: pb.DataMovementStatusResponse_FAILED,
nnfv1alpha3.DataMovementConditionReasonSuccess: pb.DataMovementStatusResponse_SUCCESS,
nnfv1alpha3.DataMovementConditionReasonInvalid: pb.DataMovementStatusResponse_INVALID,
nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovement{}
dm := &nnfv1alpha3.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 := &nnfv1alpha2.NnfDataMovement{}
dm := &nnfv1alpha3.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 != nnfv1alpha2.DataMovementConditionTypeFinished {
if dm.Status.State != nnfv1alpha3.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 nnfv1alpha2.DataMovementNamespace
return nnfv1alpha3.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.20241003200819-afc04dfac421
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241009151150-de11dae021b2
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.20240912200758-f862bc773739 h1:T49ixk8TBeiYQ3CPpx463GL2gKk94dD9nXpoLBfdmqg=
github.com/NearNodeFlash/nnf-ec v0.0.1-0.20240912200758-f862bc773739/go.mod h1:oxdwMqfttOF9dabJhqrWlirCnMk8/8eyLMwl+hducjk=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241003200819-afc04dfac421 h1:sCRy1a1bqWoOgk7Sp/E2KAPd5vOxeP8Ru2qpAnYGktk=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241003200819-afc04dfac421/go.mod h1:dZD9Kx+kHdKCig6My2uA3JNU0Hy8Sz7vb4A+RZel3m4=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241009151150-de11dae021b2 h1:0aEn+rnFsta0O9bULKxz2YryF4kuHltcoBRw/Eu7kO4=
github.com/NearNodeFlash/nnf-sos v0.0.1-0.20241009151150-de11dae021b2/go.mod h1:dZD9Kx+kHdKCig6My2uA3JNU0Hy8Sz7vb4A+RZel3m4=
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