当前位置: 首页>>代码示例>>Golang>>正文


Golang PublicAPIClient.InspectPod方法代码示例

本文整理汇总了Golang中github.com/coreos/rkt/api/v1alpha.PublicAPIClient.InspectPod方法的典型用法代码示例。如果您正苦于以下问题:Golang PublicAPIClient.InspectPod方法的具体用法?Golang PublicAPIClient.InspectPod怎么用?Golang PublicAPIClient.InspectPod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coreos/rkt/api/v1alpha.PublicAPIClient的用法示例。


在下文中一共展示了PublicAPIClient.InspectPod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: benchInspectPod

func benchInspectPod(b *testing.B, c v1alpha.PublicAPIClient) {
	resp, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{})
	if err != nil {
		b.Fatalf("Unexpected error: %v", err)
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		_, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: resp.Pods[0].Id})
		if err != nil {
			b.Error(err)
		}
	}
	b.StopTimer()
}
开发者ID:sinfomicien,项目名称:rkt,代码行数:15,代码来源:rkt_api_service_bench_test.go

示例2: newRktContainerHandler

func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPath string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, rootFs string, ignoreMetrics container.MetricSet) (container.ContainerHandler, error) {
	aliases := make([]string, 1)
	isPod := false

	apiPod := &rktapi.Pod{}

	parsed, err := parseName(name)
	if err != nil {
		return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
	}

	//rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
	if parsed.Container == "" {
		isPod = true
		aliases = append(aliases, "rkt://"+parsed.Pod)
	} else {
		aliases = append(aliases, "rkt://"+parsed.Pod+":"+parsed.Container)
	}

	pid := os.Getpid()
	labels := make(map[string]string)
	resp, err := rktClient.InspectPod(context.Background(), &rktapi.InspectPodRequest{
		Id: parsed.Pod,
	})
	if err != nil {
		return nil, err
	} else {
		var annotations []*rktapi.KeyValue
		if parsed.Container == "" {
			pid = int(resp.Pod.Pid)
			apiPod = resp.Pod
			annotations = resp.Pod.Annotations
		} else {
			var ok bool
			if annotations, ok = findAnnotations(resp.Pod.Apps, parsed.Container); !ok {
				glog.Warningf("couldn't find application in Pod matching %v", parsed.Container)
			}
		}
		labels = createLabels(annotations)
	}

	cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)

	// Generate the equivalent cgroup manager for this container.
	cgroupManager := &cgroupfs.Manager{
		Cgroups: &configs.Cgroup{
			Name: name,
		},
		Paths: cgroupPaths,
	}

	hasNetwork := false
	if isPod {
		hasNetwork = true
	}

	rootfsStorageDir := getRootFs(rktPath, parsed)

	handler := &rktContainerHandler{
		name:               name,
		rktClient:          rktClient,
		cgroupSubsystems:   cgroupSubsystems,
		machineInfoFactory: machineInfoFactory,
		cgroupPaths:        cgroupPaths,
		cgroupManager:      cgroupManager,
		fsInfo:             fsInfo,
		hasNetwork:         hasNetwork,
		rootFs:             rootFs,
		isPod:              isPod,
		aliases:            aliases,
		pid:                pid,
		labels:             labels,
		rootfsStorageDir:   rootfsStorageDir,
		ignoreMetrics:      ignoreMetrics,
		apiPod:             apiPod,
	}

	if !ignoreMetrics.Has(container.DiskUsageMetrics) {
		handler.fsHandler = common.NewFsHandler(time.Minute, rootfsStorageDir, "", fsInfo)
	}

	return handler, nil
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:83,代码来源:handler.go


注:本文中的github.com/coreos/rkt/api/v1alpha.PublicAPIClient.InspectPod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。