func waitForDeployment(c *fedclientset.Clientset, namespace string, deploymentName string, clusters map[string]*cluster) error { err := wait.Poll(10*time.Second, FederatedDeploymentTimeout, func() (bool, error) { fdep, err := c.Deployments(namespace).Get(deploymentName, metav1.GetOptions{}) if err != nil { return false, err } specReplicas, statusReplicas := int32(0), int32(0) for _, cluster := range clusters { dep, err := cluster.Deployments(namespace).Get(deploymentName, metav1.GetOptions{}) if err != nil && !errors.IsNotFound(err) { By(fmt.Sprintf("Failed getting deployment: %q/%q/%q, err: %v", cluster.name, namespace, deploymentName, err)) return false, err } if err == nil { if !verifyDeployment(fdep, dep) { By(fmt.Sprintf("Deployment meta or spec not match for cluster %q:\n federation: %v\n cluster: %v", cluster.name, fdep, dep)) return false, nil } specReplicas += *dep.Spec.Replicas statusReplicas += dep.Status.Replicas } } if statusReplicas == fdep.Status.Replicas && specReplicas >= *fdep.Spec.Replicas { return true, nil } By(fmt.Sprintf("Replicas not match, federation replicas: %v/%v, clusters replicas: %v/%v\n", *fdep.Spec.Replicas, fdep.Status.Replicas, specReplicas, statusReplicas)) return false, nil }) return err }
func updateDeploymentOrFail(clientset *fedclientset.Clientset, namespace string) *v1beta1.Deployment { if clientset == nil || len(namespace) == 0 { Fail(fmt.Sprintf("Internal error: invalid parameters passed to updateDeploymentOrFail: clientset: %v, namespace: %v", clientset, namespace)) } By(fmt.Sprintf("Updating federation deployment %q in namespace %q", FederationDeploymentName, namespace)) deployment := newDeploymentForFed(namespace, FederationDeploymentName, 15) newRs, err := clientset.Deployments(namespace).Update(deployment) framework.ExpectNoError(err, "Updating deployment %q in namespace %q", deployment.Name, namespace) By(fmt.Sprintf("Successfully updated federation deployment %q in namespace %q", FederationDeploymentName, namespace)) return newRs }