Skip to content

Commit 6a9ac50

Browse files
prometherionmjuraga
authored andcommitted
BUG/MINOR: aws: sanity checking for instance service tags
1 parent ede2fb6 commit 6a9ac50

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

discovery/aws_service_discovery_instance.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
2929
"github.com/haproxytech/client-native/v4/configuration"
3030
"github.com/haproxytech/client-native/v4/models"
31+
3132
"github.com/haproxytech/dataplaneapi/haproxy"
3233
"github.com/haproxytech/dataplaneapi/log"
3334
)
@@ -251,6 +252,8 @@ func (a *awsInstance) updateServices(api *ec2.Client) (err error) {
251252
var sn string
252253
sn, err = a.serviceNameFromEC2(i)
253254
if err != nil {
255+
a.logErrorf("unable to retrieve service name for the instance %s", *i.InstanceId)
256+
254257
continue
255258
}
256259
// creating empty service in case it isn't there
@@ -264,6 +267,13 @@ func (a *awsInstance) updateServices(api *ec2.Client) (err error) {
264267
}
265268
}
266269
instanceID := aws.ToString(i.InstanceId)
270+
271+
if _, portErr := mapService[sn].instancePortFromEC2(i); portErr != nil {
272+
a.logErrorf("unable to retrieve service port for the instance %s", *i.InstanceId)
273+
274+
continue
275+
}
276+
267277
mapService[sn].instances[instanceID] = i
268278
}
269279
}

0 commit comments

Comments
 (0)