Skip to content

Commit

Permalink
Merge pull request #2221 from ctelfer/use-fmt-string-precision
Browse files Browse the repository at this point in the history
Use fmt precision to limit string length
  • Loading branch information
Flavio Crisciani authored Jul 5, 2018
2 parents 81c8215 + 0c3d9f0 commit 0cd65db
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 63 deletions.
10 changes: 5 additions & 5 deletions drivers/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ func (d *driver) deleteNetwork(nid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove bridge endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove bridge endpoint %.7s from store: %v", ep.id, err)
}
}

Expand Down Expand Up @@ -1048,7 +1048,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
}

if err = d.storeUpdate(endpoint); err != nil {
return fmt.Errorf("failed to save bridge endpoint %s to store: %v", endpoint.id[0:7], err)
return fmt.Errorf("failed to save bridge endpoint %.7s to store: %v", endpoint.id, err)
}

return nil
Expand Down Expand Up @@ -1114,7 +1114,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove bridge endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove bridge endpoint %.7s from store: %v", ep.id, err)
}

return nil
Expand Down Expand Up @@ -1288,7 +1288,7 @@ func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string
}()

if err = d.storeUpdate(endpoint); err != nil {
return fmt.Errorf("failed to update bridge endpoint %s to store: %v", endpoint.id[0:7], err)
return fmt.Errorf("failed to update bridge endpoint %.7s to store: %v", endpoint.id, err)
}

if !network.config.EnableICC {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
clearEndpointConnections(d.nlh, endpoint)

if err = d.storeUpdate(endpoint); err != nil {
return fmt.Errorf("failed to update bridge endpoint %s to store: %v", endpoint.id[0:7], err)
return fmt.Errorf("failed to update bridge endpoint %.7s to store: %v", endpoint.id, err)
}

return nil
Expand Down
12 changes: 6 additions & 6 deletions drivers/bridge/bridge_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (d *driver) populateNetworks() error {
if err = d.createNetwork(ncfg); err != nil {
logrus.Warnf("could not create bridge network for id %s bridge name %s while booting up from persistent state: %v", ncfg.ID, ncfg.BridgeName, err)
}
logrus.Debugf("Network (%s) restored", ncfg.ID[0:7])
logrus.Debugf("Network (%.7s) restored", ncfg.ID)
}

return nil
Expand All @@ -82,16 +82,16 @@ func (d *driver) populateEndpoints() error {
ep := kvo.(*bridgeEndpoint)
n, ok := d.networks[ep.nid]
if !ok {
logrus.Debugf("Network (%s) not found for restored bridge endpoint (%s)", ep.nid[0:7], ep.id[0:7])
logrus.Debugf("Deleting stale bridge endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Network (%.7s) not found for restored bridge endpoint (%.7s)", ep.nid, ep.id)
logrus.Debugf("Deleting stale bridge endpoint (%.7s) from store", ep.id)
if err := d.storeDelete(ep); err != nil {
logrus.Debugf("Failed to delete stale bridge endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Failed to delete stale bridge endpoint (%.7s) from store", ep.id)
}
continue
}
n.endpoints[ep.id] = ep
n.restorePortAllocations(ep)
logrus.Debugf("Endpoint (%s) restored to network (%s)", ep.id[0:7], ep.nid[0:7])
logrus.Debugf("Endpoint (%.7s) restored to network (%.7s)", ep.id, ep.nid)
}

return nil
Expand Down Expand Up @@ -382,7 +382,7 @@ func (n *bridgeNetwork) restorePortAllocations(ep *bridgeEndpoint) {
ep.extConnConfig.PortBindings = ep.portMapping
_, err := n.allocatePorts(ep, n.config.DefaultBindingIP, n.driver.config.EnableUserlandProxy)
if err != nil {
logrus.Warnf("Failed to reserve existing port mapping for endpoint %s:%v", ep.id[0:7], err)
logrus.Warnf("Failed to reserve existing port mapping for endpoint %.7s:%v", ep.id, err)
}
ep.extConnConfig.PortBindings = tmp
}
4 changes: 2 additions & 2 deletions drivers/ipvlan/ipvlan_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
}

if err := d.storeUpdate(ep); err != nil {
return fmt.Errorf("failed to save ipvlan endpoint %s to store: %v", ep.id[0:7], err)
return fmt.Errorf("failed to save ipvlan endpoint %.7s to store: %v", ep.id, err)
}

