Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Apr 24, 2024
1 parent 9d355ee commit 1eaa5b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions controllers/apps/cluster_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ func (c *clusterPlanBuilder) reconcileCluster(node *model.ObjectVertex) error {
return err
}
}
case model.CREATE:
return fmt.Errorf("cluster can't be created: %s", cluster.Name)
case model.CREATE, model.UPDATE:
return fmt.Errorf("cluster can't be created or updated: %s", cluster.Name)
}
return nil
}
Expand Down
3 changes: 0 additions & 3 deletions controllers/apps/transformer_cluster_placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ func (t *clusterPlacementTransformer) Transform(ctx graph.TransformContext, dag
cluster.Annotations[constant.KBAppMultiClusterPlacementKey] = strings.Join(p, ",")
transCtx.Context = intoContext(transCtx.Context, placement(cluster))

graphCli, _ := transCtx.Client.(model.GraphClient)
graphCli.Update(dag, transCtx.OrigCluster, cluster)

return nil
}

Expand Down
11 changes: 5 additions & 6 deletions pkg/controller/component/vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ var _ = Describe("vars", func() {
Expect(err).ShouldNot(BeNil())
Expect(err.Error()).Should(ContainSubstring("the required var is not found"))

By("adaptive - has load balancer service")
By("adaptive - has load balancer pod service")
vars = []appsv1alpha1.EnvVar{
{
Name: "advertised",
Expand Down Expand Up @@ -903,7 +903,9 @@ var _ = Describe("vars", func() {
Expect(err).Should(Succeed())
checkEnvVarWithValue(envVars, "advertised", advertisedSvcName)

By("adaptive - has load balancer in provisioning")
By("adaptive - has load balancer service in provisioning")
// change to non pod-service
advertisedSvcName = constant.GenerateComponentServiceName(synthesizedComp.ClusterName, synthesizedComp.Name, "advertised")
reader = &mockReader{
cli: testCtx.Cli,
objs: []client.Object{
Expand Down Expand Up @@ -961,10 +963,7 @@ var _ = Describe("vars", func() {
}
_, envVars, err = ResolveTemplateNEnvVars(testCtx.Ctx, reader, synthesizedComp, vars)
Expect(err).Should(Succeed())
endpoints = []string{
fmt.Sprintf("%s:127.0.0.1", advertisedSvcName),
}
checkEnvVarWithValue(envVars, "advertised", strings.Join(endpoints, ","))
checkEnvVarWithValue(envVars, "advertised", "127.0.0.1")
})

It("credential vars", func() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/multicluster/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func FromContext(ctx context.Context) (string, error) {
return "", placementNotFoundError{}
}

// TODO: replace it with a new client option and automatically perform the assignment based on ordinal.

func Assign(ctx context.Context, obj client.Object, ordinal func() int) client.Object {
// has been set
if obj.GetAnnotations() != nil && obj.GetAnnotations()[constant.KBAppMultiClusterPlacementKey] != "" {
Expand Down

0 comments on commit 1eaa5b8

Please sign in to comment.