Skip to content

Commit

Permalink
azure: support standalone (non VMSS) instances
Browse files Browse the repository at this point in the history
Support instances that are not part of a Virtual Machine Scale Set.

Cilium only assumption with regard to machines running in VMSS was
limited to interfaces discovery. Also listing standard (non-VMSS)
network interfaces from the same Azure ResourceGroup is all we need
for those to work proper with Cilium.

Signed-off-by: Benjamin Pineau <benjamin.pineau@datadoghq.com>
  • Loading branch information
bpineau authored and aanm committed Jun 11, 2020
1 parent f6d62b5 commit a961b04
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion pkg/azure/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,52 @@ func deriveStatus(err error) string {
return "OK"
}

// describeNetworkInterfaces lists all Azure Interfaces
// describeNetworkInterfaces lists all Azure Interfaces in the client's resource group
func (c *Client) describeNetworkInterfaces(ctx context.Context) ([]network.Interface, error) {
networkInterfaces, err := c.vmssNetworkInterfaces(ctx)
if err != nil {
return nil, err
}

vmInterfaces, err := c.vmNetworkInterfaces(ctx)
if err != nil {
return nil, err
}

return append(networkInterfaces, vmInterfaces...), nil
}

// vmNetworkInterfaces list all interfaces of non-VMSS instances in the client's resource group
func (c *Client) vmNetworkInterfaces(ctx context.Context) ([]network.Interface, error) {
var networkInterfaces []network.Interface

c.limiter.Limit(ctx, "Interfaces.ListComplete")
sinceStart := spanstat.Start()
result, err := c.interfaces.ListComplete(ctx, c.resourceGroup)
c.metricsAPI.ObserveAPICall("Interfaces.ListComplete", deriveStatus(err), sinceStart.Seconds())
if err != nil {
return nil, err
}

for result.NotDone() {
if err != nil {
return nil, err
}
err = result.Next()

intf := result.Value()

if intf.Name == nil {
continue
}
networkInterfaces = append(networkInterfaces, intf)
}

return networkInterfaces, nil
}

// vmssNetworkInterfaces list all interfaces from VMS in Scale Sets in the client's resource group
func (c *Client) vmssNetworkInterfaces(ctx context.Context) ([]network.Interface, error) {
var networkInterfaces []network.Interface

c.limiter.Limit(ctx, "VirtualMachineScaleSets.ListAll")
Expand Down

0 comments on commit a961b04

Please sign in to comment.