n.addEndpoint(ep)
Expand Down Expand Up @@ -82,7 +82,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove ipvlan endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove ipvlan endpoint %.7s from store: %v", ep.id, err)
}
n.deleteEndpoint(ep.id)
return nil
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipvlan/ipvlan_joinleave.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
return err
}
if err = d.storeUpdate(ep); err != nil {
return fmt.Errorf("failed to save ipvlan endpoint %s to store: %v", ep.id[0:7], err)
return fmt.Errorf("failed to save ipvlan endpoint %.7s to store: %v", ep.id, err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipvlan/ipvlan_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (d *driver) DeleteNetwork(nid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove ipvlan endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove ipvlan endpoint %.7s from store: %v", ep.id, err)
}
}
// delete the *network
Expand Down
8 changes: 4 additions & 4 deletions drivers/ipvlan/ipvlan_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ func (d *driver) populateEndpoints() error {
ep := kvo.(*endpoint)
n, ok := d.networks[ep.nid]
if !ok {
logrus.Debugf("Network (%s) not found for restored ipvlan endpoint (%s)", ep.nid[0:7], ep.id[0:7])
logrus.Debugf("Deleting stale ipvlan endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Network (%.7s) not found for restored ipvlan endpoint (%.7s)", ep.nid, ep.id)
logrus.Debugf("Deleting stale ipvlan endpoint (%.7s) from store", ep.id)
if err := d.storeDelete(ep); err != nil {
logrus.Debugf("Failed to delete stale ipvlan endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Failed to delete stale ipvlan endpoint (%.7s) from store", ep.id)
}
continue
}
n.endpoints[ep.id] = ep
logrus.Debugf("Endpoint (%s) restored to network (%s)", ep.id[0:7], ep.nid[0:7])
logrus.Debugf("Endpoint (%.7s) restored to network (%.7s)", ep.id, ep.nid)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions drivers/macvlan/macvlan_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
}

if err := d.storeUpdate(ep); err != nil {
return fmt.Errorf("failed to save macvlan endpoint %s to store: %v", ep.id[0:7], err)
return fmt.Errorf("failed to save macvlan endpoint %.7s to store: %v", ep.id, err)
}

n.addEndpoint(ep)
Expand Down Expand Up @@ -87,7 +87,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove macvlan endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove macvlan endpoint %.7s from store: %v", ep.id, err)
}

