Skip to content

Conversation

ckunki
Copy link
Contributor

@ckunki ckunki commented Oct 1, 2025

Closes #271


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?
Copy link
Contributor Author

@ckunki ckunki Oct 1, 2025

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?

Copy link
Contributor Author

@ckunki ckunki Oct 1, 2025

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See my comment above.

Copy link
Collaborator

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.

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 updated the docstring.
But the question regarding the ITDE is still pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. We had the initial discussion, that actually the CLI does not interact too much with the ITDE.

  2. 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.

  3. 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.

Copy link
Collaborator

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.
Copy link
Collaborator

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.

Copy link
Contributor Author

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.
Copy link
Collaborator

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.

Copy link
Contributor Author

@ckunki ckunki Oct 2, 2025

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,
Copy link
Collaborator

@ahsimb ahsimb Oct 2, 2025

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.

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 very much agree on your statements.
So what should we do then?
Not verify Docker DB?

Copy link
Collaborator

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.

Copy link
Contributor Author

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()
Copy link
Contributor Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor Author

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?

Copy link
Contributor Author

@ckunki ckunki Oct 7, 2025

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

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 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?
Copy link
Collaborator

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()
Copy link
Collaborator

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}")
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Comment on lines 113 to 114
oset = get_option_set(scs_file)
for o in oset.options:
Copy link
Collaborator

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

Copy link
Contributor Author

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.

option_set = get_option_set(scs_file)
if not option_set:
return 1
for o in option_set.options:
Copy link
Collaborator

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

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, please see latest push.

@ckunki ckunki temporarily deployed to manual-approval October 7, 2025 13:47 — with GitHub Actions Inactive
@ckunki ckunki temporarily deployed to text-ai-prerelease October 7, 2025 14:24 — with GitHub Actions Inactive
Copy link

sonarqubecloud bot commented Oct 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ckunki ckunki merged commit cac24a3 into main Oct 7, 2025
26 of 27 checks passed
@ckunki ckunki deleted the feature/271-Implemented_checking_SCS_content branch October 7, 2025 15:03
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.

SCS CLI: Implement checking options for completeness and correctness

3 participants