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


Golang ReplicationControllerInterface.UpdateStatus方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion.ReplicationControllerInterface.UpdateStatus方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReplicationControllerInterface.UpdateStatus方法的具體用法?Golang ReplicationControllerInterface.UpdateStatus怎麽用?Golang ReplicationControllerInterface.UpdateStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion.ReplicationControllerInter的用法示例。


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

示例1: updateReplicaCount

// updateReplicaCount attempts to update the Status.Replicas of the given controller, with a single GET/PUT retry.
func updateReplicaCount(rcClient unversionedcore.ReplicationControllerInterface, controller api.ReplicationController, numReplicas, numFullyLabeledReplicas, numReadyReplicas, numAvailableReplicas int) (updateErr error) {
	// This is the steady state. It happens when the rc doesn't have any expectations, since
	// we do a periodic relist every 30s. If the generations differ but the replicas are
	// the same, a caller might've resized to the same replica count.
	if int(controller.Status.Replicas) == numReplicas &&
		int(controller.Status.FullyLabeledReplicas) == numFullyLabeledReplicas &&
		int(controller.Status.ReadyReplicas) == numReadyReplicas &&
		int(controller.Status.AvailableReplicas) == numAvailableReplicas &&
		controller.Generation == controller.Status.ObservedGeneration {
		return nil
	}
	// Save the generation number we acted on, otherwise we might wrongfully indicate
	// that we've seen a spec update when we retry.
	// TODO: This can clobber an update if we allow multiple agents to write to the
	// same status.
	generation := controller.Generation

	var getErr error
	for i, rc := 0, &controller; ; i++ {
		glog.V(4).Infof(fmt.Sprintf("Updating replica count for rc: %s/%s, ", controller.Namespace, controller.Name) +
			fmt.Sprintf("replicas %d->%d (need %d), ", controller.Status.Replicas, numReplicas, controller.Spec.Replicas) +
			fmt.Sprintf("fullyLabeledReplicas %d->%d, ", controller.Status.FullyLabeledReplicas, numFullyLabeledReplicas) +
			fmt.Sprintf("readyReplicas %d->%d, ", controller.Status.ReadyReplicas, numReadyReplicas) +
			fmt.Sprintf("availableReplicas %d->%d, ", controller.Status.AvailableReplicas, numAvailableReplicas) +
			fmt.Sprintf("sequence No: %v->%v", controller.Status.ObservedGeneration, generation))

		rc.Status = api.ReplicationControllerStatus{
			Replicas:             int32(numReplicas),
			FullyLabeledReplicas: int32(numFullyLabeledReplicas),
			ReadyReplicas:        int32(numReadyReplicas),
			AvailableReplicas:    int32(numAvailableReplicas),
			ObservedGeneration:   generation,
		}
		_, updateErr = rcClient.UpdateStatus(rc)
		if updateErr == nil || i >= statusUpdateRetries {
			return updateErr
		}
		// Update the controller with the latest resource version for the next poll
		if rc, getErr = rcClient.Get(controller.Name); getErr != nil {
			// If the GET fails we can't trust status.Replicas anymore. This error
			// is bound to be more interesting than the update failure.
			return getErr
		}
	}
}
開發者ID:upmc-enterprises,項目名稱:kubernetes,代碼行數:46,代碼來源:replication_controller_utils.go


注:本文中的k8s/io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion.ReplicationControllerInterface.UpdateStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。