Skip to content

Commit 2be281b

Browse files
committed
BUG/MINOR: aws: sanity checking for instance service tags
1 parent 11698db commit 2be281b

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/v5/configuration"
3030
"github.com/haproxytech/client-native/v5/models"
31+
3132
"github.com/haproxytech/dataplaneapi/haproxy"
3233
"github.com/haproxytech/dataplaneapi/log"
3334
)
@@ -255,6 +256,8 @@ func (a *awsInstance) updateServices(api *ec2.Client) (err error) {
255256
var sn string
256257
sn, err = a.serviceNameFromEC2(i)
257258
if err != nil {
259+
a.logErrorf("unable to retrieve service name for the instance %s", *i.InstanceId)
260+
258261
continue
259262
}
260263
// creating empty service in case it isn't there
@@ -268,6 +271,13 @@ func (a *awsInstance) updateServices(api *ec2.Client) (err error) {
268271
}
269272
}
270273
instanceID := aws.ToString(i.InstanceId)
274+
275+
if _, portErr := mapService[sn].instancePortFromEC2(i); portErr != nil {
276+
a.logErrorf("unable to retrieve service port for the instance %s", *i.InstanceId)
277+
278+
continue
279+
}
280+
271281
mapService[sn].instances[instanceID] = i
272282
}
273283
}

0 commit comments

Comments
 (0)