Skip to content

Commit

Permalink
add prints to observe issue
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Nov 22, 2023
1 parent fcdfb3c commit 513277e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified build/distributions/opensearch-security-2.11.1.0-SNAPSHOT.jar
Binary file not shown.
Binary file modified build/distributions/opensearch-security-2.11.1.0-SNAPSHOT.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ protected ConfigUpdateResponse newResponse(

@Override
protected ConfigUpdateNodeResponse nodeOperation(final NodeConfigUpdateRequest request) {

System.out.println("Reloading configuration");
configurationRepository.reloadConfiguration(CType.fromStringValues((request.request.getConfigTypes())));

System.out.println("Invalidating configuration cache");
backendRegistry.get().invalidateCache();
return new ConfigUpdateNodeResponse(clusterService.localNode(), request.request.getConfigTypes(), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ private ConfigurationRepository(
TimeUnit.SECONDS.sleep(1);
}

Thread.sleep(5000);

if (installDefaultConfig.get()) {

try {
Expand Down Expand Up @@ -216,6 +218,7 @@ private ConfigurationRepository(
}

while (!dynamicConfigFactory.isInitialized()) {
System.out.println("Dynamic config factory is NOT initialized");
try {
LOGGER.debug("Try to load config ...");
reloadConfiguration(Arrays.asList(CType.values()));
Expand Down Expand Up @@ -363,10 +366,13 @@ public void setDynamicConfigFactory(DynamicConfigFactory dynamicConfigFactory) {
* @return can also return empty in case it was never loaded
*/
public SecurityDynamicConfiguration<?> getConfiguration(CType configurationType) {
System.out.println("The CTYPE is requested in getConfiguration is: " + configurationType.toString());
SecurityDynamicConfiguration<?> conf = configCache.getIfPresent(configurationType);
if (conf != null) {
System.out.println("There was an entry in the configCache so returning a deep clone");
return conf.deepClone();
}
System.out.println("Returning an empty Security Dynamic Configuration since there was no matching cache entry");
return SecurityDynamicConfiguration.empty();
}

Expand All @@ -381,7 +387,7 @@ public void reloadConfiguration(Collection<CType> configTypes) throws ConfigUpda
LOCK.unlock();
}
} else {
throw new ConfigUpdateAlreadyInProgressException("A config update is already imn progress");
throw new ConfigUpdateAlreadyInProgressException("A config update is already in progress");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Expand Down Expand Up @@ -451,7 +457,7 @@ public Map<CType, SecurityDynamicConfiguration<?>> getConfigurationsFromIndex(

} else {
// wait (and use new layout)
LOGGER.debug("security index not exists (yet)");
LOGGER.debug("security index does not exist (yet)");
retVal.putAll(
validate(cl.load(configTypes.toArray(new CType[0]), 10, TimeUnit.SECONDS, acceptInvalid), configTypes.size())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ public final static SecurityDynamicConfiguration<?> addStatics(SecurityDynamicCo
return original;
}

protected final Logger log = LogManager.getLogger(this.getClass());
private final ConfigurationRepository cr;

protected final Logger log = LogManager.getLogger(this.getClass());
private final AtomicBoolean initialized = new AtomicBoolean();
private final EventBus eventBus = EVENT_BUS_BUILDER.build();
private final Settings opensearchSettings;
Expand Down Expand Up @@ -170,8 +171,11 @@ public DynamicConfigFactory(
@Override
public void onChange(Map<CType, SecurityDynamicConfiguration<?>> typeToConfig) {

SecurityDynamicConfiguration<?> actionGroups = cr.getConfiguration(CType.ACTIONGROUPS);
System.out.println("Change detected at top of onChange in DCM");
config = cr.getConfiguration(CType.CONFIG);
System.out.println("The returned config at top of onChange is of implementing class " + config.getImplementingClass() + " and entries " + config.getCEntries());

SecurityDynamicConfiguration<?> actionGroups = cr.getConfiguration(CType.ACTIONGROUPS);
SecurityDynamicConfiguration<?> internalusers = cr.getConfiguration(CType.INTERNALUSERS);
SecurityDynamicConfiguration<?> roles = cr.getConfiguration(CType.ROLES);
SecurityDynamicConfiguration<?> rolesmapping = cr.getConfiguration(CType.ROLESMAPPING);
Expand Down Expand Up @@ -242,6 +246,7 @@ public void onChange(Map<CType, SecurityDynamicConfiguration<?>> typeToConfig) {

if (config.getImplementingClass() == ConfigV7.class) {
// statics
System.out.println("At top of if statement since implementing class is ConfigV7");

if (roles.containsAny(staticRoles)) {
throw new StaticResourceException("Cannot override static roles");
Expand Down Expand Up @@ -295,6 +300,15 @@ public void onChange(Map<CType, SecurityDynamicConfiguration<?>> typeToConfig) {

} else {

System.out.println("At top of else statement");

if (config.getImplementingClass() == null) {
System.out.println("Config is null");
return;
}

System.out.println("Config is not null so treating as v6");

// rebuild v6 Models
dcm = new DynamicConfigModelV6(getConfigV6(config), opensearchSettings, configPath, iab);
ium = new InternalUsersModelV6((SecurityDynamicConfiguration<InternalUserV6>) internalusers);
Expand All @@ -319,8 +333,8 @@ public void onChange(Map<CType, SecurityDynamicConfiguration<?>> typeToConfig) {
eventBus.post(audit);
}

System.out.println("Setting initialized to true at bottom of onChange" );
initialized.set(true);

}

private static ConfigV6 getConfigV6(SecurityDynamicConfiguration<?> sdc) {
Expand Down

0 comments on commit 513277e

Please sign in to comment.