Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add public addresses for cdn #5221

Merged
merged 2 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/api/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions engine/api/workflow_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion engine/api/workflow_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions engine/cdn/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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##########################"`
Expand Down
5 changes: 1 addition & 4 deletions engine/hatchery/kubernetes/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions engine/hatchery/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 1 addition & 4 deletions engine/hatchery/swarm/swarm_util_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sdk/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down