Skip to content

Commit

Permalink
elasticips: onecloud: delete op for non-managed eip
Browse files Browse the repository at this point in the history
  • Loading branch information
yousong committed May 28, 2020
1 parent 8e1b6de commit fa833e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/compute/models/elasticips.go
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ func (self *SElasticip) startEipAllocateTask(ctx context.Context, userCred mccli
}

func (self *SElasticip) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
log.Infof("Elasticip delete do nothing")
// Elasticip delete do nothing
return nil
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/compute/tasks/eip_deallocate_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (self *EipDeallocateTask) taskFail(ctx context.Context, eip *models.SElasti
func (self *EipDeallocateTask) OnInit(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
eip := obj.(*models.SElasticip)

if len(eip.ExternalId) > 0 {
if eip.ExternalId != "" {
expEip, err := eip.GetIEip()
if err != nil {
if errors.Cause(err) != cloudprovider.ErrNotFound && errors.Cause(err) != cloudprovider.ErrInvalidProvider {
Expand All @@ -66,6 +66,10 @@ func (self *EipDeallocateTask) OnInit(ctx context.Context, obj db.IStandaloneMod
}
}

if eip.IsManaged() {
// TODO clear out guestnics
}

err := eip.RealDelete(ctx, self.UserCred)
if err != nil {
msg := fmt.Sprintf("fail to delete EIP %s", err)
Expand Down

0 comments on commit fa833e6

Please sign in to comment.