Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #55 from Netflix/more-vpc-logging
Browse files Browse the repository at this point in the history
More vpc logging
  • Loading branch information
sargun authored Feb 6, 2018
2 parents 6258504 + 0c33dcf commit 1c2cf4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vpc/allocate/allocate_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func allocateNetwork(parentCtx *context.VPCContext) error {
case <-ticker.C:
err = allocation.refresh()
if err != nil {
ctx.Logger.Error("Unable to refresh IP allocation record")
ctx.Logger.Error("Unable to refresh IP allocation record: ", err)
}
}
}
Expand Down Expand Up @@ -169,10 +169,12 @@ func doAllocateNetwork(parentCtx *context.VPCContext, deviceIdx, batchSize int,

networkInterface, err := getInterfaceByIdx(ctx, deviceIdx)
if err != nil {
ctx.Logger.Warning("Unable to get interface by idx: ", err)
return nil, err
}
sharedSGLock, err := setupSecurityGroups(ctx, networkInterface, securityGroups)
if err != nil {
ctx.Logger.Warning("Unable to setup security groups: ", err)
return nil, err
}
// 2. Get a (free) IP
Expand Down Expand Up @@ -233,6 +235,7 @@ func setupSecurityGroups(ctx *context.VPCContext, networkInterface *ec2wrapper.E
maybeReconfigurationLockPath := filepath.Join(networkInterface.LockPath(), "security-group-reconfig")
maybeReconfigurationLock, err := ctx.FSLocker.ExclusiveLock(maybeReconfigurationLockPath, &lockTimeout)
if err != nil {
ctx.Logger.Warning("Unable to get security-group-reconfig lock: ", err)
return nil, err
}
defer maybeReconfigurationLock.Unlock()
Expand All @@ -242,6 +245,7 @@ func setupSecurityGroups(ctx *context.VPCContext, networkInterface *ec2wrapper.E
sgConfigureLockPath := filepath.Join(networkInterface.LockPath(), "security-group-current-config")
sgConfigurationLock, err := ctx.FSLocker.SharedLock(sgConfigureLockPath, &lockTimeout)
if err != nil {
ctx.Logger.Warning("Unable to get security-group-current-config lock: ", err)
return nil, err
}
if reflect.DeepEqual(securityGroups, networkInterface.SecurityGroupIds) {
Expand Down
6 changes: 6 additions & 0 deletions vpc/allocate/ip_pool_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (mgr *IPPoolManager) assignMoreIPs(ctx *context.VPCContext, batchSize int)
func (mgr *IPPoolManager) allocate(ctx *context.VPCContext, batchSize int) (string, *fslocker.ExclusiveLock, error) {
configLock, err := mgr.lockConfiguration(ctx)
if err != nil {
ctx.Logger.Warning("Unable to get lock during allocation: ", err)
return "", nil, err
}
defer configLock.Unlock()
Expand All @@ -91,11 +92,15 @@ func (mgr *IPPoolManager) allocate(ctx *context.VPCContext, batchSize int) (stri
ip, lock, err := mgr.doAllocate(ctx)
// Did we successfully get an IP, or was there an error?
if err != nil || lock != nil {
if err != nil {
ctx.Logger.Warning("Unable to allocate IP: ", err)
}
return ip, lock, err
}

err = mgr.assignMoreIPs(ctx, batchSize)
if err != nil {
ctx.Logger.Warning("Unable assign more IPs: ", err)
return "", nil, err
}

Expand All @@ -109,6 +114,7 @@ func (mgr *IPPoolManager) doAllocate(ctx *context.VPCContext) (string, *fslocker
for _, ipAddress := range mgr.networkInterface.IPv4Addresses {
lock, err := mgr.tryAllocate(ctx, ipAddress)
if err != nil {
ctx.Logger.Warning("Unable to do allocation: ", err)
return "", nil, err
}
if lock != nil {
Expand Down
1 change: 1 addition & 0 deletions vpc/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func newVPCContext(cliContext *cli.Context) (*VPCContext, error) {
// Setup EC2 client
err = ret.setupEC2()
if err != nil {
logger.Warning("Unable to setup EC2 client: ", err)
return nil, err
}

Expand Down

0 comments on commit 1c2cf4f

Please sign in to comment.