Skip to content

Commit

Permalink
fix(hss/host_protection): modify the logic of the 'waitingForHostAvai…
Browse files Browse the repository at this point in the history
…lable' function to cover more scenarios (#5223)
  • Loading branch information
jinyangyang222 authored Jul 17, 2024
1 parent ab92f3d commit 7e66e42
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
)

const (
QueryAllEpsValue string = "all_granted_eps"
protectionVersionNull string = "hss.version.null"
hostAgentStatusOnline string = "online"
chargingModePacketCycle string = "packet_cycle"
chargingModeOnDemand string = "on_demand"
chargingModePrePaid string = "prePaid"
chargingModePostPaid string = "postPaid"
QueryAllEpsValue string = "all_granted_eps"
protectionVersionNull string = "hss.version.null"
hostAgentStatusOnline string = "online"
chargingModePacketCycle string = "packet_cycle"
chargingModeOnDemand string = "on_demand"
chargingModePrePaid string = "prePaid"
chargingModePostPaid string = "postPaid"
getProtectionHostNeedRetryMsg string = "The host cannot be found temporarily, please try again later."
)

// @API HSS GET /v5/{project_id}/host-management/hosts
Expand Down Expand Up @@ -144,7 +145,7 @@ func getProtectionHost(client *hssv5.HssClient, region, epsId, hostId string) (*

hostList := *resp.DataList
if len(hostList) == 0 {
return nil, fmt.Errorf("the host (%s) does not exist", hostId)
return nil, fmt.Errorf("%s", getProtectionHostNeedRetryMsg)
}

return &hostList[0], nil
Expand Down Expand Up @@ -240,6 +241,10 @@ func waitingForHostAvailable(ctx context.Context, client *hssv5.HssClient, regio
Refresh: func() (interface{}, string, error) {
host, err := getProtectionHost(client, region, epsId, hostId)
if err != nil {
if err.Error() == getProtectionHostNeedRetryMsg {
return nil, "PENDING", nil
}

return nil, "ERROR", err
}

Expand Down

0 comments on commit 7e66e42

Please sign in to comment.