Skip to content

Commit

Permalink
DRA: Fix code format
Browse files Browse the repository at this point in the history
Signed-off-by: cyclinder <[email protected]>
  • Loading branch information
cyclinder committed Mar 28, 2024
1 parent 7ac5d1e commit d75b9c1
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/codespell-ignorewords
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ cyclinder
shouldnot
Requestor
passt
ro
8 changes: 8 additions & 0 deletions charts/spiderpool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ helm install spiderpool spiderpool/spiderpool --wait --namespace kube-system \
| `multus.multusCNI.log.logLevel` | the multus-CNI daemonset pod log level | `debug` |
| `multus.multusCNI.log.logFile` | the multus-CNI daemonset pod log file | `/var/log/multus.log` |

### dra parameters

| Name | Description | Value |
| ----------------- | --------------------- | -------------- |
| `dra.enabled` | to enable dra feature | `false` |
| `dra.cdiRoot` | the dir of cdi root | `/var/run/cdi` |
| `dra.libraryPath` | | `""` |

### plugins parameters

| Name | Description | Value |
Expand Down
3 changes: 3 additions & 0 deletions pkg/dra/dra-controller/controller.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2024 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0

package draController

import (
Expand Down
5 changes: 4 additions & 1 deletion pkg/dra/dra-controller/driver.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2024 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0

package draController

import (
Expand Down Expand Up @@ -27,7 +30,7 @@ func (d driver) GetClassParameters(ctx context.Context, class *resourcev1alpha2.

func (d driver) GetClaimParameters(ctx context.Context, claim *resourcev1alpha2.ResourceClaim, class *resourcev1alpha2.ResourceClass, classParameters interface{}) (interface{}, error) {
if claim.Spec.ParametersRef == nil {
// TODO: we can
// TODO(@cyclinder): we can give it a default ClaimParameterSpec?
return &v2beta1.ClaimParameterSpec{}, nil
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/dra/dra-plugin/cdi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2024 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0

package draPlugin

import (
Expand Down Expand Up @@ -80,7 +83,7 @@ func (cdi *CDIHandler) GetClaimDevices(claimUID string) []string {

func (cdi *CDIHandler) CreateClaimSpecFile(claimUID string, scp *v2beta1.SpiderClaimParameter) error {
cdiSpec := cdispec.Spec{
// TODO(@cyclinder): should be make it to configureable?
// TODO(@cyclinder): should be make it to configurable?
Version: cdiapi.CurrentVersion,
Kind: cdi.cdiKind(),
Devices: []cdispec.Device{{
Expand Down Expand Up @@ -118,6 +121,7 @@ func (cdi *CDIHandler) DeleteClaimSpecFile(claimUID string) error {
return cdi.registry.SpecDB().RemoveSpec(specName + ".yaml")
}

// nolint: all
func (cdi *CDIHandler) getContaineEdits(claim string, rdma bool) cdispec.ContainerEdits {
soName := path.Base(cdi.so)
ce := cdispec.ContainerEdits{
Expand Down
10 changes: 7 additions & 3 deletions pkg/dra/dra-plugin/device_state.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// Copyright 2024 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0

package draPlugin

import (
"context"
"fmt"
"os"
"sync"

"github.com/spidernet-io/spiderpool/pkg/constant"
v2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1"
"github.com/spidernet-io/spiderpool/pkg/lock"
"go.uber.org/zap"
)

type NodeDeviceState struct {
sync.Mutex
lock.RWMutex
cdi *CDIHandler
preparedClaims map[string]struct{}
}
Expand Down Expand Up @@ -63,7 +66,8 @@ func (nds *NodeDeviceState) UnPrepare(ctx context.Context, claimUID string) erro
nds.Lock()
defer nds.Unlock()

if _, ok := nds.preparedClaims[claimUID]; ok {
_, ok := nds.preparedClaims[claimUID]
if ok {
delete(nds.preparedClaims, claimUID)
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/dra/dra-plugin/driver.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright 2024 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0
package draPlugin

import (
"context"
"fmt"
"sync"

clientset "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned"
"github.com/spidernet-io/spiderpool/pkg/lock"
"go.uber.org/zap"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand All @@ -15,7 +17,7 @@ import (
)

type driver struct {
sync.Mutex
lock.RWMutex
logger *zap.Logger
State *NodeDeviceState
K8sClientSet kubernetes.Interface
Expand Down
2 changes: 2 additions & 0 deletions pkg/dra/dra-plugin/plugin.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2024 Authors of spidernet-io
// SPDX-License-Identifier: Apache-2.0
package draPlugin

import (
Expand Down

0 comments on commit d75b9c1

Please sign in to comment.