Skip to content

Commit

Permalink
issue-594-expose-services-deferred-status, deferred status for cluste…
Browse files Browse the repository at this point in the history
…rs was handled
  • Loading branch information
DoodgeMatvey committed Oct 16, 2023
1 parent e9cccef commit ace0764
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
1 change: 0 additions & 1 deletion controllers/clusterresources/postgresqluser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ func (r *PostgreSQLUserReconciler) createUser(
return fmt.Errorf("cannot list nodes, err: %w", err)
}

// TODO: Handle scenario if there are no nodes with external IP, check private/public cluster
for _, node := range nodeList.Items {
for _, nodeAddress := range node.Status.Addresses {
if nodeAddress.Type == k8sCore.NodeExternalIP {
Expand Down
2 changes: 1 addition & 1 deletion controllers/clusters/postgresql_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var _ = Describe("PostgreSQL Controller", func() {
})
})

When("Deleting the Kafka Connect resource by avoiding operator", func() {
When("Deleting the PostgreSQL resource by avoiding operator", func() {
It("should try to get the cluster details and receive StatusNotFound", func() {
postgresqlManifest2 := postgresqlManifest.DeepCopy()
postgresqlManifest2.Name += "-test-external-delete"
Expand Down
26 changes: 15 additions & 11 deletions pkg/exposeservice/expose_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ func Create(
nodes []*v1beta1.Node,
targetPort int32,
) error {
addresses := []v1.EndpointAddress{}
for _, node := range nodes {
if node.PublicAddress == "" {
continue
}

addresses = append(addresses, v1.EndpointAddress{
IP: node.PublicAddress,
})
}

if len(addresses) == 0 {
return nil
}

svcName := fmt.Sprintf(models.ExposeServiceNameTemplate, clusterName)
service := &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -58,17 +73,6 @@ func Create(
},
}

addresses := []v1.EndpointAddress{}
for _, node := range nodes {
if node.PublicAddress == "" {
continue
}

addresses = append(addresses, v1.EndpointAddress{
IP: node.PublicAddress,
})
}

endpoints := &v1.Endpoints{
ObjectMeta: metav1.ObjectMeta{
Name: svcName,
Expand Down

0 comments on commit ace0764

Please sign in to comment.