diff --git a/engine/api/services.go b/engine/api/services.go index 9b28339007..82ac32e973 100644 --- a/engine/api/services.go +++ b/engine/api/services.go @@ -116,7 +116,7 @@ func (api *API) postServiceRegisterHandler() service.Handler { } srv.Uptodate = data.Version == sdk.VERSION - srv.LogServer = api.Config.CDN.TCP + srv.LogServerAdress = api.Config.CDN.PublicTCP return service.WriteJSON(w, srv, http.StatusOK) } diff --git a/engine/api/workflow_queue.go b/engine/api/workflow_queue.go index 2ff73ebcd5..a4e9045417 100644 --- a/engine/api/workflow_queue.go +++ b/engine/api/workflow_queue.go @@ -104,8 +104,8 @@ func (api *API) postTakeWorkflowJobHandler() service.Handler { return sdk.WrapError(err, "cannot takeJob nodeJobRunID:%d", id) } - if api.Config.CDN.TCP.Addr != "" && api.Config.CDN.TCP.Port > 0 { - pbji.GelfServiceAddr = fmt.Sprintf("%s:%d", api.Config.CDN.TCP.Addr, api.Config.CDN.TCP.Port) + if api.Config.CDN.PublicTCP != "" { + pbji.GelfServiceAddr = api.Config.CDN.PublicTCP } workflow.ResyncNodeRunsWithCommits(ctx, api.mustDB(), api.Cache, *p, report) go WorkflowSendEvent(context.Background(), api.mustDB(), api.Cache, *p, report) diff --git a/engine/api/workflow_queue_test.go b/engine/api/workflow_queue_test.go index 44a1d0f46a..2d1ecc7753 100644 --- a/engine/api/workflow_queue_test.go +++ b/engine/api/workflow_queue_test.go @@ -447,6 +447,7 @@ func Test_postTakeWorkflowJobHandler(t *testing.T) { // Add cdn config api.Config.CDN = cdn.Configuration{ + PublicTCP: "cdn.net:4545", TCP: sdk.TCPServer{ Port: 8090, Addr: "localhost", @@ -486,7 +487,7 @@ func Test_postTakeWorkflowJobHandler(t *testing.T) { } } - assert.Equal(t, "localhost:8090", pbji.GelfServiceAddr) + assert.Equal(t, "cdn.net:4545", pbji.GelfServiceAddr) run, err := workflow.LoadNodeJobRun(context.TODO(), api.mustDB(), api.Cache, ctx.job.ID) require.NoError(t, err) diff --git a/engine/cdn/types.go b/engine/cdn/types.go index cf805f9e27..054110600d 100644 --- a/engine/cdn/types.go +++ b/engine/cdn/types.go @@ -24,9 +24,11 @@ type Configuration struct { Addr string `toml:"addr" default:"" commented:"true" comment:"Listen address without port, example: 127.0.0.1" json:"addr"` Port int `toml:"port" default:"8089" json:"port"` } `toml:"http" comment:"######################\n CDS CDN HTTP Configuration \n######################" json:"http"` - URL string `default:"http://localhost:8087" json:"url"` - API service.APIServiceConfiguration `toml:"api" comment:"######################\n CDS API Settings \n######################" json:"api"` - Log struct { + URL string `default:"http://localhost:8089" json:"url" comment:"Private URL for communication with API"` + PublicTCP string `toml:"publicTCP" comment:"Public address to access to CDN TCP server"` + PublicHTTP string `toml:"publicHTTP" comment:"Public address to access to CDN HTTP server"` + API service.APIServiceConfiguration `toml:"api" comment:"######################\n CDS API Settings \n######################" json:"api"` + Log struct { StepMaxSize int64 `toml:"stepMaxSize" default:"15728640" comment:"Max step logs size in bytes (default: 15MB)" json:"stepMaxSize"` ServiceMaxSize int64 `toml:"serviceMaxSize" default:"15728640" comment:"Max service logs size in bytes (default: 15MB)" json:"serviceMaxSize"` } `toml:"log" json:"log" comment:"###########################\n Log settings.\n##########################"` diff --git a/engine/hatchery/kubernetes/services_test.go b/engine/hatchery/kubernetes/services_test.go index b26005efb3..3dea1f90c3 100644 --- a/engine/hatchery/kubernetes/services_test.go +++ b/engine/hatchery/kubernetes/services_test.go @@ -23,10 +23,7 @@ var loggerCall = 0 func Test_serviceLogs(t *testing.T) { h := NewHatcheryKubernetesTest(t) h.Common.ServiceInstance = &sdk.Service{ - LogServer: sdk.TCPServer{ - Addr: "tcphost", - Port: 8090, - }, + LogServerAdress: "tcphost:8090", } reader := rand.Reader bitSize := 2048 diff --git a/engine/hatchery/serve.go b/engine/hatchery/serve.go index 5ae773dc85..70d9582625 100644 --- a/engine/hatchery/serve.go +++ b/engine/hatchery/serve.go @@ -191,10 +191,9 @@ func (c *Common) getPanicDumpListHandler() service.Handler { } func (c *Common) InitServiceLogger() error { - tcpServer := c.Common.ServiceInstance.LogServer var signer jose.Signer - if tcpServer.Addr != "" && tcpServer.Port > 0 { - logger, err := log.New(fmt.Sprintf("%s:%d", tcpServer.Addr, tcpServer.Port)) + if c.Common.ServiceInstance.LogServerAdress != "" { + logger, err := log.New(c.Common.ServiceInstance.LogServerAdress) if err != nil { return sdk.WithStack(err) } diff --git a/engine/hatchery/swarm/swarm_util_logs_test.go b/engine/hatchery/swarm/swarm_util_logs_test.go index 14ff6e232e..c9b270c08a 100644 --- a/engine/hatchery/swarm/swarm_util_logs_test.go +++ b/engine/hatchery/swarm/swarm_util_logs_test.go @@ -21,10 +21,7 @@ var loggerCall = 0 func Test_serviceLogs(t *testing.T) { h := InitTestHatcherySwarm(t) h.Common.ServiceInstance = &sdk.Service{ - LogServer: sdk.TCPServer{ - Addr: "tcphost", - Port: 8090, - }, + LogServerAdress: "tcphost:8090", } reader := rand.Reader bitSize := 2048 diff --git a/sdk/services.go b/sdk/services.go index 2e986ec30f..261cd1823f 100644 --- a/sdk/services.go +++ b/sdk/services.go @@ -24,7 +24,7 @@ type Service struct { MonitoringStatus MonitoringStatus `json:"monitoring_status" db:"monitoring_status" cli:"-"` Version string `json:"version" db:"-" cli:"version"` Uptodate bool `json:"up_to_date" db:"-"` - LogServer TCPServer `json:"tcp" db:"-"` + LogServerAdress string `json:"tcp" db:"-"` } // Update service field from new data.