mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-01 15:39:35 +08:00
chore: improve error logs
This commit is contained in:
@@ -109,12 +109,12 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
// 根据部署资源类型决定部署方式
|
||||
switch d.config.ResourceType {
|
||||
case RESOURCE_TYPE_LOADBALANCER:
|
||||
if err := d.deployToLoadbalancer(ctx, upres.ExtendedData["certIdentifier"].(string)); err != nil {
|
||||
if err := d.deployToLoadbalancer(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case RESOURCE_TYPE_LISTENER:
|
||||
if err := d.deployToListener(ctx, upres.ExtendedData["certIdentifier"].(string)); err != nil {
|
||||
if err := d.deployToListener(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ func (d *SSLDeployerProvider) deployToCloudNative(ctx context.Context, certPEM s
|
||||
TlsMin: getDomainResp.Body.Data.TlsMin,
|
||||
TlsMax: getDomainResp.Body.Data.TlsMax,
|
||||
TlsCipherSuitesConfig: getDomainResp.Body.Data.TlsCipherSuitesConfig,
|
||||
CertIdentifier: tea.String(upres.ExtendedData["certIdentifier"].(string)),
|
||||
CertIdentifier: tea.String(upres.ExtendedData["CertIdentifier"].(string)),
|
||||
}
|
||||
updateDomainResp, err := d.sdkClients.CloudNativeAPIGateway.UpdateDomain(tea.String(domainId), updateDomainReq)
|
||||
d.logger.Debug("sdk request 'apig.UpdateDomain'", slog.Any("domainId", domainId), slog.Any("request", updateDomainReq), slog.Any("response", updateDomainResp))
|
||||
|
||||
@@ -145,14 +145,14 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
}
|
||||
|
||||
if describeDeploymentJobResp.Body.Status == nil || *describeDeploymentJobResp.Body.Status == "editing" {
|
||||
return nil, errors.New("unexpected deployment job status")
|
||||
return nil, errors.New("unexpected aliyun deployment job status")
|
||||
}
|
||||
|
||||
if *describeDeploymentJobResp.Body.Status == "success" || *describeDeploymentJobResp.Body.Status == "error" {
|
||||
break
|
||||
}
|
||||
|
||||
d.logger.Info("waiting for deployment job completion ...")
|
||||
d.logger.Info("waiting for aliyun deployment job completion ...")
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
|
||||
@@ -94,12 +94,12 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
// 根据部署资源类型决定部署方式
|
||||
switch d.config.ResourceType {
|
||||
case RESOURCE_TYPE_ACCELERATOR:
|
||||
if err := d.deployToAccelerator(ctx, upres.ExtendedData["certIdentifier"].(string)); err != nil {
|
||||
if err := d.deployToAccelerator(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case RESOURCE_TYPE_LISTENER:
|
||||
if err := d.deployToListener(ctx, upres.ExtendedData["certIdentifier"].(string)); err != nil {
|
||||
if err := d.deployToListener(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -97,12 +97,12 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
// 根据部署资源类型决定部署方式
|
||||
switch d.config.ResourceType {
|
||||
case RESOURCE_TYPE_LOADBALANCER:
|
||||
if err := d.deployToLoadbalancer(ctx, upres.ExtendedData["certIdentifier"].(string)); err != nil {
|
||||
if err := d.deployToLoadbalancer(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case RESOURCE_TYPE_LISTENER:
|
||||
if err := d.deployToListener(ctx, upres.ExtendedData["certIdentifier"].(string)); err != nil {
|
||||
if err := d.deployToListener(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ func (d *SSLDeployerProvider) deployToWAF3(ctx context.Context, certPEM string,
|
||||
InstanceId: tea.String(d.config.InstanceId),
|
||||
RegionId: tea.String(d.config.Region),
|
||||
Domain: tea.String(d.config.Domain),
|
||||
Listen: &aliwaf.ModifyDomainRequestListen{CertId: tea.String(upres.ExtendedData["certIdentifier"].(string))},
|
||||
Listen: &aliwaf.ModifyDomainRequestListen{CertId: tea.String(upres.ExtendedData["CertIdentifier"].(string))},
|
||||
Redirect: &aliwaf.ModifyDomainRequestRedirect{Loadbalance: tea.String("iphash")},
|
||||
}
|
||||
modifyDomainReq = assign(modifyDomainReq, describeDomainDetailResp.Body)
|
||||
|
||||
@@ -178,7 +178,7 @@ func (d *SSLDeployerProvider) deployViaSslService(ctx context.Context, cloudCert
|
||||
|
||||
var runningCount, succeededCount, failedCount, totalCount int64
|
||||
if describeHostDeployRecordDetailResp.Response.TotalCount == nil {
|
||||
return errors.New("unexpected deployment job status")
|
||||
return errors.New("unexpected tencentcloud deployment job status")
|
||||
} else {
|
||||
if describeHostDeployRecordDetailResp.Response.RunningTotalCount != nil {
|
||||
runningCount = *describeHostDeployRecordDetailResp.Response.RunningTotalCount
|
||||
@@ -195,13 +195,13 @@ func (d *SSLDeployerProvider) deployViaSslService(ctx context.Context, cloudCert
|
||||
|
||||
if succeededCount+failedCount == totalCount {
|
||||
if failedCount > 0 {
|
||||
return fmt.Errorf("deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
return fmt.Errorf("tencentcloud deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
d.logger.Info(fmt.Sprintf("waiting for deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
d.logger.Info(fmt.Sprintf("waiting for tencentcloud deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
@@ -321,12 +321,12 @@ func (d *SSLDeployerProvider) deployToRuleDomain(ctx context.Context, cloudCertI
|
||||
}
|
||||
|
||||
if describeTaskStatusResp.Response.Status == nil || *describeTaskStatusResp.Response.Status == 1 {
|
||||
return errors.New("unexpected task status")
|
||||
return errors.New("unexpected tencentcloud task status")
|
||||
} else if *describeTaskStatusResp.Response.Status == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
d.logger.Info("waiting for task completion ...")
|
||||
d.logger.Info("waiting for tencentcloud task completion ...")
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
@@ -383,12 +383,12 @@ func (d *SSLDeployerProvider) modifyListenerCertificate(ctx context.Context, clo
|
||||
}
|
||||
|
||||
if describeTaskStatusResp.Response.Status == nil || *describeTaskStatusResp.Response.Status == 1 {
|
||||
return errors.New("unexpected task status")
|
||||
return errors.New("unexpected tencentcloud task status")
|
||||
} else if *describeTaskStatusResp.Response.Status == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
d.logger.Info("waiting for task completion ...")
|
||||
d.logger.Info("waiting for tencentcloud task completion ...")
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
|
||||
var runningCount, succeededCount, failedCount, totalCount int64
|
||||
if describeHostDeployRecordDetailResp.Response.TotalCount == nil {
|
||||
return nil, errors.New("unexpected deployment job status")
|
||||
return nil, errors.New("unexpected tencentcloud deployment job status")
|
||||
} else {
|
||||
if describeHostDeployRecordDetailResp.Response.RunningTotalCount != nil {
|
||||
runningCount = *describeHostDeployRecordDetailResp.Response.RunningTotalCount
|
||||
@@ -142,13 +142,13 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
|
||||
if succeededCount+failedCount == totalCount {
|
||||
if failedCount > 0 {
|
||||
return nil, fmt.Errorf("deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
return nil, fmt.Errorf("tencentcloud deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
d.logger.Info(fmt.Sprintf("waiting for deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
d.logger.Info(fmt.Sprintf("waiting for tencentcloud deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
|
||||
var runningCount, succeededCount, failedCount, totalCount int64
|
||||
if describeHostDeployRecordDetailResp.Response.TotalCount == nil {
|
||||
return nil, errors.New("unexpected deployment job status")
|
||||
return nil, errors.New("unexpected tencentcloud deployment job status")
|
||||
} else {
|
||||
if describeHostDeployRecordDetailResp.Response.RunningTotalCount != nil {
|
||||
runningCount = *describeHostDeployRecordDetailResp.Response.RunningTotalCount
|
||||
@@ -143,13 +143,13 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
|
||||
if succeededCount+failedCount == totalCount {
|
||||
if failedCount > 0 {
|
||||
return nil, fmt.Errorf("deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
return nil, fmt.Errorf("tencentcloud deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
d.logger.Info(fmt.Sprintf("waiting for deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
d.logger.Info(fmt.Sprintf("waiting for tencentcloud deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ func (d *SSLDeployerProvider) executeUpdateCertificateInstance(ctx context.Conte
|
||||
|
||||
var runningCount, succeededCount, failedCount, totalCount int64
|
||||
if describeHostUpdateRecordDetailResp.Response.TotalCount == nil {
|
||||
return errors.New("unexpected deployment job status")
|
||||
return errors.New("unexpected tencentcloud deployment job status")
|
||||
} else {
|
||||
if describeHostUpdateRecordDetailResp.Response.RunningTotalCount != nil {
|
||||
runningCount = *describeHostUpdateRecordDetailResp.Response.RunningTotalCount
|
||||
@@ -176,13 +176,13 @@ func (d *SSLDeployerProvider) executeUpdateCertificateInstance(ctx context.Conte
|
||||
|
||||
if succeededCount+failedCount == totalCount {
|
||||
if failedCount > 0 {
|
||||
return fmt.Errorf("deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
return fmt.Errorf("tencentcloud deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
d.logger.Info(fmt.Sprintf("waiting for deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
d.logger.Info(fmt.Sprintf("waiting for tencentcloud deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ func (d *SSLDeployerProvider) executeUploadUpdateCertificateInstance(ctx context
|
||||
|
||||
var runningCount, succeededCount, failedCount, totalCount int64
|
||||
if describeHostUploadUpdateRecordDetailResp.Response.DeployRecordDetail == nil {
|
||||
return errors.New("unexpected deployment job status")
|
||||
return errors.New("unexpected tencentcloud deployment job status")
|
||||
} else {
|
||||
for _, record := range describeHostUploadUpdateRecordDetailResp.Response.DeployRecordDetail {
|
||||
if record.RunningTotalCount != nil {
|
||||
@@ -261,13 +261,13 @@ func (d *SSLDeployerProvider) executeUploadUpdateCertificateInstance(ctx context
|
||||
|
||||
if succeededCount+failedCount == totalCount {
|
||||
if failedCount > 0 {
|
||||
return fmt.Errorf("deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
return fmt.Errorf("tencentcloud deployment job failed (succeeded: %d, failed: %d, total: %d)", succeededCount, failedCount, totalCount)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
d.logger.Info(fmt.Sprintf("waiting for deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
d.logger.Info(fmt.Sprintf("waiting for tencentcloud deployment job completion (running: %d, succeeded: %d, failed: %d, total: %d) ...", runningCount, succeededCount, failedCount, totalCount))
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
|
||||
@@ -211,12 +211,12 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
}
|
||||
|
||||
if getDeploymentTaskDetailResp.Status == "failed" {
|
||||
return nil, errors.New("unexpected deployment task status")
|
||||
return nil, errors.New("unexpected wangsu deployment task status")
|
||||
} else if getDeploymentTaskDetailResp.Status == "succeeded" || getDeploymentTaskDetailResp.FinishTime != "" {
|
||||
break
|
||||
}
|
||||
|
||||
d.logger.Info(fmt.Sprintf("waiting for deployment task completion (current status: %s) ...", getDeploymentTaskDetailResp.Status))
|
||||
d.logger.Info(fmt.Sprintf("waiting for wangsu deployment task completion (current status: %s) ...", getDeploymentTaskDetailResp.Status))
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ func (m *SSLManagerProvider) Upload(ctx context.Context, certPEM string, privkey
|
||||
CertId: fmt.Sprintf("%d", tea.Int64Value(certOrder.CertificateId)),
|
||||
CertName: *certOrder.Name,
|
||||
ExtendedData: map[string]any{
|
||||
"instanceId": tea.StringValue(getUserCertificateDetailResp.Body.InstanceId),
|
||||
"certIdentifier": tea.StringValue(getUserCertificateDetailResp.Body.CertIdentifier),
|
||||
"InstanceId": tea.StringValue(getUserCertificateDetailResp.Body.InstanceId),
|
||||
"CertIdentifier": tea.StringValue(getUserCertificateDetailResp.Body.CertIdentifier),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@@ -184,8 +184,8 @@ func (m *SSLManagerProvider) Upload(ctx context.Context, certPEM string, privkey
|
||||
CertId: fmt.Sprintf("%d", tea.Int64Value(getUserCertificateDetailResp.Body.Id)),
|
||||
CertName: certName,
|
||||
ExtendedData: map[string]any{
|
||||
"instanceId": tea.StringValue(getUserCertificateDetailResp.Body.InstanceId),
|
||||
"certIdentifier": tea.StringValue(getUserCertificateDetailResp.Body.CertIdentifier),
|
||||
"InstanceId": tea.StringValue(getUserCertificateDetailResp.Body.InstanceId),
|
||||
"CertIdentifier": tea.StringValue(getUserCertificateDetailResp.Body.CertIdentifier),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func (m *SSLManagerProvider) Upload(ctx context.Context, certPEM string, privkey
|
||||
CertId: fmt.Sprintf("%d", uploadNormalCertificateResp.CertificateID),
|
||||
CertName: certName,
|
||||
ExtendedData: map[string]any{
|
||||
"resourceId": uploadNormalCertificateResp.LongResourceID,
|
||||
"ResourceId": uploadNormalCertificateResp.LongResourceID,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@@ -215,7 +215,7 @@ func (m *SSLManagerProvider) findCertIfExists(ctx context.Context, certPEM strin
|
||||
CertId: fmt.Sprintf("%d", certItem.CertificateID),
|
||||
CertName: certItem.Name,
|
||||
ExtendedData: map[string]any{
|
||||
"resourceId": certItem.CertificateSN,
|
||||
"ResourceId": certItem.CertificateSN,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user