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

Issue 1700097 - IdM creates pairs of left-right replicas rather than … #2147

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions daemons/ipa-slapi-plugins/topology/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef struct topo_replica {
char *total_attrs;
char *repl_attrs;
TopoReplicaSegmentList *repl_segments;
PRBool repl_segments_fetched;
TopoReplicaHost *hosts;
} TopoReplica;

Expand Down Expand Up @@ -311,6 +312,7 @@ Slapi_Entry *ipa_topo_util_get_entry(char *dn);
int ipa_topo_util_modify(Slapi_DN *entrySDN, Slapi_Mods *smods);
char *ipa_topo_util_get_pluginhost(void);
TopoReplica *ipa_topo_util_get_replica_conf(char *repl_root);
TopoReplicaSegmentList *ipa_topo_util_get_repl_segments(TopoReplica *replica);
TopoReplicaSegmentList *ipa_topo_util_get_replica_segments(TopoReplica *replica);
void ipa_topo_util_set_domain_level(void);
void ipa_topo_util_reset_init(char *repl_root);
15 changes: 9 additions & 6 deletions daemons/ipa-slapi-plugins/topology/topology_cfg.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

#include <nspr4/prtypes.h>

#include "topology.h"

/* two static data structures to hold the
Expand Down Expand Up @@ -562,7 +564,7 @@ ipa_topo_cfg_replica_segment_find(TopoReplica *replica, char *leftHost, char *ri
else reverse_dir = SEGMENT_BIDIRECTIONAL;

if (lock) slapi_lock_mutex(replica->repl_lock);
segments = replica->repl_segments;
segments = ipa_topo_util_get_repl_segments(replica);
while (segments) {

tsegm = segments->segm;
Expand Down Expand Up @@ -716,7 +718,7 @@ ipa_topo_cfg_segment_set_visited(TopoReplica *replica, TopoReplicaSegment *vsegm
char *rightHost = vsegm->to;

slapi_lock_mutex(replica->repl_lock);
segments = replica->repl_segments;
segments = ipa_topo_util_get_repl_segments(replica);
while (segments) {
tsegm = segments->segm;
if ( ((strcasecmp(leftHost,tsegm->from) == 0) && (strcasecmp(rightHost,tsegm->to) == 0) &&
Expand Down Expand Up @@ -754,10 +756,10 @@ ipa_topo_cfg_segment_add(TopoReplica *replica, TopoReplicaSegment *tsegm)
slapi_ch_calloc(1,sizeof(TopoReplicaSegmentList));
seglist->visited = 0;
seglist->segm = tsegm;
if (replica->repl_segments == NULL) {
if (ipa_topo_util_get_repl_segments(replica) == NULL) {
replica->repl_segments = seglist;
} else {
seglist->next = replica->repl_segments;
seglist->next = ipa_topo_util_get_repl_segments(replica);
replica->repl_segments = seglist;
}
slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM,
Expand All @@ -775,7 +777,7 @@ ipa_topo_cfg_segment_del(TopoReplica *tconf, TopoReplicaSegment *tsegm)
slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM,
"ipa_topo_cfg_segment_del: %s\n", tsegm->name);
slapi_lock_mutex(tconf->repl_lock);
segment = tconf->repl_segments;
segment = ipa_topo_util_get_repl_segments(tconf);
while (segment) {
if (segment->segm == tsegm) {
if (prev == NULL) {
Expand All @@ -802,6 +804,7 @@ ipa_topo_cfg_replica_new(void)
if (topoRepl) {
topoRepl->next = NULL;
topoRepl->repl_segments = NULL;
topoRepl->repl_segments_fetched = PR_FALSE;
topoRepl->repl_root = NULL;
topoRepl->strip_attrs = NULL;
topoRepl->total_attrs = NULL;
Expand Down Expand Up @@ -848,7 +851,7 @@ ipa_topo_cfg_replica_free(TopoReplica *tconf)
slapi_destroy_mutex(tconf->repl_lock);
slapi_ch_free_string(&tconf->shared_config_base);
slapi_ch_free_string(&tconf->repl_root);
seg = tconf->repl_segments;
seg = ipa_topo_util_get_repl_segments(tconf);
while (seg) {
seg_next = seg->next;
ipa_topo_cfg_segment_free(seg->segm);
Expand Down
2 changes: 1 addition & 1 deletion daemons/ipa-slapi-plugins/topology/topology_pre.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ ipa_topo_connection_fanout(TopoReplica *tconf, TopoReplicaSegment *tseg)
slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM,
"ipa_topo_connection_fanout for segment: %s\n",tseg->name);
/* lock it */
TopoReplicaSegmentList *seglist = tconf->repl_segments;
TopoReplicaSegmentList *seglist = ipa_topo_util_get_repl_segments(tconf);
while (seglist) {
segm = seglist->segm;
if (strcasecmp(segm->name, tseg->name) != 0) {
Expand Down
42 changes: 37 additions & 5 deletions daemons/ipa-slapi-plugins/topology/topology_util.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <dirsrv/slapi-plugin.h>
#include <nspr4/prtypes.h>
#include "topology.h"


Expand Down Expand Up @@ -204,6 +206,30 @@ ipa_topo_util_get_replica_conf(char *repl_root)
return topoRepl;
}

/* This routine just return the segments associated to
* a given replica.
* In addition it logs a warning that this segments (in memory) may
* be out of sync (shared config entries) because ipa_topo_util_start
* was called with a delay (DS startup or total init).
*/
TopoReplicaSegmentList *
ipa_topo_util_get_repl_segments(TopoReplica *replica)
{
if (!replica->repl_segments_fetched) {
int nb_segments = 0;
TopoReplicaSegmentList *segm = replica->repl_segments;
for(; segm; nb_segments++) segm = segm->next;

slapi_log_error(SLAPI_LOG_WARNING, IPA_TOPO_PLUGIN_SUBSYSTEM,
"ipa_topo_util_get_repl_segments: "
"in memory replica %d segments for %s "
"can differ from the shared tree. You may try to reduce %s\n",
nb_segments, replica->repl_root, CONFIG_ATTR_STARTUP_DELAY);
}
return replica->repl_segments;
}


TopoReplicaSegmentList *
ipa_topo_util_get_replica_segments(TopoReplica *replica)
{
Expand Down Expand Up @@ -241,7 +267,8 @@ ipa_topo_util_get_replica_segments(TopoReplica *replica)
}
slapi_free_search_results_internal(pb);
slapi_pblock_destroy(pb);
return replica->repl_segments;
replica->repl_segments_fetched = PR_TRUE;
return ipa_topo_util_get_repl_segments(replica);
}

