Skip to content

Commit 5e541e1

Browse files
authored
feat(hatchery/openstack): list worker IP (#6702)
Signed-off-by: francois.samin <francois.samin@ovhcloud.com>
1 parent a441cd4 commit 5e541e1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

engine/hatchery/openstack/get.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/rockbears/log"
1212

1313
"github.com/ovh/cds/sdk"
14+
cdslog "github.com/ovh/cds/sdk/log"
1415
)
1516

1617
// Find image ID from image name
@@ -53,7 +54,7 @@ func (h *HatcheryOpenstack) getSmallerFlavorThan(flavor flavors.Flavor) flavors.
5354

5455
func (h *HatcheryOpenstack) getImages(ctx context.Context) []images.Image {
5556
t := time.Now()
56-
defer log.Debug(ctx, "getImages(): %fs", time.Since(t).Seconds())
57+
defer func() { log.Debug(ctx, "getImages(): %fs", time.Since(t).Seconds()) }()
5758

5859
is, expired := h.cache.Getimages()
5960
if len(is) > 0 && !expired {
@@ -91,7 +92,7 @@ func (h *HatcheryOpenstack) refreshImagesCache(ctx context.Context) error {
9192

9293
func (h *HatcheryOpenstack) getServers(ctx context.Context) []servers.Server {
9394
t := time.Now()
94-
defer log.Debug(ctx, "getServers() : %fs", time.Since(t).Seconds())
95+
defer func() { log.Debug(ctx, "getServers() : %fs", time.Since(t).Seconds()) }()
9596

9697
srvs, expired := h.cache.GetServers()
9798
if len(srvs) > 0 && !expired {
@@ -107,6 +108,7 @@ func (h *HatcheryOpenstack) getServers(ctx context.Context) []servers.Server {
107108
}
108109

109110
func (h *HatcheryOpenstack) refreshServersCache(ctx context.Context) error {
111+
ctx = context.WithValue(ctx, cdslog.Component, "refreshServersCache")
110112
all, err := servers.List(h.openstackClient, nil).AllPages()
111113
if err != nil {
112114
return sdk.WrapError(err, "cannot list openstack servers")
@@ -125,6 +127,7 @@ func (h *HatcheryOpenstack) refreshServersCache(ctx context.Context) error {
125127
if workerHatcheryName == "" || workerHatcheryName != h.Name() {
126128
continue
127129
}
130+
log.Info(ctx, "worker %q (status=%s) IP %q", s.Name, s.Status, s.AccessIPv4)
128131
filteredServerList = append(filteredServerList, s)
129132
}
130133

sdk/log/fields.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
NodeRunID = log.Field("node_run_id")
5050
PermJobID = log.Field("permJobID")
5151
Workflow = log.Field("workflow")
52+
Component = log.Field("component")
5253
)
5354

5455
func init() {
@@ -65,6 +66,7 @@ func init() {
6566
AuthSessionIAT,
6667
AuthSessionTokenID,
6768
Commit,
69+
Component,
6870
Deprecated,
6971
Duration,
7072
Goroutine,
@@ -92,7 +94,7 @@ func init() {
9294
AnalyzeID,
9395
NodeRunID,
9496
PermJobID,
95-
Workflow,
97+
Workflow,
9698
)
9799
}
98100

0 commit comments

Comments
 (0)