Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kibana and Cerebro services are not deleted when deleting ElasticsearchCluster #291

Open
xyphr opened this issue Mar 7, 2019 · 2 comments

Comments

@xyphr
Copy link
Contributor

xyphr commented Mar 7, 2019

Currently, when deleting an ElasticsearchCluster the services for Kibana and Cerebro are left behind. The delete services method doesn't have the code for deleting those two services.

@xyphr
Copy link
Contributor Author

xyphr commented Mar 7, 2019

This seems to fix it

diff --git a/pkg/k8sutil/services.go b/pkg/k8sutil/services.go
index e9deabb0..8274697f 100644
--- a/pkg/k8sutil/services.go
+++ b/pkg/k8sutil/services.go
@@ -262,19 +262,17 @@ func (k *K8sutil) DeleteServices(clusterName, namespace string) error {
 
        for component, _ := range mgmtServices {
 
+               fullClientServiceName := fmt.Sprintf("%s-%s", component, clusterName)
                // Check if service exists
-               s, _ := k.Kclient.CoreV1().Services(namespace).Get(component, metav1.GetOptions{})
-
-               // Service exists, delete
-               if len(s.Name) >= 1 {
-                       fullClientServiceName := fmt.Sprintf("%s-%s", component, clusterName)
-
+               _, err := k.Kclient.CoreV1().Services(namespace).Get(fullClientServiceName, metav1.GetOptions{})
+               if err != nil {
+                       logrus.Error("Could not find service "+fullClientServiceName+":", err)
+               } else {
                        if err := k.Kclient.CoreV1().Services(namespace).Delete(fullClientServiceName, &metav1.DeleteOptions{}); err != nil {
                                logrus.Error("Could not delete service "+fullClientServiceName+":", err)
                        }
                        logrus.Infof("Deleted service: %s", fullClientServiceName)
                }
-
        }
 
        return nil

@stevesloka
Copy link
Member

Hey @xyphr would you like to send up a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants