Skip to content

Commit

Permalink
add debt-ctr backoff version func (labring#3615)
Browse files Browse the repository at this point in the history
* add debt-ctr backoff version func
  • Loading branch information
nowinkeyy committed Aug 2, 2023
1 parent 49aaf13 commit 36f8008
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions controllers/account/api/v1/debt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const (
ImminentDeletionPeriod DebtStatusType = "ImminentDeletionPeriod"
FinalDeletionPeriod DebtStatusType = "FinalDeletionPeriod"

PreWarningPeriod DebtStatusType = "PreWarningPeriod"
SuspendPeriod DebtStatusType = "SuspendPeriod"
RemovedPeriod DebtStatusType = "RemovedPeriod"

DebtPrefix = "debt-"
DaySecond = 24 * 60 * 60
)
Expand Down
11 changes: 6 additions & 5 deletions controllers/account/controllers/debt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (r *DebtReconciler) reconcileDebtStatus(ctx context.Context, debt *accountv
}
//兼容老版本
default:
update = oldStatusConversion(debt)
update = newStatusConversion(debt)
}

if update {
Expand Down Expand Up @@ -284,13 +284,14 @@ func SetDebtStatus(debt *accountv1.Debt, status accountv1.DebtStatusType) bool {
return true
}

// 旧版本转换
func oldStatusConversion(debt *accountv1.Debt) bool {
func newStatusConversion(debt *accountv1.Debt) bool {
switch debt.Status.AccountDebtStatus {
case accountv1.DebtStatusNormal:
case accountv1.PreWarningPeriod:
debt.Status.AccountDebtStatus = accountv1.NormalPeriod
default:
case accountv1.SuspendPeriod:
debt.Status.AccountDebtStatus = accountv1.ImminentDeletionPeriod
case accountv1.RemovedPeriod:
debt.Status.AccountDebtStatus = accountv1.FinalDeletionPeriod
}
return true
}
Expand Down

0 comments on commit 36f8008

Please sign in to comment.