Skip to content

Commit

Permalink
CA-401363 Eject host cost too long when VM is resident on slave
Browse files Browse the repository at this point in the history
Signed-off-by: Fei Su <fei.su@cloud.com>
  • Loading branch information
acefei committed Nov 4, 2024
1 parent b2ed041 commit ba812d2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 50 deletions.
82 changes: 41 additions & 41 deletions examples/pool-main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,52 @@ provider "xenserver" {
password = local.env_vars["XENSERVER_PASSWORD"]
}

resource "xenserver_sr_nfs" "nfs" {
name_label = "NFS shared storage"
name_description = "A test NFS storage repository"
version = "3"
storage_location = format("%s:%s", local.env_vars["NFS_SERVER"], local.env_vars["NFS_SERVER_PATH"])
}

data "xenserver_pif" "pif" {
device = "eth0"
}

data "xenserver_pif" "pif1" {
device = "eth3"
}
# resource "xenserver_sr_nfs" "nfs" {
# name_label = "NFS shared storage"
# name_description = "A test NFS storage repository"
# version = "3"
# storage_location = format("%s:%s", local.env_vars["NFS_SERVER"], local.env_vars["NFS_SERVER_PATH"])
# }

locals {
pif1_data = tomap({for element in data.xenserver_pif.pif1.data_items: element.uuid => element})
}
# data "xenserver_pif" "pif" {
# device = "eth0"
# }

resource "xenserver_pif_configure" "pif_update" {
for_each = local.pif1_data
uuid = each.key
interface = {
mode = "DHCP"
}
}
# data "xenserver_pif" "pif1" {
# device = "eth3"
# }

resource "xenserver_pool" "pool" {
name_label = "pool"
# default_sr = xenserver_sr_nfs.nfs.uuid
# management_network = data.xenserver_pif.pif.data_items[0].network
join_supporters = [
{
host = local.env_vars["SUPPORTER_HOST"]
username = local.env_vars["SUPPORTER_USERNAME"]
password = local.env_vars["SUPPORTER_PASSWORD"]
}
]
}
# locals {
# pif1_data = tomap({for element in data.xenserver_pif.pif1.data_items: element.uuid => element})
# }

# comment out the following block for the second run
# data "xenserver_host" "supporter" {
# is_coordinator = false
# resource "xenserver_pif_configure" "pif_update" {
# for_each = local.pif1_data
# uuid = each.key
# interface = {
# mode = "DHCP"
# }
# }

# resource "xenserver_pool" "pool" {
# name_label = "pool"
# eject_supporters = [ data.xenserver_host.supporter.data_items[1].uuid ]
# }
# # default_sr = xenserver_sr_nfs.nfs.uuid
# # management_network = data.xenserver_pif.pif.data_items[0].network
# join_supporters = [
# {
# host = local.env_vars["SUPPORTER_HOST"]
# username = local.env_vars["SUPPORTER_USERNAME"]
# password = local.env_vars["SUPPORTER_PASSWORD"]
# }
# ]
# }

# comment out the following block for the second run
data "xenserver_host" "supporter" {
is_coordinator = false
}

resource "xenserver_pool" "pool" {
name_label = "pool"
eject_supporters = [ data.xenserver_host.supporter.data_items[0].uuid ]
}
14 changes: 5 additions & 9 deletions xenserver/pool_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,13 @@ func poolEject(ctx context.Context, session *xenapi.Session, plan poolResourceMo
for _, hostUUID := range ejectSupporters {
tflog.Debug(ctx, "Ejecting pool with host: "+hostUUID)

operation := func() error {
hostRef, err := xenapi.Host.GetByUUID(session, hostUUID)
if err != nil {
return errors.New(err.Error())
}
return xenapi.Pool.Eject(session, hostRef)
hostRef, err := xenapi.Host.GetByUUID(session, hostUUID)
if err != nil {
return errors.New("unable to Get Host by UUID " + hostUUID + "!\n" + err.Error())
}

err := backoff.Retry(operation, backoff.NewExponentialBackOff())
err = xenapi.Pool.Eject(session, hostRef)
if err != nil {
return errors.New(err.Error())
return errors.New("unable to Eject Pool with host UUID " + hostUUID + "!\n" + err.Error())
}
}

Expand Down

0 comments on commit ba812d2

Please sign in to comment.