@@ -41,6 +41,7 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
41
41
return nil
42
42
}
43
43
_ = domain .UpdateSSLStatus (ctx , dbWithoutTx , core .DomainSSLStatusFailed )
44
+ logger .CronJobLoggerError .Println ("Domain" , domain .Name , "is not pointing to this server. Marking SSL Issue as failed" )
44
45
return nil
45
46
}
46
47
// generate private key [if not found]
@@ -52,6 +53,7 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
52
53
domain .SSLPrivateKey = privateKey
53
54
err = domain .Update (ctx , dbWithoutTx )
54
55
if err != nil {
56
+ logger .CronJobLoggerError .Println ("Failed to update domain" , domain .Name , "with private key." , err .Error (), "\n Will retry later" )
55
57
return err
56
58
}
57
59
}
@@ -72,16 +74,19 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
72
74
// update domain
73
75
err = domain .Update (ctx , dbWithoutTx )
74
76
if err != nil {
77
+ logger .CronJobLoggerError .Println ("Failed to update domain" , domain .Name , "with SSL status" , domain .SSLStatus , err .Error (), "\n Will retry later" )
75
78
return err
76
79
}
77
80
// fetch all proxy servers
78
81
proxyServers , err := core .FetchProxyActiveServers (& m .ServiceManager .DbClient )
79
82
if err != nil {
83
+ logger .CronJobLoggerError .Println ("Failed to fetch proxy servers while generating SSL certificate" , err .Error (), "\n Will retry later" )
80
84
return err
81
85
}
82
86
// fetch all haproxy managers
83
87
haproxyManagers , err := manager .HAProxyClients (context .Background (), proxyServers )
84
88
if err != nil {
89
+ logger .CronJobLoggerError .Println ("Failed to fetch haproxy managers while generating SSL certificate" , err .Error ())
85
90
return err
86
91
}
87
92
// map of server ip and transaction id
@@ -92,13 +97,15 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
92
97
// generate a new transaction id for haproxy
93
98
transactionId , err := haproxyManager .FetchNewTransactionId ()
94
99
if err != nil {
100
+ logger .CronJobLoggerError .Println ("Failed to fetch new transaction id while generating SSL certificate" , err .Error (), "\n Will retry later" )
95
101
return err
96
102
}
97
103
// add to map
98
104
transactionIdMap [haproxyManager ] = transactionId
99
105
// upload certificate to haproxy
100
106
err = haproxyManager .UpdateSSL (transactionId , domain .Name , []byte (domain .SSLPrivateKey ), []byte (domain .SSLFullChain ))
101
107
if err != nil {
108
+ logger .CronJobLoggerError .Println ("Failed to update SSL certificate while generating SSL certificate" , err .Error (), "\n Will retry later" )
102
109
isFailed = true
103
110
break
104
111
}
@@ -110,10 +117,10 @@ func (m Manager) SSLGenerate(request SSLGenerateRequest, ctx context.Context, _
110
117
}
111
118
if isFailed || err != nil {
112
119
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 () )
114
121
err := haproxyManager .DeleteTransaction (haproxyTransactionId )
115
122
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 () )
117
124
}
118
125
}
119
126
}
0 commit comments