Skip to content

Conversation

@bbotella
Copy link
Contributor

This is a follow up PR on top of
#4255

# AsyncProfiler Flags
#-Dcassandra.async_profiler.enabled=true|false
#-Dcassandra.async_profiler.advanced_mode=true|false
#-Dcassandra.async_profiler.output_directory=/tmp/cassandra-profiling
Copy link
Contributor

Choose a reason for hiding this comment

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

the parameter is declared but not implemented, a logging directory probably is a better default location ...


public interface AsyncProfilerMBean
{
void start(String event, String outputFormat, int timeout, String outputPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

timeout - duration probably a better name for the parameter + a time unit as a a suffix would be helpful

outputPath - using a path is too dangerous from security point of view, a path to a data file or another file can be specified to cause a DoS (explicitly or using tricks like ../../.., so it is better to allow only a file name with explictly defined set of symbols to use (allowlist is safer than an denylist)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left it at timeout, as it is what the actual async profiler is using.

For the outputPath, that makes sense. Changing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding timeout - yes, I mixed it up with -d option and what one is asprof option only.

}
catch (Throwable t)
{
System.out.println("async-profiler initialization ERROR");
Copy link
Contributor

Choose a reason for hiding this comment

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

printing to out instead of using logging within Cassandra daemon

{

private static AsyncProfilerService profiler;
private static String testOutputFile = "/tmp/test-profile.html";
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use TemporaryFolder?

@Before
public void setUp()
{
ASYNC_PROFILER_ENABLED.setBoolean(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use org.apache.cassandra.distributed.shared.WithProperties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the tests are needed that flag to be true. I think this setup helps with code duplication?

}

@Test
public void testUnsafeExecute() {
Copy link
Contributor

Choose a reason for hiding this comment

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

the goal of the test is not clear..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to set on stone that the safe profiler will fail with arbitrary commands.

public class Profile extends AbstractCommand {

@Option(names = {"-s", "--start"}, description = "Start profiling")
public boolean start;
Copy link
Contributor

Choose a reason for hiding this comment

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

should start/stop/raw be a subcommand? Or we need some another way to make the options exclusive, they are not used together based on the execute logic..

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.

3 participants