本文整理汇总了Golang中github.com/Sirupsen/logrus.Errorf函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorf函数的具体用法?Golang Errorf怎么用?Golang Errorf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeleteEndpointID
// DeleteEndpointID deletes an endpoint by ID.
func DeleteEndpointID(stateDriver core.StateDriver, epID string) error {
epCfg := &drivers.OvsCfgEndpointState{}
epCfg.StateDriver = stateDriver
err := epCfg.Read(epID)
if err != nil {
return err
}
nwCfg := &drivers.OvsCfgNetworkState{}
nwCfg.StateDriver = stateDriver
err = nwCfg.Read(epCfg.NetID)
if err != nil {
return err
}
err = freeEndpointResources(epCfg, nwCfg)
if err != nil {
return err
}
err = epCfg.Clear()
if err != nil {
log.Errorf("error writing nw config. Error: %s", err)
return err
}
err = nwCfg.Write()
if err != nil {
log.Errorf("error writing nw config. Error: %s", err)
return err
}
return err
}
示例2: RemoveLocalIpv6Flow
// Remove local IPv6 flow
func (self *Vrouter) RemoveLocalIpv6Flow(endpoint OfnetEndpoint) error {
// Find the flow entry
flowId := self.agent.getEndpointIdByIpVlan(endpoint.Ipv6Addr, endpoint.Vlan)
ipv6Flow := self.flowDb[flowId]
if ipv6Flow == nil {
log.Errorf("Error finding the flow for endpoint: %+v", endpoint)
return errors.New("Flow not found")
}
// Delete the Fgraph entry
err := ipv6Flow.Delete()
if err != nil {
log.Errorf("Error deleting the endpoint: %+v. Err: %v", endpoint, err)
}
// TODO: where do we add svcProxy endpoint? Do we need it for IPv6?
//self.svcProxy.DelEndpoint(&endpoint)
// Remove the endpoint from policy tables
err = self.policyAgent.DelIpv6Endpoint(&endpoint)
if err != nil {
log.Errorf("Error deleting IPv6 endpoint to policy agent{%+v}. Err: %v", endpoint, err)
return err
}
return nil
}
示例3: getSize
// getSize returns the real size & virtual size of the container.
func (daemon *Daemon) getSize(container *Container) (int64, int64) {
var (
sizeRw, sizeRootfs int64
err error
)
if err := daemon.Mount(container); err != nil {
logrus.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err)
return sizeRw, sizeRootfs
}
defer daemon.Unmount(container)
sizeRw, err = container.rwlayer.Size()
if err != nil {
logrus.Errorf("Driver %s couldn't return diff size of container %s: %s", daemon.driver, container.ID, err)
// FIXME: GetSize should return an error. Not changing it now in case
// there is a side-effect.
sizeRw = -1
}
if parent := container.rwlayer.Parent(); parent != nil {
sizeRootfs, err = parent.Size()
if err != nil {
sizeRootfs = -1
} else if sizeRw != -1 {
sizeRootfs += sizeRw
}
}
return sizeRw, sizeRootfs
}
示例4: GetSize
// GetSize, return real size, virtual size
func (container *Container) GetSize() (int64, int64) {
var (
sizeRw, sizeRootfs int64
err error
driver = container.daemon.driver
)
if err := container.Mount(); err != nil {
log.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err)
return sizeRw, sizeRootfs
}
defer container.Unmount()
initID := fmt.Sprintf("%s-init", container.ID)
sizeRw, err = driver.DiffSize(container.ID, initID)
if err != nil {
log.Errorf("Driver %s couldn't return diff size of container %s: %s", driver, container.ID, err)
// FIXME: GetSize should return an error. Not changing it now in case
// there is a side-effect.
sizeRw = -1
}
if _, err = os.Stat(container.basefs); err != nil {
if sizeRootfs, err = directory.Size(container.basefs); err != nil {
sizeRootfs = -1
}
}
return sizeRw, sizeRootfs
}
示例5: findApplianceByID
func (d *Dispatcher) findApplianceByID(conf *metadata.VirtualContainerHostConfigSpec) (*vm.VirtualMachine, error) {
defer trace.End(trace.Begin(""))
var err error
var vmm *vm.VirtualMachine
moref := new(types.ManagedObjectReference)
if ok := moref.FromString(conf.ID); !ok {
message := "Failed to get appliance VM mob reference"
log.Errorf(message)
return nil, errors.New(message)
}
ref, err := d.session.Finder.ObjectReference(d.ctx, *moref)
if err != nil {
if _, ok := err.(*find.NotFoundError); !ok {
err = errors.Errorf("Failed to query appliance (%s): %s", moref, err)
return nil, err
}
log.Debugf("Appliance is not found")
return nil, nil
}
ovm, ok := ref.(*object.VirtualMachine)
if !ok {
log.Errorf("Failed to find VM %s, %s", moref, err)
return nil, err
}
vmm = vm.NewVirtualMachine(d.ctx, d.session, ovm.Reference())
return vmm, nil
}
示例6: Cleanup
// Cleanup stops active swarm node. This is run before daemon shutdown.
func (c *Cluster) Cleanup() {
c.Lock()
node := c.node
if node == nil {
c.Unlock()
return
}
if c.isActiveManager() {
active, reachable, unreachable, err := c.managerStats()
if err == nil {
singlenode := active && reachable == 1 && unreachable == 0
if active && !singlenode && reachable-2 <= unreachable {
logrus.Errorf("Leaving cluster with %v managers left out of %v. Raft quorum will be lost.", reachable-1, reachable+unreachable)
}
}
}
c.cancelReconnect()
c.Unlock()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err := node.Stop(ctx); err != nil {
logrus.Errorf("error cleaning up cluster: %v", err)
}
c.Lock()
c.node = nil
c.ready = false
c.conn = nil
c.Unlock()
}
示例7: update
func (c *Client) update() error {
err := c.downloadTimestamp()
if err != nil {
logrus.Errorf("Client Update (Timestamp): %s", err.Error())
return err
}
err = c.downloadSnapshot()
if err != nil {
logrus.Errorf("Client Update (Snapshot): %s", err.Error())
return err
}
err = c.checkRoot()
if err != nil {
// In this instance the root has not expired base on time, but is
// expired based on the snapshot dictating a new root has been produced.
logrus.Debug(err)
return tuf.ErrLocalRootExpired{}
}
// will always need top level targets at a minimum
err = c.downloadTargets("targets")
if err != nil {
logrus.Errorf("Client Update (Targets): %s", err.Error())
return err
}
return nil
}
示例8: ProcessDeletions
// ProcessDeletions deletes the configuration passed from netmaster's statestore.
// This may result in generating Delete triggers for the netplugin.
func ProcessDeletions(allCfg *intent.Config) (err error) {
stateDriver, err := utils.GetStateDriver()
if err != nil {
return err
}
for _, tenant := range allCfg.Tenants {
err1 := DeleteEndpoints(stateDriver, &tenant)
if err1 != nil {
log.Errorf("error deleting endpoints '%s' \n", err1)
err = err1
continue
}
err1 = DeleteNetworks(stateDriver, &tenant)
if err1 != nil {
log.Errorf("error deleting networks '%s' \n", err1)
err = err1
continue
}
err1 = DeleteTenant(stateDriver, &tenant)
if err1 != nil {
log.Errorf("error deleting tenant '%s' \n", err1)
err = err1
continue
}
}
return
}
示例9: stubAddPod
// stubAddPod is the handler for testing pod additions
func stubAddPod(r *http.Request) (interface{}, error) {
resp := cniapi.RspAddPod{}
content, err := ioutil.ReadAll(r.Body)
if err != nil {
logger.Errorf("Failed to read request: %v", err)
return resp, err
}
pInfo := cniapi.CNIPodAttr{}
if err := json.Unmarshal(content, &pInfo); err != nil {
return resp, err
}
// verify pod attributes are as expected.
if pInfo.Name == "utPod" && pInfo.K8sNameSpace == "utK8sNS" &&
pInfo.InfraContainerID != "" && pInfo.IntfName != "" {
_, err := nsToPID(pInfo.NwNameSpace)
if err != nil {
logger.Errorf("Failed to fetch pid from netns %s: %v", pInfo.NwNameSpace,
err)
} else {
// respond with success
resp.IPAddress = utPodIP
resp.EndpointID = pInfo.InfraContainerID
return resp, nil
}
}
logger.Errorf("Failed pod %v", pInfo)
return resp, fmt.Errorf("Failed to add pod")
}
示例10: GetEndpointStats
// GetEndpointStats gets all endpoints from all ovs instances
func (d *OvsDriver) GetEndpointStats() ([]byte, error) {
vxlanStats, err := d.switchDb["vxlan"].GetEndpointStats()
if err != nil {
log.Errorf("Error getting vxlan stats. Err: %v", err)
return []byte{}, err
}
vlanStats, err := d.switchDb["vlan"].GetEndpointStats()
if err != nil {
log.Errorf("Error getting vlan stats. Err: %v", err)
return []byte{}, err
}
// combine the maps
for key, val := range vxlanStats {
vlanStats[key] = val
}
jsonStats, err := json.Marshal(vlanStats)
if err != nil {
log.Errorf("Error encoding epstats. Err: %v", err)
return jsonStats, err
}
return jsonStats, nil
}
示例11: Init
// Init registers a remote ipam when its plugin is activated
func Init(cb ipamapi.Callback, l, g interface{}) error {
newPluginHandler := func(name string, client *plugins.Client) {
a := newAllocator(name, client)
if cps, err := a.(*allocator).getCapabilities(); err == nil {
if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil {
logrus.Errorf("error registering remote ipam driver %s due to %v", name, err)
}
} else {
logrus.Infof("remote ipam driver %s does not support capabilities", name)
logrus.Debug(err)
if err := cb.RegisterIpamDriver(name, a); err != nil {
logrus.Errorf("error registering remote ipam driver %s due to %v", name, err)
}
}
}
// Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins.
handleFunc := plugins.Handle
if pg := cb.GetPluginGetter(); pg != nil {
handleFunc = pg.Handle
activePlugins := pg.GetAllManagedPluginsByCap(ipamapi.PluginEndpointType)
for _, ap := range activePlugins {
newPluginHandler(ap.Name(), ap.Client())
}
}
handleFunc(ipamapi.PluginEndpointType, newPluginHandler)
return nil
}
示例12: launch
func launch(c *cli.Context) {
conf := config.Conf(c)
resultChan := make(chan error)
rClient, err := config.GetRancherClient(conf)
if err != nil {
log.Fatal(err)
}
kClient := kubernetesclient.NewClient(conf.KubernetesURL, true)
rcHandler := kubernetesevents.NewHandler(rClient, kClient, kubernetesevents.RCKind)
svcHandler := kubernetesevents.NewHandler(rClient, kClient, kubernetesevents.ServiceKind)
handlers := []kubernetesevents.Handler{rcHandler, svcHandler}
go func(rc chan error) {
err := kubernetesevents.ConnectToEventStream(handlers, conf)
log.Errorf("Kubernetes stream listener exited with error: %s", err)
rc <- err
}(resultChan)
go func(rc chan error) {
err := rancherevents.ConnectToEventStream(conf)
log.Errorf("Rancher stream listener exited with error: %s", err)
rc <- err
}(resultChan)
<-resultChan
log.Info("Exiting.")
}
示例13: RuleDelete
// RuleDelete deletes the rule within a policy
func (ac *APIController) RuleDelete(rule *contivModel.Rule) error {
log.Infof("Received RuleDelete: %+v", rule)
policyKey := rule.TenantName + ":" + rule.PolicyName
// find the policy
policy := contivModel.FindPolicy(policyKey)
if policy == nil {
log.Errorf("Error finding policy %s", policyKey)
return core.Errorf("Policy not found")
}
// unlink the rule from policy
modeldb.RemoveLinkSet(&policy.LinkSets.Rules, rule)
err := policy.Write()
if err != nil {
return err
}
// Trigger policyDB Update
err = master.PolicyDelRule(policy, rule)
if err != nil {
log.Errorf("Error deleting rule %s to policy %s. Err: %v", rule.Key, policy.Key, err)
return err
}
return nil
}
示例14: EndpointGroupDelete
// EndpointGroupDelete deletes end point group
func (ac *APIController) EndpointGroupDelete(endpointGroup *contivModel.EndpointGroup) error {
log.Infof("Received EndpointGroupDelete: %+v", endpointGroup)
// delete the endpoint group state
err := master.DeleteEndpointGroup(endpointGroup.EndpointGroupID)
if err != nil {
log.Errorf("Error creating endpoing group %+v. Err: %v", endpointGroup, err)
}
// Detach the endpoint group from the Policies
for _, policyName := range endpointGroup.Policies {
policyKey := endpointGroup.TenantName + ":" + policyName
// find the policy
policy := contivModel.FindPolicy(policyKey)
if policy == nil {
log.Errorf("Could not find policy %s", policyName)
continue
}
// detach policy to epg
err := master.PolicyDetach(endpointGroup, policy)
if err != nil && err != master.EpgPolicyExists {
log.Errorf("Error detaching policy %s from epg %s", policyName, endpointGroup.Key)
}
// Remove links
modeldb.RemoveLinkSet(&policy.LinkSets.EndpointGroups, endpointGroup)
modeldb.RemoveLinkSet(&endpointGroup.LinkSets.Policies, policy)
policy.Write()
}
return nil
}
示例15: authorizationMiddleware
// authorizationMiddleware perform authorization on the request.
func (s *Server) authorizationMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// FIXME: fill when authN gets in
// User and UserAuthNMethod are taken from AuthN plugins
// Currently tracked in https://github.com/docker/docker/pull/13994
user := ""
userAuthNMethod := ""
authCtx := authorization.NewCtx(s.authZPlugins, user, userAuthNMethod, r.Method, r.RequestURI)
if err := authCtx.AuthZRequest(w, r); err != nil {
logrus.Errorf("AuthZRequest for %s %s returned error: %s", r.Method, r.RequestURI, err)
return err
}
rw := authorization.NewResponseModifier(w)
if err := handler(ctx, rw, r, vars); err != nil {
logrus.Errorf("Handler for %s %s returned error: %s", r.Method, r.RequestURI, err)
return err
}
if err := authCtx.AuthZResponse(rw, r); err != nil {
logrus.Errorf("AuthZResponse for %s %s returned error: %s", r.Method, r.RequestURI, err)
return err
}
return nil
}
}