-
Notifications
You must be signed in to change notification settings - Fork 0
#271: Implemented checking SCS content for completeness and correctness #272
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
Conversation
|
||
def verify_connection(scs: Secrets) -> int: | ||
if BackendSelector(scs).use_itde: | ||
# Question: Is it OK, to let bring_itde_up modify the SCS content, here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it OK, to let bring_itde_up()
modify the SCS content, here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional question:
- Should the command line really launch the IDTE only for verifying the connection parameters?
- As actually the ITDE does not require actual connection parameters but only offers optional(!) configuration of disk and mem size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we need to bring the ITDE up and take it down, in a try .. finally
manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the docstring.
But the question regarding the ITDE is still pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
We had the initial discussion, that actually the CLI does not interact too much with the ITDE.
-
Additionally, launching the ITDE takes quite some time and hence I am not sure whether a user really wants to verify launching and connecting to a Docker DB controlled by ITDE without any significant parameters needing to be configured and hence no significant parameters needing to be verified either.
-
Binging the ITDE up and take it down, in a
try ... finally
manner still requires some additional logic compared to the other DB instance variants and hence, I assume, we will need a test, which will again increase the size of this PR.
All in all, I want to ask for confirmation if the benefits of this feature justify the additional effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, it doesn't really makes sense to test the connection to the ITDE. If we want to make sure the parameters are correct, we should make sure their format is checked while setting them.
def check(self): | ||
""" | ||
Check if the content of the SCS is complete wrt. the selected | ||
backend as the required options depend on the selected backend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please say that the function raises the ScsCliError
if the check fails. I have to look at the code to figure this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Please see next push updating the docstring.
def get_option_set(scs_file: Path) -> OptionSet: | ||
""" | ||
Return an instance of an OptionSet if the SCS contains a proper | ||
backend selection. Otherwise report an error and return None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the docstring according to your latest changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See next push.
@add_params(SCS_OPTIONS) | ||
@click.option( | ||
"--connect/--no-connect", | ||
is_flag=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the default depend on the backend?
For a DB that is already running it would be a good idea to check that the configuration works. However, for the Docker DB it's a different story. On one hand, starting it up takes time. On the other hand, all you need to check is that the memory parameters are with reasonable range. If we can't start the ITDE it must be for some unrelated reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I very much agree on your statements.
So what should we do then?
Not verify Docker DB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make the default = False for the DockerDB and True otherwise. Maybe slightly awkward to implement, but not too difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it seems to be not that easy.
The check
CLI command is common for all DB instance variants. Hence, the command does not know up-front which backend to check but reads the backend from the SCS, instead.
That means that the default value for the CLI option --connect
needs to be detected dynamically, not during the CLI configuration and definition of the CLI options, but later during runtime.
This has the effect, that we cannot use a simple boolean CLI option here, but we need a three-state flag
DEFAULT
, i.e.TRUE
for SaaS and on-premise,FALSE
for ITDE / Docker DB.TRUE
(force connect)FALSE
(never verify connect)
This in turn requires adding an Enum class and I think we should also add dedicated tests.
It also invalidates the current CLI option --connect/--no-connect
using Click's is_flag=True
feature.
Hence, we need to specify two separate Options operating on the same three-state flag. And each CLI option requires a separate help string.
Additionally, I think the default depending on the DB instance variant is also harder to explain to the user.
All this increases the size of the current PR by more than a few lines.
Again, if I am not wrong, I would like to ask for confirmation if the benefits of this feature justify the required effort.
report.warning(f"Bring up ITDE currently disabled") | ||
return | ||
try: | ||
open_pyexasol_connection(scs).execute("SELECT 1 FROM DUAL").fetchone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should verify_connection()
(CLI command scs check --connect
) verify the bucketfs, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is it sufficient to list the BFS contents in the test?
- What is the expectation?
- Are there any default files we expect to be contained in the BFS?
- Or is it acceptable to modify the BFS contents for the sake of testing the connection?
- Should the test also do a cleanup after having verified the connection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add verification for bucket FS parameters:
- list contents
- choose unique file name
- upload and download sample file
- verify identical content
- remove the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the BucketFS verification to a separate ticket/PR:
|
||
def verify_connection(scs: Secrets) -> int: | ||
if BackendSelector(scs).use_itde: | ||
# Question: Is it OK, to let bring_itde_up modify the SCS content, here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, it doesn't really makes sense to test the connection to the ITDE. If we want to make sure the parameters are correct, we should make sure their format is checked while setting them.
report.warning(f"Bring up ITDE currently disabled") | ||
return | ||
try: | ||
open_pyexasol_connection(scs).execute("SELECT 1 FROM DUAL").fetchone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
try: | ||
open_pyexasol_connection(scs).execute("SELECT 1 FROM DUAL").fetchone() | ||
except Exception as ex: | ||
raise ScsCliError(f"Failed to connect to the configured database {ex}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, if only showing the exception message is helpful, maybe we should format the whole exception with stack trace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see next push for improved exception handling.
oset = get_option_set(scs_file) | ||
for o in oset.options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of the short variable names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see next push, using a more expressive name.
Co-authored-by: Torsten Kilias <[email protected]>
option_set = get_option_set(scs_file) | ||
if not option_set: | ||
return 1 | ||
for o in option_set.options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name o
is still not really meaning full
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, please see latest push.
|
Closes #271