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

new storage #717

Merged
merged 1 commit into from
Jul 12, 2017
Merged

new storage #717

merged 1 commit into from
Jul 12, 2017

Conversation

gyorb
Copy link
Contributor

@gyorb gyorb commented Jul 10, 2017

Resolves #683

@gyorb gyorb added the WIP 💣 Work In Progress label Jul 10, 2017
Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

Some initial comments, not a throughout review, since it is still work in progress.

// store checker run related data to the database
// by default updates the results if name was already found
// using the force flag removes existing analysis results for a run
i64 addCheckerRun(
Copy link
Contributor

Choose a reason for hiding this comment

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

The comments should be full sentences.

Does the force parameter make sense in the new model? Maybe it should be removed?

4: bool force)
throws (1: shared.RequestFailed requestError),

bool replaceConfigInfo(
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the whole run is stored again in incremental mode, maybe this API call no longer makes sense.

@@ -22,6 +21,7 @@
from libcodechecker.analyze.analyzers import result_handler_clang_tidy
from libcodechecker.analyze.analyzers import result_handler_plist_to_db
from libcodechecker.analyze.analyzers import result_handler_plist_to_stdout
from libcodechecker.cmd.cmd_line_client import setup_client
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a pretty strange dependency for this module.

Copy link
Contributor

@whisperity whisperity Jul 10, 2017

Choose a reason for hiding this comment

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

setup_client handles authentication and creates the local Thrift endpoint that can be used (after an optional authentication, if needed) to transmit data.

I would definitely introduce, akin to the other imports like this, a notice:

# TODO: This is a cross-subpackage reference.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe such code should be pulled out from the cmd_line_client into a separate helper module to avoid layering violations.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's why I'd go with introducing a TODO at this point. There are a lot of such TODOs that are to be handled later on. I would like this pull request to be minimal in terms of changes related to the new storage system, for review and history's sake.

Cross-package imports are another concern, they can be refactored out in a batch.

Copy link
Contributor

Choose a reason for hiding this comment

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

In these scenarios I am more fond of having a separate pull request to pull this code out and rebase this one after that one is accepted, to avoid the excess amount of TODOs.

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 know this is not the way it should be handled but I did not wanted to do more refactoring during the development and importing this way was easy to get the functionality.

I've factored out to an api_client package which can be used by the command line client and the store.

self.buildaction.analyzer_type,
source_file_name)

assert self.analyzer_returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe assert is not the best way to handle the error here. The return code is not zero is not due to a programming error. It might be a configuration error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually after splitting up the analyze and store functionality the analyzer return code is set in store.py which is not connected to the actual analysis.
Checking this value with the new setup is not necessary.

README.md Outdated

### Start a web server