int
Expand Down Expand Up @@ -512,7 +539,7 @@ ipa_topo_util_segm_modify (TopoReplica *tconf,
void
ipa_topo_util_remove_init_attr(TopoReplica *repl_conf, TopoReplicaAgmt *topo_agmt)
{
TopoReplicaSegmentList *seglist = repl_conf->repl_segments;
TopoReplicaSegmentList *seglist = ipa_topo_util_get_repl_segments(repl_conf);
TopoReplicaSegment *segment = NULL;
char *dirattr = NULL;

Expand Down Expand Up @@ -644,7 +671,7 @@ ipa_topo_util_update_agmt_list(TopoReplica *conf, TopoReplicaSegmentList *repl_s
"cannot read targethost: error %d\n", rc);
continue;
}
topo_agmt = ipa_topo_util_find_segment_agmt(conf->repl_segments,
topo_agmt = ipa_topo_util_find_segment_agmt(ipa_topo_util_get_repl_segments(conf),
ipa_topo_get_plugin_hostname(),
targetHost);
if (topo_agmt) {
Expand Down Expand Up @@ -720,7 +747,7 @@ ipa_topo_util_update_agmt_list(TopoReplica *conf, TopoReplicaSegmentList *repl_s
/* check if segments not covered by agreement exist
* add agreeement
*/
ipa_topo_util_missing_agmts_add_list(conf, conf->repl_segments,
ipa_topo_util_missing_agmts_add_list(conf, ipa_topo_util_get_repl_segments(conf),
ipa_topo_get_plugin_hostname());

error_return:
Expand Down Expand Up @@ -1190,6 +1217,11 @@ ipa_topo_util_segment_merge(TopoReplica *tconf,
/* merging is only done on one of the endpoints of the segm */
return;
}
if (!tconf->repl_segments_fetched) {
/* Let's fetch the in memory segment from the shared config area */
ipa_topo_util_get_replica_segments(tconf);
}


if (tsegm->direct == SEGMENT_LEFT_RIGHT) {
ex_segm = ipa_topo_cfg_replica_segment_find(tconf, tsegm->from, tsegm->to,
Expand Down Expand Up @@ -1374,7 +1406,7 @@ ipa_topo_util_update_segments_for_host(TopoReplica *conf, char *hostname)
}
/* segment has been recreated and added during postp of segment_write
* but the correct agreement rdn was lost, set it now */
topo_agmt = ipa_topo_util_find_segment_agmt(conf->repl_segments,
topo_agmt = ipa_topo_util_find_segment_agmt(ipa_topo_util_get_repl_segments(conf),
ipa_topo_get_plugin_hostname(),
hostname);
if (topo_agmt) {
Expand Down