n.deleteEndpoint(ep.id)
Expand Down
2 changes: 1 addition & 1 deletion drivers/macvlan/macvlan_joinleave.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
return err
}
if err := d.storeUpdate(ep); err != nil {
return fmt.Errorf("failed to save macvlan endpoint %s to store: %v", ep.id[0:7], err)
return fmt.Errorf("failed to save macvlan endpoint %.7s to store: %v", ep.id, err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/macvlan/macvlan_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (d *driver) DeleteNetwork(nid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove macvlan endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove macvlan endpoint %.7s from store: %v", ep.id, err)
}
}
// delete the *network
Expand Down
8 changes: 4 additions & 4 deletions drivers/macvlan/macvlan_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ func (d *driver) populateEndpoints() error {
ep := kvo.(*endpoint)
n, ok := d.networks[ep.nid]
if !ok {
logrus.Debugf("Network (%s) not found for restored macvlan endpoint (%s)", ep.nid[0:7], ep.id[0:7])
logrus.Debugf("Deleting stale macvlan endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Network (%.7s) not found for restored macvlan endpoint (%.7s)", ep.nid, ep.id)
logrus.Debugf("Deleting stale macvlan endpoint (%.7s) from store", ep.id)
if err := d.storeDelete(ep); err != nil {
logrus.Debugf("Failed to delete stale macvlan endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Failed to delete stale macvlan endpoint (%.7s) from store", ep.id)
}
continue
}
n.endpoints[ep.id] = ep
logrus.Debugf("Endpoint (%s) restored to network (%s)", ep.id[0:7], ep.nid[0:7])
logrus.Debugf("Endpoint (%.7s) restored to network (%.7s)", ep.id, ep.nid)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions drivers/overlay/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (e *encrMap) String() string {
}

func (d *driver) checkEncryption(nid string, rIP net.IP, vxlanID uint32, isLocal, add bool) error {
logrus.Debugf("checkEncryption(%s, %v, %d, %t)", nid[0:7], rIP, vxlanID, isLocal)
logrus.Debugf("checkEncryption(%.7s, %v, %d, %t)", nid, rIP, vxlanID, isLocal)

n := d.network(nid)
if n == nil || !n.secure {
Expand All @@ -101,7 +101,7 @@ func (d *driver) checkEncryption(nid string, rIP net.IP, vxlanID uint32, isLocal
}
return false
}); err != nil {
logrus.Warnf("Failed to retrieve list of participating nodes in overlay network %s: %v", nid[0:5], err)
logrus.Warnf("Failed to retrieve list of participating nodes in overlay network %.5s: %v", nid, err)
}
default:
if len(d.network(nid).endpoints) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion drivers/overlay/joinleave.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
ep.ifName = containerIfName

if err = d.writeEndpointToStore(ep); err != nil {
return fmt.Errorf("failed to update overlay endpoint %s to local data store: %v", ep.id[0:7], err)
return fmt.Errorf("failed to update overlay endpoint %.7s to local data store: %v", ep.id, err)
}

// Set the container interface and its peer MTU to 1450 to allow
Expand Down
4 changes: 2 additions & 2 deletions drivers/overlay/ov_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
n.addEndpoint(ep)

if err := d.writeEndpointToStore(ep); err != nil {
return fmt.Errorf("failed to update overlay endpoint %s to local store: %v", ep.id[0:7], err)
return fmt.Errorf("failed to update overlay endpoint %.7s to local store: %v", ep.id, err)
}

return nil
Expand All @@ -116,7 +116,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
n.deleteEndpoint(eid)

if err := d.deleteEndpointFromStore(ep); err != nil {
logrus.Warnf("Failed to delete overlay endpoint %s from local store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to delete overlay endpoint %.7s from local store: %v", ep.id, err)
}

if ep.ifName == "" {
Expand Down
2 changes: 1 addition & 1 deletion drivers/overlay/ov_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (d *driver) DeleteNetwork(nid string) error {
}

if err := d.deleteEndpointFromStore(ep); err != nil {
logrus.Warnf("Failed to delete overlay endpoint %s from local store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to delete overlay endpoint %.7s from local store: %v", ep.id, err)
}
}
// flush the peerDB entries
Expand Down
6 changes: 3 additions & 3 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ func (d *driver) restoreEndpoints() error {
ep := kvo.(*endpoint)
n := d.network(ep.nid)
if n == nil {
logrus.Debugf("Network (%s) not found for restored endpoint (%s)", ep.nid[0:7], ep.id[0:7])
logrus.Debugf("Deleting stale overlay endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Network (%.7s) not found for restored endpoint (%.7s)", ep.nid, ep.id)
logrus.Debugf("Deleting stale overlay endpoint (%.7s) from store", ep.id)
if err := d.deleteEndpointFromStore(ep); err != nil {
logrus.Debugf("Failed to delete stale overlay endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Failed to delete stale overlay endpoint (%.7s) from store", ep.id)
}
continue
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/windows/overlay/ov_endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (n *network) removeEndpointWithAddress(addr *net.IPNet) {
_, err := hcsshim.HNSEndpointRequest("DELETE", networkEndpoint.profileID, "")

if err != nil {
logrus.Debugf("Failed to delete stale overlay endpoint (%s) from hns", networkEndpoint.id[0:7])
logrus.Debugf("Failed to delete stale overlay endpoint (%.7s) from hns", networkEndpoint.id)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (d *driver) DeleteNetwork(nid string) error {
// delele endpoints belong to this network
for _, ep := range n.endpoints {
if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove bridge endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove bridge endpoint %.7s from store: %v", ep.id, err)
}
}

Expand Down Expand Up @@ -704,7 +704,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
}

if err = d.storeUpdate(endpoint); err != nil {
logrus.Errorf("Failed to save endpoint %s to store: %v", endpoint.id[0:7], err)
logrus.Errorf("Failed to save endpoint %.7s to store: %v", endpoint.id, err)
}

return nil
Expand All @@ -731,7 +731,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
}

if err := d.storeDelete(ep); err != nil {
logrus.Warnf("Failed to remove bridge endpoint %s from store: %v", ep.id[0:7], err)
logrus.Warnf("Failed to remove bridge endpoint %.7s from store: %v", ep.id, err)
}
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/windows/windows_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (d *driver) populateNetworks() error {
if err = d.createNetwork(ncfg); err != nil {
logrus.Warnf("could not create windows network for id %s hnsid %s while booting up from persistent state: %v", ncfg.ID, ncfg.HnsID, err)
}
logrus.Debugf("Network %v (%s) restored", d.name, ncfg.ID[0:7])
logrus.Debugf("Network %v (%.7s) restored", d.name, ncfg.ID)
}

return nil
Expand All @@ -87,15 +87,15 @@ func (d *driver) populateEndpoints() error {
}
n, ok := d.networks[ep.nid]
if !ok {
logrus.Debugf("Network (%s) not found for restored endpoint (%s)", ep.nid[0:7], ep.id[0:7])
logrus.Debugf("Deleting stale endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Network (%.7s) not found for restored endpoint (%.7s)", ep.nid, ep.id)
logrus.Debugf("Deleting stale endpoint (%.7s) from store", ep.id)
if err := d.storeDelete(ep); err != nil {
logrus.Debugf("Failed to delete stale endpoint (%s) from store", ep.id[0:7])
logrus.Debugf("Failed to delete stale endpoint (%.7s) from store", ep.id)
}
continue
}
n.endpoints[ep.id] = ep
logrus.Debugf("Endpoint (%s) restored to network (%s)", ep.id[0:7], ep.nid[0:7])
logrus.Debugf("Endpoint (%.7s) restored to network (%.7s)", ep.id, ep.nid)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ func (n *network) addSvcRecords(eID, name, serviceID string, epIP, epIPv6 net.IP
return
}

logrus.Debugf("%s (%s).addSvcRecords(%s, %s, %s, %t) %s sid:%s", eID, n.ID()[0:7], name, epIP, epIPv6, ipMapUpdate, method, serviceID)
logrus.Debugf("%s (%.7s).addSvcRecords(%s, %s, %s, %t) %s sid:%s", eID, n.ID(), name, epIP, epIPv6, ipMapUpdate, method, serviceID)

c := n.getController()
c.Lock()
Expand Down Expand Up @@ -1426,7 +1426,7 @@ func (n *network) deleteSvcRecords(eID, name, serviceID string, epIP net.IP, epI
return
}

logrus.Debugf("%s (%s).deleteSvcRecords(%s, %s, %s, %t) %s sid:%s ", eID, n.ID()[0:7], name, epIP, epIPv6, ipMapUpdate, method, serviceID)
logrus.Debugf("%s (%.7s).deleteSvcRecords(%s, %s, %s, %t) %s sid:%s ", eID, n.ID(), name, epIP, epIPv6, ipMapUpdate, method, serviceID)

c := n.getController()
c.Lock()
Expand Down
8 changes: 4 additions & 4 deletions networkdb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (l *logWriter) Write(p []byte) (int, error) {

// SetKey adds a new key to the key ring
func (nDB *NetworkDB) SetKey(key []byte) {
logrus.Debugf("Adding key %s", hex.EncodeToString(key)[0:5])
logrus.Debugf("Adding key %.5s", hex.EncodeToString(key))
nDB.Lock()
defer nDB.Unlock()
for _, dbKey := range nDB.config.Keys {
Expand All @@ -69,7 +69,7 @@ func (nDB *NetworkDB) SetKey(key []byte) {
// SetPrimaryKey sets the given key as the primary key. This should have
// been added apriori through SetKey
func (nDB *NetworkDB) SetPrimaryKey(key []byte) {
logrus.Debugf("Primary Key %s", hex.EncodeToString(key)[0:5])
logrus.Debugf("Primary Key %.5s", hex.EncodeToString(key))
nDB.RLock()
defer nDB.RUnlock()
for _, dbKey := range nDB.config.Keys {
Expand All @@ -85,7 +85,7 @@ func (nDB *NetworkDB) SetPrimaryKey(key []byte) {
// RemoveKey removes a key from the key ring. The key being removed
// can't be the primary key
func (nDB *NetworkDB) RemoveKey(key []byte) {
logrus.Debugf("Remove Key %s", hex.EncodeToString(key)[0:5])
logrus.Debugf("Remove Key %.5s", hex.EncodeToString(key))
nDB.Lock()
defer nDB.Unlock()
for i, dbKey := range nDB.config.Keys {
Expand Down Expand Up @@ -123,7 +123,7 @@ func (nDB *NetworkDB) clusterInit() error {
var err error
if len(nDB.config.Keys) > 0 {
for i, key := range nDB.config.Keys {
logrus.Debugf("Encryption key %d: %s", i+1, hex.EncodeToString(key)[0:5])
logrus.Debugf("Encryption key %d: %.5s", i+1, hex.EncodeToString(key))
}
nDB.keyring, err = memberlist.NewKeyring(nDB.config.Keys, nDB.config.Keys[0])
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion sandbox_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (c *controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
}
sb.osSbox, err = osl.NewSandbox(sb.Key(), create, isRestore)
if err != nil {
logrus.Errorf("failed to create osl sandbox while trying to restore sandbox %s%s: %v", sb.ID()[0:7], msg, err)
logrus.Errorf("failed to create osl sandbox while trying to restore sandbox %.7s%s: %v", sb.ID(), msg, err)
continue
}

Expand Down
Loading

0 comments on commit 0cd65db

Please sign in to comment.