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

DATAGO-79772: Cloud managed EMA must not stream configPush logs to EP Core #191

Merged

Conversation

rudraneel-chakraborty
Copy link
Contributor

@rudraneel-chakraborty rudraneel-chakraborty commented Jul 4, 2024

What is the purpose of this change?

Currently, Self managed EMA streams Terraform execution logs to ep-core. These logs end up in Datadog and aids in debuggability. Cloud managed EMA already has DD integration. So we intend to disable the log streaming feature if the ema is running in cloud managed mode

How was this change implemented?

Java code change

How was this change tested?

IT

Is there anything the reviewers should focus on/be aware of?

...

Comment on lines -53 to -73
public void deleteExecutionLogFiles(List<Path> listOfExecutionLogFiles) {
boolean allFilesDeleted = listOfExecutionLogFiles
.stream()
.allMatch(this::deleteExecutionLogFile);
if (!allFilesDeleted) {
throw new IllegalArgumentException("Some of the execution log files were not deleted. Please check the logs");
}
}

private boolean deleteExecutionLogFile(Path path) {
try {
if (Files.exists(path)) {
Files.delete(path);
}
} catch (IOException e) {
log.warn("Error while deleting execution log at {}", path, e);
return false;
}
return true;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted these methods as is to CommandManager as these methods are better suited there

Comment on lines -164 to -177
@Bean
@Qualifier("realCommandLogStreamingProcessor")
public CommandLogStreamingProcessor realCommandLogStreamingProcessor(CommandLogsPublisher commandLogsPublisher,
EventPortalProperties eventPortalProperties,
ObjectMapper objectMapper) {
return new CommandLogStreamingProcessor(commandLogsPublisher, eventPortalProperties, objectMapper);
}

@Bean
@Qualifier("mockedCommandLogStreamingProcessor")
@Primary
public CommandLogStreamingProcessor mockedCommandLogStreamingProcessor() {
return mock(CommandLogStreamingProcessor.class);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

@@ -45,14 +48,14 @@ public class CommandManager {
private final MessagingServiceDelegateService messagingServiceDelegateService;
private final EventPortalProperties eventPortalProperties;
private final ThreadPoolTaskExecutor configPushPool;
private final CommandLogStreamingProcessor commandLogStreamingProcessor;
private final Optional<CommandLogStreamingProcessor> commandLogStreamingProcessorOpt;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commandLogStreamingProcessor is absent for cloud managed mode. So making it optional

Comment on lines +112 to +114
if (commandLogStreamingProcessorOpt.isPresent()) {
streamCommandExecutionLogToEpCore(request, command, executionLog);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only stream if the commandLogStreamingProcessorOpt is present (e.g. in self managed mode)

@rudraneel-chakraborty rudraneel-chakraborty changed the title DATAGO-79772 wip DATAGO-79772: Cloud managed EMA must not stream configPush logs to EP Core Jul 7, 2024
@rudraneel-chakraborty rudraneel-chakraborty marked this pull request as ready for review July 7, 2024 23:59
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD)
//CPD-OFF
class CloudManagedEMACommandManagerTests {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a separate class as we want to load a new application context in cloud managed mode

Copy link
Collaborator

@moodiRealist moodiRealist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but application.properties file must be rolled back before I can approve.

id: gateway
name: evmr1
id: f0ydyzsr1jp
name: POCCloudManagedEMAEVMR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo these changes.

Copy link
Contributor Author

@rudraneel-chakraborty rudraneel-chakraborty Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. See slack message on how I mitigated the impact

@@ -37,6 +38,9 @@ public class TerraformManager {
private final TerraformProperties terraformProperties;
private final TerraformClientFactory terraformClientFactory;


private boolean isManagedAgent;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this boolean used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Good Catch

@@ -7,6 +7,7 @@
import com.solace.maas.ep.event.management.agent.plugin.command.model.CommandResult;
import com.solace.maas.ep.event.management.agent.plugin.command.model.JobStatus;
import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants;
import com.solace.maas.ep.event.management.agent.plugin.messagingService.event.EventProperty;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this library doesn't have PMD checks. Otherwise, it should have failed the build for un-used imports.

Please just roll-back this file considering there is no relevant change here.

Copy link

SonarQube Quality Gate

Quality Gate failed

Failed condition 75.9% 75.9% Coverage on New Code (is less than 80%)

See analysis details on SonarQube

@rudraneel-chakraborty rudraneel-chakraborty merged commit 9573772 into main Jul 10, 2024
5 of 6 checks passed
@rudraneel-chakraborty rudraneel-chakraborty deleted the DATAGO-79772-no-log-streaming-to-ep-for-cema branch July 10, 2024 13:22
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

Successfully merging this pull request may close these issues.

2 participants