Skip to content
Open
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
11 changes: 6 additions & 5 deletions core/resource/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type (
ProvisionStart(context.Context) error
}
UnprovisionStoper interface {
UnprovisionStop(context.Context) error
UnprovisionStop(ctx context.Context, leader bool) error
}
)

Expand Down Expand Up @@ -118,7 +118,7 @@ func Unprovision(ctx context.Context, r Driver, leader bool) error {
} else {
r.Log().Infof("unprovision is disabled, the current resource provisioning state is %s", prov)
}
if err := unprovisionStop(ctx, r); err != nil {
if err := unprovisionStop(ctx, r, leader); err != nil {
return err
}
r.Log().Infof("unprovision is disabled or n/a")
Expand Down Expand Up @@ -207,7 +207,8 @@ func provisionAsFollower(ctx context.Context, t Driver) error {
}

func unprovision(ctx context.Context, t Driver, leader bool) error {
if err := unprovisionStop(ctx, t); err != nil {
t.Log().Infof("unprovision leader: %#v", leader)
if err := unprovisionStop(ctx, t, leader); err != nil {
return err
}
if err := SCSIPersistentReservationStop(ctx, t); err != nil {
Expand All @@ -222,10 +223,10 @@ func unprovision(ctx context.Context, t Driver, leader bool) error {
return nil
}

func unprovisionStop(ctx context.Context, t Driver) error {
func unprovisionStop(ctx context.Context, t Driver, leader bool) error {
switch o := t.(type) {
case UnprovisionStoper:
return o.UnprovisionStop(ctx)
return o.UnprovisionStop(ctx, leader)
case stopper:
return o.Stop(ctx)
default:
Expand Down
7 changes: 6 additions & 1 deletion drivers/resdiskdrbd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ func (t *T) Label(_ context.Context) string {
}

// UnprovisionStop is a noop to avoid calling the normal Stop before unprovision
func (t *T) UnprovisionStop(_ context.Context) error {
func (t *T) UnprovisionStop(ctx context.Context, leader bool) error {
if !leader {
t.Log().Debugf("stop for unprovision leader")
return t.Stop(ctx)
}
t.Log().Tracef("bypass stop for unprovision leader")
return nil
}

Expand Down
8 changes: 6 additions & 2 deletions drivers/resdiskzpool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ func (t *T) genHostID() error {
// because zfs can only destroy imported pools. The Unprovision func
// imports anyway, but if we don't export unnecessary export/import is
// saved.
func (t *T) UnprovisionStop(ctx context.Context) error {
t.Log().Tracef("bypass export for unprovision")
func (t *T) UnprovisionStop(ctx context.Context, leader bool) error {
if !leader {
t.Log().Debugf("stop for unprovision leader")
return t.Stop(ctx)
}
t.Log().Tracef("bypass export for unprovision on leader")
return nil
}

Expand Down
Loading