开发检查点:完成可信恢复证据与部署回归
补充部署事务恢复证据、锁归属和文件摘要校验,接入站点恢复基线,更新三数据库迁移与回归测试。
This commit is contained in:
1 parent
fb8ddd5002
commit
0e48dc9231
13 files changed
+508
-97
No files matched your search
@@ -105,6 +105,24 @@ func NewWithConfigPath(ctx context.Context, cfg config.Config, configPath string
|
||||
taskRepo := repository.NewSQLTaskRepository(db.DB, runtimeDatabaseConfig.Driver)
|
||||
transactionRepo := repository.NewSQLDeploymentTransactionRepository(db.DB, runtimeDatabaseConfig.Driver)
|
||||
deploymentService := deployment.NewServiceWithJournal(deployment.SSHFactory{Secrets: secretStore}, transactionRepo)
|
||||
remoteValidator := certificate.RemoteValidator{}
|
||||
deploymentService.VerifyRecoveryTarget = func(ctx context.Context, server deployment.Server, baseline deployment.RecoveryBaseline, committed bool) error {
|
||||
expected := baseline.PreviousFingerprint
|
||||
if committed {
|
||||
expected = baseline.ExpectedFingerprint
|
||||
}
|
||||
if expected == "" || baseline.Endpoint == "" || len(baseline.Domains) == 0 {
|
||||
return fmt.Errorf("恢复站点基线不完整")
|
||||
}
|
||||
validation, err := remoteValidator.ValidateHTTPSAt(ctx, baseline.Endpoint, server.Address, baseline.Domains)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if validation.FingerprintSHA256 != expected {
|
||||
return fmt.Errorf("站点证书指纹不符合事务基线")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := deploymentService.RecoverPending(ctx, serverRepo.GetServerByID); err != nil {
|
||||
logger.Error("恢复中断部署事务失败,已保留现场等待人工核查", "error", err)
|
||||
}
|
||||
@@ -128,7 +146,6 @@ func NewWithConfigPath(ctx context.Context, cfg config.Config, configPath string
|
||||
certificates.SetDNSAuthorizationChecker(aliyunAuthChecker)
|
||||
|
||||
notifier := notification.New(cfg.Notification, secretStore)
|
||||
remoteValidator := certificate.RemoteValidator{}
|
||||
workflow := &CertificateWorkflow{
|
||||
Certificates: certificates,
|
||||
Domains: repo,
|
||||
|
||||
@@ -290,6 +290,10 @@ func (w *CertificateWorkflow) deploy(ctx context.Context, result certificate.Iss
|
||||
server: target.Server,
|
||||
baselineFingerprint: baselineFingerprint,
|
||||
})
|
||||
targets[len(verificationTargets)-1].Baseline = deployment.RecoveryBaseline{
|
||||
Endpoint: endpoint, Domains: append([]string(nil), result.Domains...),
|
||||
PreviousFingerprint: baselineFingerprint, ExpectedFingerprint: expectedFingerprint,
|
||||
}
|
||||
}
|
||||
verification := deployment.Verification{
|
||||
Verify: func(verificationContext context.Context) error {
|
||||
|
||||
Reference in new issue
Block a user