Start a CodeChecker web and storage server in another terminal or as a background process. By default it will listen on `localhost:8001'
Copy link
Contributor

Choose a reason for hiding this comment

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

Sentence is not terminated.

1: string command,
2: string name,
3: string version,
4: bool force)
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, please normalise the style of this file. At some places, the closing ) of the argument list is newline, in some cases (like this one), it is not.

@@ -279,6 +285,93 @@ service codeCheckerDBAccess {
2: i64 new_run_id,
3: DiffType diff_type,
4: ReportFilterList reportFilters)
throws (1: shared.RequestFailed requestError)
throws (1: shared.RequestFailed requestError),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does calling this file report_viewer_server.thrift proper anymore? It integrates multiple functionality. Maybe report_server.thrift?

Copy link
Contributor

Choose a reason for hiding this comment

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

☑️ This has been done, just GitHub is not picking it up. 😉





Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather, though, introduce some comments that separate the functionality handled by this service.

@@ -86,6 +87,12 @@ _CodeChecker_. It analyzes your project and stores the reported code defects
in a database, which can be viewed in a Web Browser later on (via `CodeChecker
server`).

With the server command start the server where the results will be stored and
Copy link
Contributor

Choose a reason for hiding this comment

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

I would somehow merge this with the previous paragraph. CodeChecker server is mentioned twice.

@@ -100,6 +118,20 @@ def add_arguments_to_parser(parser):
"the '--name' parameter given to 'codechecker-"
"analyze' will be used, if exists.")

parser.add_argument('--host',
Copy link
Contributor

Choose a reason for hiding this comment

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

We should introduce an argument_group for these arguments and explain that they are used to specify where the resultes are stored.

@@ -152,6 +152,20 @@ def add_arguments_to_parser(parser):
"the '--name' parameter given to 'codechecker-"
"analyze' will be used, if exists.")

parser.add_argument('--host',
Copy link
Contributor

Choose a reason for hiding this comment

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

(Same as comment in store.py.)

default='localhost',
help="CodeChecker server host.")

parser.add_argument('--port',
Copy link
Contributor

Choose a reason for hiding this comment

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

CodeChecker server and CodeChecker cmd has -p as shorthand for --port.

@gyorb gyorb force-pushed the one_server branch 5 times, most recently from 8127d19 to 395d679 Compare July 10, 2017 16:05
Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

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

Very minor stuff. Otherwise, the code looks good.

I'll come up with better help messages, though.

LOG.critical("No authentication methods were reported by the server "
"that this client could support.")
sys.exit(1)
login = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Statement can be simplified: login = 'logout' in args. And then the variable can be inlined into the function call.

from libcodechecker import suppress_file_handler
from libcodechecker.api_client.client import setup_client
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing, but I don't like the package name for this. We should make it somehow inline with the not-subcommand-related libcodechecker subfolders, like libauth or libhandlers.

Maybe it could go straight into libauth? Or libclient? Something with lib on the beginning of it.

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 would choose the libclient name.

@@ -11,6 +11,7 @@
import unittest

from codeCheckerDBAccess.ttypes import ReportFilter
from shared.ttypes import SuppressBugData
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this import used?

@@ -12,6 +12,7 @@
import random
import string
import unittest
import base64
Copy link
Contributor

Choose a reason for hiding this comment

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

Import name alphabetical order violated.

@gyorb gyorb force-pushed the one_server branch 5 times, most recently from 189814a to 5307da2 Compare July 11, 2017 11:54
@whisperity
Copy link
Contributor

@gyorb There is an issue. CodeChecker cmd login on an authentication-requiring server simply states that you need to authenticate (via CodeChecker cmd login) and then the process exits. (With return code 0.)

@gyorb
Copy link
Contributor Author

gyorb commented Jul 11, 2017

@whisperity the login problem should be fixed now

@gyorb gyorb force-pushed the one_server branch 2 times, most recently from 55f1a18 to f1aadbf Compare July 11, 2017 15:54
@whisperity
Copy link
Contributor

CodeChecker cmd login --logout is broken. It states "You are already logged in." and does not terminate the session.


if auth_token and handshake.sessionStillActive:
LOG.info("You are already logged in.")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

This early return prevents logout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this.

Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

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

Apart from the --logout issue mentioned earlier (that was not made broken in the current changeset, it seems it was broken and not triaged earlier!) and a little comment, looking good. 😉

run_id)

elif buildaction.analyzer_type == CLANG_TIDY:
res_handler = result_handler_clang_tidy.ClangTidyPlistToDB(
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this distintiction here made result_handler_clang_tidy.ClangTidyPlistToDB an obsolete class. Is this intended?

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 the storing of plist files to the database should not depend on the analyzer which generated it.
This functionality should be refactored so that there should be only one plist to database handler.

I did not wanted to increase the size of this pull request with this refactoring. It should be a separate development.

Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

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

Oh, yeah, one more thing: We should introduce a simple test case somewhere that covers (maybe tests/functional/authentication is the best place for this?) getting an error if store is called with a server and without authentication.

One server should handle all of the requests to store and view the results.

* merge report server api and implementation into the report viewer
* only one common server is started to store and view the results
* authentication is introduced for the storage api too
* store and check should use a codechecker server host and port
  no direct connection to the database is available
* database arguments in store and check are deprecated
* authentication and client api was factored out from the command
  line client modul to a common client module
* new test which tries to store results to an authenticated server
@gyorb gyorb removed the WIP 💣 Work In Progress label Jul 12, 2017
@dkrupp dkrupp merged commit 598ead7 into Ericsson:master Jul 12, 2017
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.

4 participants