Skip to content

Commit

Permalink
minor revise for Codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Feb 3, 2023
1 parent 3ee4fce commit 8191d74
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resource/cobalt/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

/*
Alloc
Alloc alloc resource
opts struct
{
Expand Down
2 changes: 2 additions & 0 deletions resource/cobalt/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/projecteru2/core/types"
)

// GetMetricsDescription .
func (m Manager) GetMetricsDescription(ctx context.Context) ([]*plugintypes.MetricsDescription, error) {
var metricsDescriptions []*plugintypes.MetricsDescription
resps, err := call(ctx, m.plugins, func(plugin plugins.Plugin) (*plugintypes.GetMetricsDescriptionResponse, error) {
Expand All @@ -31,6 +32,7 @@ func (m Manager) GetMetricsDescription(ctx context.Context) ([]*plugintypes.Metr
return metricsDescriptions, nil
}

// GetNodeMetrics .
func (m Manager) GetNodeMetrics(ctx context.Context, node *types.Node) ([]*plugintypes.Metrics, error) {
logger := log.WithFunc("resource.cobalt.GetNodeMetrics").WithField("node", node.Name)

Expand Down
1 change: 1 addition & 0 deletions resource/cobalt/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (m Manager) RemoveNode(ctx context.Context, nodename string) error {
)
}

// GetMostIdleNode .
func (m Manager) GetMostIdleNode(ctx context.Context, nodenames []string) (string, error) {
logger := log.WithFunc("resource.cobalt.GetMostIdleNode")
if len(nodenames) == 0 {
Expand Down
2 changes: 2 additions & 0 deletions resource/cobalt/realloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/projecteru2/core/utils"
)

// Realloc .
func (m Manager) Realloc(ctx context.Context, nodename string, nodeResource *types.Resources, opts *types.Resources) (*types.Resources, *types.Resources, *types.Resources, error) {
logger := log.WithFunc("resource.cobalt.Realloc").WithField("node", nodename)
engineParams := &types.Resources{}
Expand Down Expand Up @@ -59,6 +60,7 @@ func (m Manager) Realloc(ctx context.Context, nodename string, nodeResource *typ
)
}

// RollbackRealloc .
func (m Manager) RollbackRealloc(ctx context.Context, nodename string, workloadParams *types.Resources) error {
_, _, err := m.SetNodeResourceUsage(ctx, nodename, nil, nil, []*types.Resources{workloadParams}, true, plugins.Decr)
return err
Expand Down
2 changes: 2 additions & 0 deletions resource/plugins/binary/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Plugin struct {
config coretypes.Config
}

// NewPlugin .
func NewPlugin(ctx context.Context, path string, config coretypes.Config) (*Plugin, error) {
p, err := filepath.Abs(ppath.Join(config.ResourcePlugin.Dir, path))
if err != nil {
Expand All @@ -25,6 +26,7 @@ func NewPlugin(ctx context.Context, path string, config coretypes.Config) (*Plug
return plugin, nil
}

// Name .
func (p Plugin) Name() string {
return p.name
}
3 changes: 3 additions & 0 deletions resource/plugins/binary/calculate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
plugintypes "github.com/projecteru2/core/resource/plugins/types"
)

// CalculateDeploy .
func (p Plugin) CalculateDeploy(ctx context.Context, nodename string, deployCount int, resourceRequest *plugintypes.WorkloadResourceRequest) (*plugintypes.CalculateDeployResponse, error) {
req := &binarytypes.CalculateDeployRequest{
Nodename: nodename,
Expand All @@ -17,6 +18,7 @@ func (p Plugin) CalculateDeploy(ctx context.Context, nodename string, deployCoun
return resp, p.call(ctx, CalculateDeployCommand, req, resp)
}

// CalculateRealloc .
func (p Plugin) CalculateRealloc(ctx context.Context, nodename string, resource *plugintypes.WorkloadResource, resourceRequest *plugintypes.WorkloadResourceRequest) (*plugintypes.CalculateReallocResponse, error) {
req := &binarytypes.CalculateReallocRequest{
Nodename: nodename,
Expand All @@ -27,6 +29,7 @@ func (p Plugin) CalculateRealloc(ctx context.Context, nodename string, resource
return resp, p.call(ctx, CalculateReallocCommand, req, resp)
}

// CalculateRemap .
func (p Plugin) CalculateRemap(ctx context.Context, nodename string, workloadsResource map[string]*plugintypes.WorkloadResource) (*plugintypes.CalculateRemapResponse, error) {
req := &binarytypes.CalculateRemapRequest{
Nodename: nodename,
Expand Down
3 changes: 3 additions & 0 deletions resource/plugins/cpumem/calculate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
coretypes "github.com/projecteru2/core/types"
)

// CalculateDeploy .
func (p Plugin) CalculateDeploy(ctx context.Context, nodename string, deployCount int, resourceRequest *plugintypes.WorkloadResourceRequest) (*plugintypes.CalculateDeployResponse, error) {
logger := log.WithFunc("resource.cpumem.CalculateDeploy").WithField("node", nodename)
req := &cpumemtypes.WorkloadResourceRequest{}
Expand Down Expand Up @@ -48,6 +49,7 @@ func (p Plugin) CalculateDeploy(ctx context.Context, nodename string, deployCoun
}, resp)
}

// CalculateRealloc .
func (p Plugin) CalculateRealloc(ctx context.Context, nodename string, resource *plugintypes.WorkloadResource, resourceRequest *plugintypes.WorkloadResourceRequest) (*plugintypes.CalculateReallocResponse, error) {
req := &cpumemtypes.WorkloadResourceRequest{}
if err := req.Parse(resourceRequest); err != nil {
Expand Down Expand Up @@ -137,6 +139,7 @@ func (p Plugin) CalculateRealloc(ctx context.Context, nodename string, resource
}, resp)
}

// CalculateRemap .
func (p Plugin) CalculateRemap(ctx context.Context, nodename string, workloadsResource map[string]*plugintypes.WorkloadResource) (*plugintypes.CalculateRemapResponse, error) {
resp := &plugintypes.CalculateRemapResponse{}
engineParamsMap := map[string]*cpumemtypes.EngineParams{}
Expand Down
2 changes: 2 additions & 0 deletions resource/plugins/cpumem/cpumem.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Plugin struct {
store meta.KV
}

// NewPlugin .
func NewPlugin(ctx context.Context, config coretypes.Config, t *testing.T) (*Plugin, error) {
if t == nil && len(config.Etcd.Machines) < 1 {
return nil, coretypes.ErrConfigInvaild
Expand All @@ -36,6 +37,7 @@ func NewPlugin(ctx context.Context, config coretypes.Config, t *testing.T) (*Plu
return plugin, nil
}

// Name .
func (p Plugin) Name() string {
return p.name
}
2 changes: 1 addition & 1 deletion rpc/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func toCoreResources(resources map[string][]byte) *types.Resources {
for k, v := range resources {
rp := &types.RawParams{}
if err := json.Unmarshal(v, rp); err != nil {
log.WithFunc("toCoreResources").Errorf(context.TODO(), err, "%v", string(v))
log.WithFunc("toCoreResources").Errorf(nil, err, "%v", string(v)) // nolint
continue
}
(*r)[k] = rp
Expand Down

0 comments on commit 8191d74

Please sign in to comment.