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

Introduce logger REST API to manage log level at runtime #9161

Merged
merged 5 commits into from
Mar 21, 2018
Merged

Conversation

benoitf
Copy link
Contributor

@benoitf benoitf commented Mar 21, 2018

What does this PR do?

following this previous comment #8997 (comment)

with this Rest API, it's possible to create new logger with log level, list all loggers defined with loglevel, change level on a given logger, etc

On multi-user, System#MANAGE_SYSTEM permission is required.

Change-Id: I1c105aca33cc88f90270ade4d792d3a75191740a
Signed-off-by: Florent BENOIT fbenoit@redhat.com

What issues does this PR fix or reference?

#8997

It's possible to create new logger with log level, list all loggers defined with loglevel, change level on a given logger, etc

Change-Id: I1c105aca33cc88f90270ade4d792d3a75191740a
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
@benoitf benoitf added kind/enhancement A feature request - must adhere to the feature request template. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. labels Mar 21, 2018
@benoitf benoitf self-assigned this Mar 21, 2018
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

why it's provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 the dependency

<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-persist</artifactId>
<scope>provided</scope>
Copy link
Contributor

Choose a reason for hiding this comment

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

why its provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 the dependency

* @author Florent Benoit
*/
@Api(value = "/logger", description = "Logger REST API")
@Path("/logger")
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make sure this service is protected with authentification in multi-user mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now it was not enabled in multi user mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

permission mechanism added

@ApiResponses({
@ApiResponse(code = 200, message = "The loggers successfully fetched"),
})
public List<LoggerDto> getLoggers() {
Copy link
Contributor

@skabashnyuk skabashnyuk Mar 21, 2018

Choose a reason for hiding this comment

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

should we add pagination here? with limit 30 by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added pagination

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

Cool and useful feature 👍
But It looks like authorization is missed here. I guess It's not OK to this API should is available for all authenticated users. Or I missed something?

</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-db-vendor-h2</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

Please revise dependencies list, I guess you don't need che-core-db-vendor-h2, org.eclipse.persistence.jpa dependencies, do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I need to cleanup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ApiResponses({
@ApiResponse(code = 200, message = "The logger successfully created"),
})
public LoggerDto createLogger(
Copy link
Member

Choose a reason for hiding this comment

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

I think this method should be covered with System#MANAGE_SYSTEM permission actions. Or maybe even all methods of this service. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

permission mechanism added

@benoitf
Copy link
Contributor Author

benoitf commented Mar 21, 2018

I should have specified that for now there is now permission check on this service, mainly because I added only this service on the single user and not the multi user.

https://github.com/eclipse/che/blob/fc3fd1dc83ba7d7305e54c956353ebdae7b2aedb/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java#L249-L269

But yes I wanted to include it as well for multi-user, just wanted to discuss on how you were seeing the permission that would be required to call it. It seems System#MANAGE_SYSTEM is a choice ?

Change-Id: I626a03fde2ea2ecc65bee50dbae9f4135b46fdcc
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
@skabashnyuk
Copy link
Contributor

It seems System#MANAGE_SYSTEM is a choice

I think yes.

Change-Id: I4596f22ae6f28a9317d147b4f29bb090ddb7e9c6
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
@benoitf
Copy link
Contributor Author

benoitf commented Mar 21, 2018

ok I have added permission stuff and then enabled as well logger api for multi user mode

Change-Id: I59a1136c450103dec23bf4b1b5781a9fbeea1b91
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
Change-Id: I56aa8df29c8ee3ab876c97812b6a139854914a0f
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

LGTM

</dtoPackages>
<outputDirectory>${dto-generator-out-directory}</outputDirectory>
<genClassName>org.eclipse.che.api.logger.server.dto.DtoServerImpls</genClassName>
<impl>server</impl>
Copy link
Member

Choose a reason for hiding this comment

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

I'd say that it is better to generate DTO server implementations in server module. Because a shared module is supposed to contain only shared things which are compatible with dependent modules.
So GWT module will get classes that can't be used there.
WDYT? Does it make sense?

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 copied content from workspace-shared module so maybe if I'm doing it wrong there is an issue with this module as well ?

it's up to you, let me know what is the better approach.
maybe client or server should be additional classifier artifacts

main artifacts = interfaces
client classifier = for gwt
server classifier = for server

Copy link
Member

Choose a reason for hiding this comment

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

I like the idea with classifiers.

Is an issue with this module as well

I think yes.

I think now we can leave it as it is. And later rework it in all places.
@skabashnyuk WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can revise it later.

<plugin>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto-maven-plugin</artifactId>
<version>${project.version}</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

should there ${che.version} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, ok, in theory both are fine, but I thought we use che.version in such places so it seems it is ok

@benoitf benoitf merged commit f051b7f into master Mar 21, 2018
@benoitf benoitf deleted the logger-rest branch March 21, 2018 14:17
@benoitf benoitf added this to the 6.3.0 milestone Mar 21, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants