當前位置: 首頁>>代碼示例>>Golang>>正文


Golang etcd.InterpretDeleteError函數代碼示例

本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd.InterpretDeleteError函數的典型用法代碼示例。如果您正苦於以下問題:Golang InterpretDeleteError函數的具體用法?Golang InterpretDeleteError怎麽用?Golang InterpretDeleteError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了InterpretDeleteError函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: DeleteService

// DeleteService deletes a Service specified by its name.
func (r *Registry) DeleteService(name string) error {
	key := makeServiceKey(name)
	err := r.Delete(key, true)
	if err != nil {
		return etcderr.InterpretDeleteError(err, "service", name)
	}

	// TODO: can leave dangling endpoints, and potentially return incorrect
	// endpoints if a new service is created with the same name
	key = makeServiceEndpointsKey(name)
	if err := r.Delete(key, true); err != nil && !tools.IsEtcdNotFound(err) {
		return etcderr.InterpretDeleteError(err, "endpoints", name)
	}
	return nil
}
開發者ID:linuxwhy,項目名稱:kubernetes,代碼行數:16,代碼來源:etcd.go

示例2: DeleteRoute

// DeleteRoute deletes a Route specified by its ID.
func (registry *Etcd) DeleteRoute(ctx kapi.Context, routeID string) error {
	key, err := makeRouteKey(ctx, routeID)
	if err != nil {
		return err
	}
	err = registry.Delete(key, &api.Route{})
	return etcderr.InterpretDeleteError(err, "route", routeID)
}
開發者ID:dustintownsend,項目名稱:origin,代碼行數:9,代碼來源:etcd.go

示例3: DeleteController

// DeleteController deletes a ReplicationController specified by its ID.
func (r *Registry) DeleteController(ctx api.Context, controllerID string) error {
	key, err := makeControllerKey(ctx, controllerID)
	if err != nil {
		return err
	}
	err = r.Delete(key, false)
	return etcderr.InterpretDeleteError(err, "replicationController", controllerID)
}
開發者ID:SivagnanamCiena,項目名稱:calico-kubernetes,代碼行數:9,代碼來源:etcd.go

示例4: Delete

// Delete removes the item from etcd.
func (e *Etcd) Delete(ctx api.Context, id string) error {
	key, err := e.KeyFunc(ctx, id)
	if err != nil {
		return err
	}
	err = e.Helper.Delete(key, false)
	return etcderr.InterpretDeleteError(err, e.EndpointName, id)
}
開發者ID:hortonworks,項目名稱:kubernetes-yarn,代碼行數:9,代碼來源:etcd.go

示例5: DeleteBuildConfig

// DeleteBuildConfig deletes a BuildConfig specified by its ID.
func (r *Etcd) DeleteBuildConfig(ctx kapi.Context, id string) error {
	key, err := makeBuildConfigKey(ctx, id)
	if err != nil {
		return err
	}
	err = r.Delete(key, true)
	return etcderr.InterpretDeleteError(err, "buildConfig", id)
}
開發者ID:pombredanne,項目名稱:atomic-enterprise,代碼行數:9,代碼來源:etcd.go

示例6: DeleteMinion

func (r *Registry) DeleteMinion(ctx api.Context, minionID string) error {
	key := makeNodeKey(minionID)
	err := r.Delete(key, true)
	if err != nil {
		return etcderr.InterpretDeleteError(err, "minion", minionID)
	}
	return nil
}
開發者ID:vrosnet,項目名稱:kubernetes,代碼行數:8,代碼來源:etcd.go

示例7: DeletePod

// DeletePod deletes an existing pod specified by its ID.
func (r *Registry) DeletePod(ctx api.Context, podID string) error {
	var pod api.Pod
	podKey, err := makePodKey(ctx, podID)
	if err != nil {
		return err
	}
	err = r.ExtractObj(podKey, &pod, false)
	if err != nil {
		return etcderr.InterpretDeleteError(err, "pod", podID)
	}
	// First delete the pod, so a scheduler doesn't notice it getting removed from the
	// machine and attempt to put it somewhere.
	err = r.Delete(podKey, true)
	if err != nil {
		return etcderr.InterpretDeleteError(err, "pod", podID)
	}
	machine := pod.Status.Host
	if machine == "" {
		// Pod was never scheduled anywhere, just return.
		return nil
	}
	// Next, remove the pod from the machine atomically.
	contKey := makeBoundPodsKey(machine)
	return r.AtomicUpdate(contKey, &api.BoundPods{}, func(in runtime.Object) (runtime.Object, error) {
		pods := in.(*api.BoundPods)
		newPods := make([]api.BoundPod, 0, len(pods.Items))
		found := false
		for _, pod := range pods.Items {
			if pod.Name != podID {
				newPods = append(newPods, pod)
			} else {
				found = true
			}
		}
		if !found {
			// This really shouldn't happen, it indicates something is broken, and likely
			// there is a lost pod somewhere.
			// However it is "deleted" so log it and move on
			glog.Warningf("Couldn't find: %s in %#v", podID, pods)
		}
		pods.Items = newPods
		return pods, nil
	})
}
開發者ID:hortonworks,項目名稱:kubernetes-yarn,代碼行數:45,代碼來源:etcd.go

示例8: Delete

// Delete removes the item from etcd.
func (e *Etcd) Delete(ctx api.Context, name string, options *api.DeleteOptions) (runtime.Object, error) {
	key, err := e.KeyFunc(ctx, name)
	if err != nil {
		return nil, err
	}

	obj := e.NewFunc()
	trace := util.NewTrace("Delete " + reflect.TypeOf(obj).String())
	defer trace.LogIfLong(time.Second)
	trace.Step("About to read object")
	if err := e.Helper.ExtractObj(key, obj, false); err != nil {
		return nil, etcderr.InterpretDeleteError(err, e.EndpointName, name)
	}

	// support older consumers of delete by treating "nil" as delete immediately
	if options == nil {
		options = api.NewDeleteOptions(0)
	}
	graceful, pendingGraceful, err := rest.BeforeDelete(e.DeleteStrategy, ctx, obj, options)
	if err != nil {
		return nil, err
	}
	if pendingGraceful {
		return e.finalizeDelete(obj, false)
	}
	if graceful && *options.GracePeriodSeconds != 0 {
		trace.Step("Graceful deletion")
		out := e.NewFunc()
		if err := e.Helper.SetObj(key, obj, out, uint64(*options.GracePeriodSeconds)); err != nil {
			return nil, etcderr.InterpretUpdateError(err, e.EndpointName, name)
		}
		return e.finalizeDelete(out, true)
	}

	// delete immediately, or no graceful deletion supported
	out := e.NewFunc()
	trace.Step("About to delete object")
	if err := e.Helper.DeleteObj(key, out); err != nil {
		return nil, etcderr.InterpretDeleteError(err, e.EndpointName, name)
	}
	return e.finalizeDelete(out, true)
}
開發者ID:brandon-adams,項目名稱:origin,代碼行數:43,代碼來源:etcd.go

示例9: DeleteService

// DeleteService deletes a Service specified by its name.
func (r *Registry) DeleteService(ctx api.Context, name string) error {
	key, err := makeServiceKey(ctx, name)
	if err != nil {
		return err
	}
	err = r.Delete(key, true)
	if err != nil {
		return etcderr.InterpretDeleteError(err, "service", name)
	}

	// TODO: can leave dangling endpoints, and potentially return incorrect
	// endpoints if a new service is created with the same name
	err = r.endpoints.DeleteEndpoints(ctx, name)
	if err != nil && !errors.IsNotFound(err) {
		return err
	}
	return nil
}
開發者ID:SivagnanamCiena,項目名稱:calico-kubernetes,代碼行數:19,代碼來源:etcd.go

示例10: Delete

// Delete removes the item from etcd.
func (e *Etcd) Delete(ctx api.Context, name string) (runtime.Object, error) {
	key, err := e.KeyFunc(ctx, name)
	if err != nil {
		return nil, err
	}
	obj := e.NewFunc()
	if err := e.Helper.DeleteObj(key, obj); err != nil {
		return nil, etcderr.InterpretDeleteError(err, e.EndpointName, name)
	}
	if e.AfterDelete != nil {
		if err := e.AfterDelete(obj); err != nil {
			return nil, err
		}
	}
	if e.Decorator != nil {
		if err := e.Decorator(obj); err != nil {
			return nil, err
		}
	}
	if e.ReturnDeletedObject {
		return obj, nil
	}
	return &api.Status{Status: api.StatusSuccess}, nil
}
開發者ID:vrosnet,項目名稱:kubernetes,代碼行數:25,代碼來源:etcd.go

示例11: DeleteController

// DeleteController deletes a ReplicationController specified by its ID.
func (r *Registry) DeleteController(controllerID string) error {
	key := makeControllerKey(controllerID)
	err := r.Delete(key, false)
	return etcderr.InterpretDeleteError(err, "replicationController", controllerID)
}
開發者ID:linuxwhy,項目名稱:kubernetes,代碼行數:6,代碼來源:etcd.go

示例12: Delete

// Delete removes the item from etcd.
func (e *Etcd) Delete(ctx api.Context, id string) error {
	err := e.Helper.Delete(e.KeyFunc(id), false)
	return etcderr.InterpretDeleteError(err, e.EndpointName, id)
}
開發者ID:ericcapricorn,項目名稱:kubernetes,代碼行數:5,代碼來源:etcd.go


注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd.InterpretDeleteError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。