This fix allows the removal of segments, where not both endpoints of the segments are managed. These segments can exist after deliberately disconnecting a topology by removal of a central node, a fix to automatically remove dangling segments is in process, but it cannot handle all situations, especially if the removed server is no longer working and the topology is already broken before the removal. In these cases a manual cleanup must be possible and is addressed in this patch

Ludwig
>From 82e0e824bfb1b77329bc10ed582e75a951a6bf3c Mon Sep 17 00:00:00 2001
From: Ludwig Krispenz <lkris...@redhat.com>
Date: Wed, 1 Jul 2015 11:55:13 +0200
Subject: [PATCH] allow deletion of segment if endpoint is not managed

in the preop check do not reject the deletion of a segment, if not both endpoints
are managed servers for the suffix

thisis part of work for ticlet #5072
---
 daemons/ipa-slapi-plugins/topology/topology.h      |  1 +
 daemons/ipa-slapi-plugins/topology/topology_pre.c  |  5 +++++
 daemons/ipa-slapi-plugins/topology/topology_util.c | 11 +++++++++++
 3 files changed, 17 insertions(+)

diff --git a/daemons/ipa-slapi-plugins/topology/topology.h b/daemons/ipa-slapi-plugins/topology/topology.h
index 953a5e33f2fac379a9621910a86aa8ce5a8c89b2..be9737679153ad4b2f8d07bc1622bcd6775bc8b1 100644
--- a/daemons/ipa-slapi-plugins/topology/topology.h
+++ b/daemons/ipa-slapi-plugins/topology/topology.h
@@ -283,6 +283,7 @@ void ipa_topo_util_delete_segments_for_host(char *repl_root, char *delhost);
 
 int ipa_topo_util_entry_is_candidate(Slapi_Entry *e);
 int ipa_topo_util_target_is_managed(Slapi_Entry *e);
+int ipa_topo_util_segment_is_managed(TopoReplica *tconf, TopoReplicaSegment *tsegm);
 char * ipa_topo_util_get_segm_attr(TopoReplicaAgmt *agmt, char *attr_type);
 void ipa_topo_util_set_segm_attr(TopoReplicaAgmt *agmt, char *attr_type,
                                  char *attr_val);
diff --git a/daemons/ipa-slapi-plugins/topology/topology_pre.c b/daemons/ipa-slapi-plugins/topology/topology_pre.c
index 0b9f8900940eda4429bb26fe6fc8118e2a71932b..952068e7dd24d30054c0bd2aaa2efd64d2a6618f 100644
--- a/daemons/ipa-slapi-plugins/topology/topology_pre.c
+++ b/daemons/ipa-slapi-plugins/topology/topology_pre.c
@@ -406,6 +406,11 @@ ipa_topo_check_topology_disconnect(Slapi_PBlock *pb)
                             "segment to be deleted does not exist\n");
             goto done;
         }
+        if (!ipa_topo_util_segment_is_managed(tconf,tsegm)) {
+            /* not both endpoints are managed servers, delete is ok */
+            rc = 0;
+            goto done;
+        }
         /* check if removal of segment would break connectivity */
         fanout = ipa_topo_connection_fanout(tconf, tsegm);
         if (fanout == NULL) goto done;
diff --git a/daemons/ipa-slapi-plugins/topology/topology_util.c b/daemons/ipa-slapi-plugins/topology/topology_util.c
index ea9a9c74c3bb755decadb80c82225a0047d7bdeb..523f6123c6db942860939842b64a098dd25839c9 100644
--- a/daemons/ipa-slapi-plugins/topology/topology_util.c
+++ b/daemons/ipa-slapi-plugins/topology/topology_util.c
@@ -1036,6 +1036,17 @@ ipa_topo_util_target_is_managed(Slapi_Entry *e)
 
 }
 
+int ipa_topo_util_segment_is_managed(TopoReplica *tconf, TopoReplicaSegment *tsegm)
+{
+    int ret = 0;
+
+    if (ipa_topo_cfg_host_find(tconf, tsegm->from, 1) &&
+        ipa_topo_cfg_host_find(tconf, tsegm->to, 1)) {
+        ret = 1;
+    }
+    return ret;
+}
+
 void
 ipa_topo_util_segm_update (TopoReplica *tconf,
                                TopoReplicaSegment *tsegm,
-- 
2.1.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to