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