7
7
"time"
8
8
9
9
"github.com/go-gorp/gorp"
10
+ "github.com/lib/pq"
10
11
11
12
"github.com/ovh/cds/engine/api/cache"
12
13
"github.com/ovh/cds/sdk"
@@ -48,6 +49,10 @@ func ping(db gorp.SqlExecutor, s sdk.ExternalService) error {
48
49
var serv service
49
50
query := `select * from services where name = $1 for update nowait`
50
51
if err := db .SelectOne (& serv , query , s .Name ); err != nil {
52
+ if pqerr , ok := err .(* pq.Error ); ok && pqerr .Code == "55P03" {
53
+ log .Debug ("services.ping> Unable to lock service %s: %v" , s .Name , err )
54
+ return nil
55
+ }
51
56
log .Warning ("services.ping> Unable to lock service %s: %v" , s .Name , err )
52
57
return err
53
58
}
@@ -61,7 +66,13 @@ func ping(db gorp.SqlExecutor, s sdk.ExternalService) error {
61
66
},
62
67
},
63
68
}
64
- _ , code , err := doRequest (context .Background (), fmt .Sprintf ("%s:%s" , s .HealthURL , s .HealthPort ), "" , "GET" , s .HealthPath , nil )
69
+ var pingURL string
70
+ if s .HealthPort == "0" || s .HealthPort == "" {
71
+ pingURL = s .HealthURL
72
+ } else {
73
+ pingURL = fmt .Sprintf ("%s:%s" , s .HealthURL , s .HealthPort )
74
+ }
75
+ _ , code , err := doRequest (context .Background (), pingURL , "" , "GET" , s .HealthPath , nil )
65
76
if err != nil || code >= 400 {
66
77
mon .Lines [0 ].Status = sdk .MonitoringStatusWarn
67
78
mon .Lines [0 ].Value = "Health: KO"
@@ -108,7 +119,7 @@ func InitExternal(dbFunc func() *gorp.DbMap, store cache.Store, ss []sdk.Externa
108
119
}
109
120
s .Service .LastHeartbeat = oldSrv .LastHeartbeat
110
121
s .Service .MonitoringStatus = oldSrv .MonitoringStatus
111
- s .Service .Config = oldSrv . Config
122
+ s .Service .Config = s
112
123
if err := Update (tx , & s .Service ); err != nil {
113
124
_ = tx .Rollback ()
114
125
return fmt .Errorf ("InitExternal> unable to update external service: %v" , err )
0 commit comments