diff --git a/client/deployments.go b/client/deployments.go index 8d9233b1b..f18909b7c 100644 --- a/client/deployments.go +++ b/client/deployments.go @@ -88,6 +88,7 @@ func WaitForDeploymentAvailables( zap.Int32("available-replicas", dp.Status.AvailableReplicas), zap.Int32("unavailable-replicas", dp.Status.UnavailableReplicas), zap.Int32("ready-replicas", dp.Status.ReadyReplicas), + zap.Int32("target-available-replicas", targetAvailableReplicas), zap.String("condition-last-updated", dpCond.LastUpdateTime.String()), zap.String("condition-type", string(dpCond.Type)), zap.String("condition-status", string(dpCond.Status)), @@ -95,7 +96,7 @@ func WaitForDeploymentAvailables( zap.String("condition-message", dpCond.Message), ) if dpCond.Type == apps_v1.DeploymentReplicaFailure { - return true, fmt.Errorf("Deployment %q status %q", deploymentName, dpCond.Type) + return true, fmt.Errorf("deployment %q status %q", deploymentName, dpCond.Type) } if dp.Status.AvailableReplicas >= targetAvailableReplicas { if dpCond.Type == apps_v1.DeploymentAvailable { diff --git a/k8s-tester/nlb-guestbook/tester.go b/k8s-tester/nlb-guestbook/tester.go index 289654398..483f49a16 100644 --- a/k8s-tester/nlb-guestbook/tester.go +++ b/k8s-tester/nlb-guestbook/tester.go @@ -132,16 +132,18 @@ const ( redisLeaderAppName = "redis-master" // ref. https://hub.docker.com/_/redis/?tab=tags // ref. https://gallery.ecr.aws/bitnami/redis - redisLeaderAppImageName = "public.ecr.aws/bitnami/redis:latest" - redisLeaderServiceName = "redis-master" // e..g "Connecting to MASTER redis-master:6379" - redisLeaderRoleName = "master" // TODO: change this to "leader" + redisLeaderAppImageName = "public.ecr.aws/bitnami/redis:latest" + redisLeaderServiceName = "redis-master" // e..g "Connecting to MASTER redis-master:6379" + redisLeaderRoleName = "master" // TODO: change this to "leader" + redisLeaderTargetReplicas int32 = 1 redisFollowerDeploymentName = "redis-follower" redisFollowerAppName = "redis-slave" // ref. https://hub.docker.com/_/redis/?tab=tags - redisFollowerAppImageName = "k8s.gcr.io/redis-slave:v2" - redisFollowerServiceName = "redis-slave" - redisFollowerRoleName = "slave" // TODO: change this to "follower" + redisFollowerAppImageName = "k8s.gcr.io/redis-slave:v2" + redisFollowerServiceName = "redis-slave" + redisFollowerRoleName = "slave" // TODO: change this to "follower" + redisFollowerTargetReplicas int32 = 1 deploymentName = "guestbook" appName = "guestbook" @@ -403,7 +405,7 @@ func (ts *tester) createDeploymentRedisLeader() error { }, }, Spec: apps_v1.DeploymentSpec{ - Replicas: int32Ref(1), + Replicas: int32Ref(redisLeaderTargetReplicas), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "app.kubernetes.io/name": redisLabelName, @@ -460,7 +462,7 @@ func (ts *tester) createDeploymentRedisLeader() error { } func (ts *tester) checkDeploymentRedisLeader() error { - timeout := 7*time.Minute + time.Duration(ts.cfg.DeploymentReplicas)*time.Minute + timeout := 7*time.Minute + time.Duration(redisLeaderTargetReplicas)*time.Minute ctx, cancel := context.WithTimeout(context.Background(), timeout) _, err := client.WaitForDeploymentAvailables( ctx, @@ -472,7 +474,7 @@ func (ts *tester) checkDeploymentRedisLeader() error { 20*time.Second, ts.cfg.Namespace, redisLeaderDeploymentName, - ts.cfg.DeploymentReplicas, + redisLeaderTargetReplicas, client.WithQueryFunc(func() { descArgs := []string{ ts.cfg.Client.Config().KubectlPath, @@ -594,7 +596,7 @@ func (ts *tester) createDeploymentRedisFollower() error { }, }, Spec: apps_v1.DeploymentSpec{ - Replicas: int32Ref(2), + Replicas: int32Ref(redisFollowerTargetReplicas), Selector: &meta_v1.LabelSelector{ MatchLabels: map[string]string{ "app.kubernetes.io/name": redisLabelName, @@ -651,7 +653,7 @@ func (ts *tester) createDeploymentRedisFollower() error { } func (ts *tester) checkDeploymentRedisFollower() error { - timeout := 7*time.Minute + time.Duration(ts.cfg.DeploymentReplicas)*time.Minute + timeout := 7*time.Minute + time.Duration(redisFollowerTargetReplicas)*time.Minute ctx, cancel := context.WithTimeout(context.Background(), timeout) _, err := client.WaitForDeploymentAvailables( ctx, @@ -663,7 +665,7 @@ func (ts *tester) checkDeploymentRedisFollower() error { 20*time.Second, ts.cfg.Namespace, redisFollowerDeploymentName, - ts.cfg.DeploymentReplicas, + redisFollowerTargetReplicas, client.WithQueryFunc(func() { descArgs := []string{ ts.cfg.Client.Config().KubectlPath,