Skip to content

Commit 0c2041f

Browse files
authored
Merge branch 'develop' into mark_ing_as_failed
2 parents 62b2824 + 995a798 commit 0c2041f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

swiftwave_service/worker/process_ssl_request.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
4141
return nil
4242
}
4343
_ = domain.UpdateSSLStatus(ctx, dbWithoutTx, core.DomainSSLStatusFailed)
44+
logger.CronJobLoggerError.Println("Domain", domain.Name, "is not pointing to this server. Marking SSL Issue as failed")
4445
return nil
4546
}
4647
// generate private key [if not found]
@@ -52,6 +53,7 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
5253
domain.SSLPrivateKey = privateKey
5354
err = domain.Update(ctx, dbWithoutTx)
5455
if err != nil {
56+
logger.CronJobLoggerError.Println("Failed to update domain", domain.Name, "with private key.", err.Error(), "\nWill retry later")
5557
return err
5658
}
5759
}
@@ -72,16 +74,19 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
7274
// update domain
7375
err = domain.Update(ctx, dbWithoutTx)
7476
if err != nil {
77+
logger.CronJobLoggerError.Println("Failed to update domain", domain.Name, "with SSL status", domain.SSLStatus, err.Error(), "\nWill retry later")
7578
return err
7679
}
7780
// fetch all proxy servers
7881
proxyServers, err := core.FetchProxyActiveServers(&m.ServiceManager.DbClient)
7982
if err != nil {
83+
logger.CronJobLoggerError.Println("Failed to fetch proxy servers while generating SSL certificate", err.Error(), "\nWill retry later")
8084
return err
8185
}
8286
// fetch all haproxy managers
8387
haproxyManagers, err := manager.HAProxyClients(context.Background(), proxyServers)
8488
if err != nil {
89+
logger.CronJobLoggerError.Println("Failed to fetch haproxy managers while generating SSL certificate", err.Error())
8590
return err
8691
}
8792
// map of server ip and transaction id
@@ -92,13 +97,15 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
9297
// generate a new transaction id for haproxy
9398
transactionId, err := haproxyManager.FetchNewTransactionId()
9499
if err != nil {
100+
logger.CronJobLoggerError.Println("Failed to fetch new transaction id while generating SSL certificate", err.Error(), "\nWill retry later")
95101
return err
96102
}
97103
// add to map
98104
transactionIdMap[haproxyManager] = transactionId
99105
// upload certificate to haproxy
100106
err = haproxyManager.UpdateSSL(transactionId, domain.Name, []byte(domain.SSLPrivateKey), []byte(domain.SSLFullChain))
101107
if err != nil {
108+
logger.CronJobLoggerError.Println("Failed to update SSL certificate while generating SSL certificate", err.Error(), "\nWill retry later")
102109
isFailed = true
103110
break
104111
}
@@ -110,10 +117,10 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
110117
}
111118
if isFailed || err != nil {
112119
isFailed = true
113-
log.Println("failed to commit haproxy transaction", err)
120+
logger.CronJobLoggerError.Println("Failed to commit haproxy transaction while generating SSL certificate", err.Error())
114121
err := haproxyManager.DeleteTransaction(haproxyTransactionId)
115122
if err != nil {
116-
log.Println("failed to rollback haproxy transaction", err)
123+
logger.CronJobLoggerError.Println("Failed to rollback haproxy transaction while generating SSL certificate", err.Error())
117124
}
118125
}
119126
}

0 commit comments

Comments
 (0)