Skip to content

Commit feb094d

Browse files
authored
fix(cdn): add public addresses (#5221)
1 parent e5876a9 commit feb094d

File tree

8 files changed

+15
-19
lines changed

8 files changed

+15
-19
lines changed

engine/api/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (api *API) postServiceRegisterHandler() service.Handler {
116116
}
117117

118118
srv.Uptodate = data.Version == sdk.VERSION
119-
srv.LogServer = api.Config.CDN.TCP
119+
srv.LogServerAdress = api.Config.CDN.PublicTCP
120120

121121
return service.WriteJSON(w, srv, http.StatusOK)
122122
}

engine/api/workflow_queue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func (api *API) postTakeWorkflowJobHandler() service.Handler {
104104
return sdk.WrapError(err, "cannot takeJob nodeJobRunID:%d", id)
105105
}
106106

107-
if api.Config.CDN.TCP.Addr != "" && api.Config.CDN.TCP.Port > 0 {
108-
pbji.GelfServiceAddr = fmt.Sprintf("%s:%d", api.Config.CDN.TCP.Addr, api.Config.CDN.TCP.Port)
107+
if api.Config.CDN.PublicTCP != "" {
108+
pbji.GelfServiceAddr = api.Config.CDN.PublicTCP
109109
}
110110
workflow.ResyncNodeRunsWithCommits(ctx, api.mustDB(), api.Cache, *p, report)
111111
go WorkflowSendEvent(context.Background(), api.mustDB(), api.Cache, *p, report)

engine/api/workflow_queue_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ func Test_postTakeWorkflowJobHandler(t *testing.T) {
447447

448448
// Add cdn config
449449
api.Config.CDN = cdn.Configuration{
450+
PublicTCP: "cdn.net:4545",
450451
TCP: sdk.TCPServer{
451452
Port: 8090,
452453
Addr: "localhost",
@@ -486,7 +487,7 @@ func Test_postTakeWorkflowJobHandler(t *testing.T) {
486487
}
487488
}
488489

489-
assert.Equal(t, "localhost:8090", pbji.GelfServiceAddr)
490+
assert.Equal(t, "cdn.net:4545", pbji.GelfServiceAddr)
490491

491492
run, err := workflow.LoadNodeJobRun(context.TODO(), api.mustDB(), api.Cache, ctx.job.ID)
492493
require.NoError(t, err)

engine/cdn/types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ type Configuration struct {
2424
Addr string `toml:"addr" default:"" commented:"true" comment:"Listen address without port, example: 127.0.0.1" json:"addr"`
2525
Port int `toml:"port" default:"8089" json:"port"`
2626
} `toml:"http" comment:"######################\n CDS CDN HTTP Configuration \n######################" json:"http"`
27-
URL string `default:"http://localhost:8087" json:"url"`
28-
API service.APIServiceConfiguration `toml:"api" comment:"######################\n CDS API Settings \n######################" json:"api"`
29-
Log struct {
27+
URL string `default:"http://localhost:8089" json:"url" comment:"Private URL for communication with API"`
28+
PublicTCP string `toml:"publicTCP" comment:"Public address to access to CDN TCP server"`
29+
PublicHTTP string `toml:"publicHTTP" comment:"Public address to access to CDN HTTP server"`
30+
API service.APIServiceConfiguration `toml:"api" comment:"######################\n CDS API Settings \n######################" json:"api"`
31+
Log struct {
3032
StepMaxSize int64 `toml:"stepMaxSize" default:"15728640" comment:"Max step logs size in bytes (default: 15MB)" json:"stepMaxSize"`
3133
ServiceMaxSize int64 `toml:"serviceMaxSize" default:"15728640" comment:"Max service logs size in bytes (default: 15MB)" json:"serviceMaxSize"`
3234
} `toml:"log" json:"log" comment:"###########################\n Log settings.\n##########################"`

engine/hatchery/kubernetes/services_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ var loggerCall = 0
2323
func Test_serviceLogs(t *testing.T) {
2424
h := NewHatcheryKubernetesTest(t)
2525
h.Common.ServiceInstance = &sdk.Service{
26-
LogServer: sdk.TCPServer{
27-
Addr: "tcphost",
28-
Port: 8090,
29-
},
26+
LogServerAdress: "tcphost:8090",
3027
}
3128
reader := rand.Reader
3229
bitSize := 2048

engine/hatchery/serve.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,9 @@ func (c *Common) getPanicDumpListHandler() service.Handler {
191191
}
192192

193193
func (c *Common) InitServiceLogger() error {
194-
tcpServer := c.Common.ServiceInstance.LogServer
195194
var signer jose.Signer
196-
if tcpServer.Addr != "" && tcpServer.Port > 0 {
197-
logger, err := log.New(fmt.Sprintf("%s:%d", tcpServer.Addr, tcpServer.Port))
195+
if c.Common.ServiceInstance.LogServerAdress != "" {
196+
logger, err := log.New(c.Common.ServiceInstance.LogServerAdress)
198197
if err != nil {
199198
return sdk.WithStack(err)
200199
}

engine/hatchery/swarm/swarm_util_logs_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ var loggerCall = 0
2121
func Test_serviceLogs(t *testing.T) {
2222
h := InitTestHatcherySwarm(t)
2323
h.Common.ServiceInstance = &sdk.Service{
24-
LogServer: sdk.TCPServer{
25-
Addr: "tcphost",
26-
Port: 8090,
27-
},
24+
LogServerAdress: "tcphost:8090",
2825
}
2926
reader := rand.Reader
3027
bitSize := 2048

sdk/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Service struct {
2424
MonitoringStatus MonitoringStatus `json:"monitoring_status" db:"monitoring_status" cli:"-"`
2525
Version string `json:"version" db:"-" cli:"version"`
2626
Uptodate bool `json:"up_to_date" db:"-"`
27-
LogServer TCPServer `json:"tcp" db:"-"`
27+
LogServerAdress string `json:"tcp" db:"-"`
2828
}
2929

3030
// Update service field from new data.

0 commit comments

Comments
 (0)