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

Commit

Permalink
Update casing for errors
Browse files Browse the repository at this point in the history
In Go, errors should start with lower-case. Ref: #21

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Jan 20, 2020
1 parent 28d0dce commit 5b3fb8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions handlers/cni_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ func DeleteCNINetwork(ctx context.Context, cni gocni.CNI, client *containerd.Cli
if containerErr == nil {
task, err := container.Task(ctx, nil)
if err != nil {
log.Printf("[Delete] container %s does not have task\n", name)
log.Printf("[Delete] unable to find task for container: %s\n", name)
return nil
}

log.Printf("[Delete] removing CNI network for %s\n", task.ID())
log.Printf("[Delete] removing CNI network for: %s\n", task.ID())

id := NetID(task)
netns := NetNamespace(task)

if err := cni.Remove(ctx, id, netns); err != nil {
return errors.Wrapf(err, "Failed to remove network for task %q: %v", id, err)
return errors.Wrapf(err, "Failed to remove network for task: %q, %v", id, err)
}
log.Printf("[Delete] removed %s with namespace %s and ID %s\n", name, netns, id)
log.Printf("[Delete] removed: %s from namespace: %s, ID: %s\n", name, netns, id)

return nil
}

return errors.Wrapf(containerErr, "Container %s not found: %s", name, containerErr)
return errors.Wrapf(containerErr, "Unable to find container: %s, error: %s", name, containerErr)
}

// GetIPAddress returns the IP address of the created container
Expand All @@ -144,7 +144,7 @@ func GetIPAddress(result *gocni.CNIResult, task containerd.Task) (net.IP, error)
}
}
if ip == nil {
return nil, fmt.Errorf("Unable to get IP address for %s", task.ID())
return nil, fmt.Errorf("unable to get IP address for: %s", task.ID())
}
return ip, nil
}
Expand All @@ -154,12 +154,12 @@ func GetIPfromPID(pid int) (*net.IP, error) {

peerIDs, err := ConnectedToBridgeVethPeerIds(defaultBridgeName)
if err != nil {
return nil, fmt.Errorf("Unable to find peers on: %s %s", defaultBridgeName, err)
return nil, fmt.Errorf("unable to find peers on: %s %s", defaultBridgeName, err)
}

addrs, addrsErr := GetNetDevsByVethPeerIds(pid, peerIDs)
if addrsErr != nil {
return nil, fmt.Errorf("Unable to find address for veth pair using: %v %s", peerIDs, addrsErr)
return nil, fmt.Errorf("unable to find address for veth pair using: %v %s", peerIDs, addrsErr)
}
return &addrs[0].CIDRs[0].IP, nil

Expand Down
4 changes: 2 additions & 2 deletions handlers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GetFunction(client *containerd.Client, name string) (Function, error) {
// Task for container exists
svc, err := task.Status(ctx)
if err != nil {
return Function{}, fmt.Errorf("Unable to get task status for container: %s", name, err)
return Function{}, fmt.Errorf("unable to get task status for container: %s %s", name, err)
}
if svc.Status == "running" {
replicas = 1
Expand All @@ -67,5 +67,5 @@ func GetFunction(client *containerd.Client, name string) (Function, error) {
return f, nil

}
return Function{}, fmt.Errorf("Unable to find function %s: %s", name, err)
return Function{}, fmt.Errorf("unable to find function: %s, error %s", name, err)
}
3 changes: 2 additions & 1 deletion handlers/invoke_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ func (i *InvokeResolver) Resolve(functionName string) (url.URL, error) {

fun, err := GetFunction(i.client, functionName)
if err != nil {
return url.URL{}, fmt.Errorf("not found")
return url.URL{}, fmt.Errorf("%s not found", functionName)
}

serviceIP := fun.IP

const watchdogPort = 8080
Expand Down

0 comments on commit 5b3fb8a

Please sign in to comment.