Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 77b855d

Browse files
author
Vincent Planchenault
committed
minor post pull fixes
1 parent c2ba76c commit 77b855d

13 files changed

Lines changed: 28 additions & 54 deletions

File tree

lib/server/listeners/cluster.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"fmt"
2222

23-
"github.com/CS-SI/SafeScale/v21/lib/server/resources/operations"
2423
googleprotobuf "github.com/golang/protobuf/ptypes/empty"
2524
"google.golang.org/grpc/codes"
2625
"google.golang.org/grpc/status"
@@ -29,6 +28,7 @@ import (
2928
"github.com/CS-SI/SafeScale/v21/lib/server/resources"
3029
clusterfactory "github.com/CS-SI/SafeScale/v21/lib/server/resources/factories/cluster"
3130
hostfactory "github.com/CS-SI/SafeScale/v21/lib/server/resources/factories/host"
31+
"github.com/CS-SI/SafeScale/v21/lib/server/resources/operations"
3232
"github.com/CS-SI/SafeScale/v21/lib/server/resources/operations/converters"
3333
propertiesv3 "github.com/CS-SI/SafeScale/v21/lib/server/resources/properties/v3"
3434
srvutils "github.com/CS-SI/SafeScale/v21/lib/server/utils"
@@ -196,12 +196,6 @@ func (s *ClusterListener) Inspect(ctx context.Context, in *protocol.Reference) (
196196
if xerr != nil {
197197
return nil, xerr
198198
}
199-
defer func() {
200-
derr := instance.Released()
201-
if derr != nil {
202-
logrus.Warn(derr)
203-
}
204-
}()
205199

206200
return instance.ToProtocol()
207201
}

lib/server/listeners/volume.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ import (
2020
"context"
2121
"fmt"
2222

23-
"github.com/CS-SI/SafeScale/v21/lib/server/resources/abstract"
24-
volumefactory "github.com/CS-SI/SafeScale/v21/lib/server/resources/factories/volume"
25-
"github.com/CS-SI/SafeScale/v21/lib/utils/debug/tracing"
26-
"github.com/sirupsen/logrus"
27-
2823
"github.com/CS-SI/SafeScale/v21/lib/protocol"
2924
"github.com/CS-SI/SafeScale/v21/lib/server/handlers"
25+
"github.com/CS-SI/SafeScale/v21/lib/server/resources/abstract"
3026
"github.com/CS-SI/SafeScale/v21/lib/server/resources/enums/volumespeed"
3127
volumefactory "github.com/CS-SI/SafeScale/v21/lib/server/resources/factories/volume"
3228
srvutils "github.com/CS-SI/SafeScale/v21/lib/server/utils"
@@ -302,20 +298,13 @@ func (s *VolumeListener) Inspect(ctx context.Context, in *protocol.Reference) (_
302298
defer tracer.Exiting()
303299
defer fail.OnExitLogError(&err, tracer.TraceMessage())
304300

305-
volumeInstance, xerr := volumefactory.Load(job.Service(), ref)
301+
volumeInstance, xerr := volumefactory.Load(job.Context(), job.Service(), ref)
306302
if xerr != nil {
307303
if _, ok := xerr.(*fail.ErrNotFound); ok {
308304
return nil, abstract.ResourceNotFoundError("volume", ref)
309305
}
310306
return nil, xerr
311307
}
312308

313-
defer func() {
314-
issue := volumeInstance.Released()
315-
if issue != nil {
316-
logrus.Warn(issue)
317-
}
318-
}()
319-
320-
return volumeInstance.ToProtocol()
309+
return volumeInstance.ToProtocol(job.Context())
321310
}

lib/server/resources/factories/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ func New(ctx context.Context, svc iaas.Service) (_ resources.Cluster, ferr fail.
5757

5858
// Load loads metadata of a cluster and returns an instance of resources.Cluster
5959
func Load(ctx context.Context, svc iaas.Service, name string) (_ resources.Cluster, ferr fail.Error) {
60-
return operations.LoadCluster(ctx, svc, name, operations.WithReloadOption)
60+
return operations.LoadCluster(ctx, svc, name)
6161
}

lib/server/resources/factories/host/host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ func New(svc iaas.Service) (_ resources.Host, err fail.Error) {
6262

6363
// Load loads the metadata of host and returns an instance of resources.Host
6464
func Load(ctx context.Context, svc iaas.Service, ref string) (_ resources.Host, err fail.Error) {
65-
return operations.LoadHost(ctx, svc, ref, operations.WithReloadOption)
65+
return operations.LoadHost(ctx, svc, ref)
6666
}

lib/server/resources/factories/share/share.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ func New(svc iaas.Service) (resources.Share, fail.Error) {
3535

3636
// Load loads the metadata of a share and returns an instance of resources.Share
3737
func Load(ctx context.Context, svc iaas.Service, ref string) (resources.Share, fail.Error) {
38-
return operations.LoadShare(ctx, svc, ref, operations.WithReloadOption)
38+
return operations.LoadShare(ctx, svc, ref)
3939
}

lib/server/resources/factories/volume/volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ func New(svc iaas.Service) (resources.Volume, fail.Error) {
3232

3333
// Load loads the metadata of a volume and returns an instance of resources.Volume
3434
func Load(ctx context.Context, svc iaas.Service, ref string) (resources.Volume, fail.Error) {
35-
return operations.LoadVolume(ctx, svc, ref, operations.WithReloadOption)
35+
return operations.LoadVolume(ctx, svc, ref)
3636
}

lib/server/resources/operations/cluster.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (instance *Cluster) startRandomDelayGenerator(ctx context.Context, min, max
149149
}
150150

151151
// LoadCluster loads cluster information from metadata
152-
func LoadCluster(ctx context.Context, svc iaas.Service, name string, options ...data.ImmutableKeyValue) (_ resources.Cluster, ferr fail.Error) {
152+
func LoadCluster(ctx context.Context, svc iaas.Service, name string) (_ resources.Cluster, ferr fail.Error) {
153153
defer fail.OnPanic(&ferr)
154154

155155
if svc == nil {
@@ -1194,7 +1194,7 @@ func (instance *Cluster) AddNodes(ctx context.Context, count uint, def abstract.
11941194
for _, v := range nodes {
11951195
v := v
11961196
_, derr = dtg.Start(
1197-
instance.taskDeleteNode, taskDeleteNodeParameters{node: v, nodeLoadMethod: WithoutReloadOption},
1197+
instance.taskDeleteNode, taskDeleteNodeParameters{node: v},
11981198
)
11991199
if derr != nil {
12001200
abErr := dtg.AbortWithCause(derr)
@@ -1386,7 +1386,7 @@ func (instance *Cluster) DeleteSpecificNode(ctx context.Context, hostID string,
13861386
return xerr
13871387
}
13881388

1389-
xerr = instance.deleteNode(task.Context(), node, selectedMaster.(*Host), WithReloadOption)
1389+
xerr = instance.deleteNode(task.Context(), node, selectedMaster.(*Host))
13901390
if xerr != nil {
13911391
return xerr
13921392
}
@@ -2037,7 +2037,7 @@ func (instance *Cluster) deleteMaster(ctx context.Context, host resources.Host)
20372037
}
20382038

20392039
// deleteNode deletes a node
2040-
func (instance *Cluster) deleteNode(ctx context.Context, node *propertiesv3.ClusterNode, master *Host, loadHostMethod data.ImmutableKeyValue) (ferr fail.Error) {
2040+
func (instance *Cluster) deleteNode(ctx context.Context, node *propertiesv3.ClusterNode, master *Host) (ferr fail.Error) {
20412041
task, xerr := concurrency.TaskFromContextOrVoid(ctx)
20422042
xerr = debug.InjectPlannedFail(xerr)
20432043
if xerr != nil {
@@ -2114,7 +2114,7 @@ func (instance *Cluster) deleteNode(ctx context.Context, node *propertiesv3.Clus
21142114
}()
21152115

21162116
// Deletes node
2117-
hostInstance, xerr := LoadHost(task.Context(), instance.Service(), nodeRef, loadHostMethod)
2117+
hostInstance, xerr := LoadHost(task.Context(), instance.Service(), nodeRef)
21182118
xerr = debug.InjectPlannedFail(xerr)
21192119
if xerr != nil {
21202120
switch xerr.(type) {
@@ -2312,7 +2312,7 @@ func (instance *Cluster) delete(ctx context.Context) (ferr fail.Error) {
23122312

23132313
completedOptions = append(completedOptions, concurrency.AmendID(fmt.Sprintf("/node/%s/delete", n.Name)))
23142314
_, xerr = tg.Start(
2315-
instance.taskDeleteNode, taskDeleteNodeParameters{node: n, nodeLoadMethod: WithoutReloadOption},
2315+
instance.taskDeleteNode, taskDeleteNodeParameters{node: n},
23162316
completedOptions...,
23172317
)
23182318
xerr = debug.InjectPlannedFail(xerr)
@@ -2338,7 +2338,7 @@ func (instance *Cluster) delete(ctx context.Context) (ferr fail.Error) {
23382338

23392339
completedOptions = append(completedOptions, concurrency.AmendID(fmt.Sprintf("/master/%s/delete", n.Name)))
23402340
_, xerr := tg.Start(
2341-
instance.taskDeleteMaster, taskDeleteNodeParameters{node: n, nodeLoadMethod: WithoutReloadOption},
2341+
instance.taskDeleteMaster, taskDeleteNodeParameters{node: n},
23422342
completedOptions...,
23432343
)
23442344
xerr = debug.InjectPlannedFail(xerr)
@@ -2396,7 +2396,7 @@ func (instance *Cluster) delete(ctx context.Context) (ferr fail.Error) {
23962396

23972397
for _, v := range all {
23982398
_, xerr = tg.Start(
2399-
instance.taskDeleteNode, taskDeleteNodeParameters{node: v, nodeLoadMethod: WithoutReloadOption},
2399+
instance.taskDeleteNode, taskDeleteNodeParameters{node: v},
24002400
concurrency.InheritParentIDOption, concurrency.AmendID(fmt.Sprintf("/node/%s/delete", v.Name)),
24012401
)
24022402
xerr = debug.InjectPlannedFail(xerr)
@@ -3407,7 +3407,7 @@ func (instance *Cluster) Shrink(ctx context.Context, count uint) (_ []*propertie
34073407
for _, v := range removedNodes {
34083408
_, xerr = tg.Start(
34093409
instance.taskDeleteNode,
3410-
taskDeleteNodeParameters{node: v, nodeLoadMethod: WithReloadOption, master: selectedMaster.(*Host)},
3410+
taskDeleteNodeParameters{node: v, master: selectedMaster.(*Host)},
34113411
concurrency.InheritParentIDOption, concurrency.AmendID(fmt.Sprintf("/node/%s/delete", v.Name)),
34123412
)
34133413
xerr = debug.InjectPlannedFail(xerr)

lib/server/resources/operations/clustertasks.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,9 +2845,8 @@ func (instance *Cluster) taskDeleteNodeOnFailure(task concurrency.Task, params c
28452845
}
28462846

28472847
type taskDeleteNodeParameters struct {
2848-
node *propertiesv3.ClusterNode
2849-
nodeLoadMethod data.ImmutableKeyValue
2850-
master *Host
2848+
node *propertiesv3.ClusterNode
2849+
master *Host
28512850
}
28522851

28532852
// taskDeleteNode deletes one node
@@ -2876,9 +2875,6 @@ func (instance *Cluster) taskDeleteNode(task concurrency.Task, params concurrenc
28762875
if p.node.ID == "" && p.node.Name == "" {
28772876
return nil, fail.InvalidParameterError("params.node.ID|params.node.Name", "ID or Name must be set")
28782877
}
2879-
if p.nodeLoadMethod != WithoutReloadOption && p.nodeLoadMethod != WithReloadOption {
2880-
return nil, fail.InvalidParameterError("params.nodeLoadMethod", "must be 'WithoutReloadOption' or 'WithReloadOption'")
2881-
}
28822878
nodeName := p.node.Name
28832879
if nodeName == "" {
28842880
nodeName = p.node.ID
@@ -2900,7 +2896,7 @@ func (instance *Cluster) taskDeleteNode(task concurrency.Task, params concurrenc
29002896
}()
29012897

29022898
logrus.Debugf("Deleting Node '%s'", nodeName)
2903-
xerr = instance.deleteNode(task.Context(), p.node, p.master, p.nodeLoadMethod)
2899+
xerr = instance.deleteNode(task.Context(), p.node, p.master)
29042900
xerr = debug.InjectPlannedFail(xerr)
29052901
if xerr != nil {
29062902
switch xerr.(type) {
@@ -2952,7 +2948,7 @@ func (instance *Cluster) taskDeleteMaster(task concurrency.Task, params concurre
29522948
return nil, fail.AbortedError(lerr, "parent task killed")
29532949
}
29542950

2955-
host, xerr := LoadHost(task.Context(), instance.Service(), nodeName, WithoutReloadOption)
2951+
host, xerr := LoadHost(task.Context(), instance.Service(), nodeName)
29562952
xerr = debug.InjectPlannedFail(xerr)
29572953
if xerr != nil {
29582954
switch xerr.(type) {

lib/server/resources/operations/host.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func NewHost(svc iaas.Service) (_ *Host, ferr fail.Error) {
105105
}
106106

107107
// LoadHost ...
108-
func LoadHost(ctx context.Context, svc iaas.Service, ref string, options ...data.ImmutableKeyValue) (_ resources.Host, ferr fail.Error) {
108+
func LoadHost(ctx context.Context, svc iaas.Service, ref string) (_ resources.Host, ferr fail.Error) {
109109
defer fail.OnPanic(&ferr)
110110

111111
if svc == nil {
@@ -2314,7 +2314,7 @@ func (instance *Host) RelaxedDeleteHost(ctx context.Context) (ferr fail.Error) {
23142314
if count > 0 {
23152315
// clients found, checks if these clients already exists...
23162316
for _, hostID := range hostShare.ClientsByID {
2317-
instance, inErr := LoadHost(task.Context(), svc, hostID, WithoutReloadOption)
2317+
instance, inErr := LoadHost(task.Context(), svc, hostID)
23182318
if inErr != nil {
23192319
debug.IgnoreError(inErr)
23202320
continue

lib/server/resources/operations/share.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func NewShare(svc iaas.Service) (resources.Share, fail.Error) {
140140
// If error is fail.ErrNotFound return this error
141141
// In case of any other error, abort the retry to propagate the error
142142
// If retry times out, return fail.ErrTimeout
143-
func LoadShare(svc iaas.Service, ref string) (shareInstance resources.Share, ferr fail.Error) {
143+
func LoadShare(ctx context.Context, svc iaas.Service, ref string) (_ resources.Share, ferr fail.Error) {
144144
defer fail.OnPanic(&ferr)
145145

146146
if svc == nil {
@@ -150,7 +150,7 @@ func LoadShare(svc iaas.Service, ref string) (shareInstance resources.Share, fer
150150
return nil, fail.InvalidParameterError("ref", "cannot be empty string")
151151
}
152152

153-
cacheMissLoader := func() (data.Identifiable, fail.Error) { return onShareCacheMiss(svc, ref) }
153+
cacheMissLoader := func() (data.Identifiable, fail.Error) { return onShareCacheMiss(ctx, svc, ref) }
154154
anon, xerr := cacheMissLoader()
155155
if xerr != nil {
156156
return nil, xerr
@@ -169,7 +169,7 @@ func LoadShare(svc iaas.Service, ref string) (shareInstance resources.Share, fer
169169
}
170170

171171
// onShareCacheMiss is called when there is no instance in cache of Share 'ref'
172-
func onShareCacheMiss(svc iaas.Service, ref string) (data.Identifiable, fail.Error) {
172+
func onShareCacheMiss(ctx context.Context, svc iaas.Service, ref string) (data.Identifiable, fail.Error) {
173173
shareInstance, innerXErr := NewShare(svc)
174174
if innerXErr != nil {
175175
return nil, innerXErr

0 commit comments

Comments
 (0)