AB#2286 Return only primary IPs for instance metadata operations (#335)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2022-08-04 11:08:20 +02:00 committed by GitHub
parent 5c00dafe9b
commit 4151d365fb
21 changed files with 180 additions and 185 deletions

View file

@ -73,7 +73,9 @@ func (f *Fetcher) DiscoverDebugdIPs(ctx context.Context) ([]string, error) {
}
var ips []string
for _, instance := range instances {
ips = append(ips, instance.PrivateIPs...)
if instance.VPCIP != "" {
ips = append(ips, instance.VPCIP)
}
}
return ips, nil
}

View file

@ -31,13 +31,13 @@ func TestDiscoverDebugIPs(t *testing.T) {
meta: stubMetadata{
listRes: []metadata.InstanceMetadata{
{
PrivateIPs: []string{"192.0.2.0"},
VPCIP: "192.0.2.0",
},
{
PrivateIPs: []string{"192.0.2.1"},
VPCIP: "192.0.2.1",
},
{
PrivateIPs: []string{"192.0.2.2"},
VPCIP: "192.0.2.2",
},
},
},