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

fix: seperated _update_cluster_fn from _process_operation_fn to displ… #619

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

SteBaum
Copy link
Contributor

@SteBaum SteBaum commented Aug 2, 2024

fix: seperated _update_cluster_fn from _process_operation_fn to display deployment operations

Which issue(s) this PR fixes

Fixes None

Additional comments

Before this PR the tdp deploy or tdp deploy --mock-deploy does not display the -install operations although they are executed and written in the database since they do not provide cluster_status_logs directly. Therefore in order to show these commands too, in the iterator the _process_operation_fn must be separated in two. one function which executes the operation and a second one which updates the status_logs.

Agreements

@SteBaum SteBaum self-assigned this Aug 2, 2024
Copy link
Contributor

@PaulFarault PaulFarault left a comment

Choose a reason for hiding this comment

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

If I understand correctly, you're saying that the CLI doesn't display any message in the console for the *_install operations because their _process_operation_fn aren't returning any logs to append to the sch_status_log table.

If so, extracting the log generation logic from the _process_operation_fn is a good refactor. However, the DeploymentIterator signature likely shouldn't change. Why return two functions instead of simply doing the following:

for operation_rec, process_operation_fn in deployment_iterator:
    dao.session.commit()  # Update deployment and current operation status to RUNNING and next operations to PENDING
-   if process_operation_fn and (cluster_status_logs := process_operation_fn()):
+   if process_operation_fn:
        click.echo(
            f"Operation {operation_rec.operation} is {operation_rec.state} {'for hosts: ' + operation_rec.host if operation_rec.host is not None else ''}"
        )
+       if cluster_status_logs := process_operation_fn():
-       dao.session.add_all(cluster_status_logs)
+           dao.session.add_all(cluster_status_logs)
    dao.session.commit()  # Update operation status to SUCCESS, FAILURE or HELD
    

            dao.session.add_all(cluster_status_logs)
    dao.session.commit()  # Update operation status to SUCCESS, FAILURE or HELD

@SteBaum SteBaum force-pushed the stephan/fix/deployment branch from 9584116 to d97e29e Compare October 18, 2024 15:09
@SteBaum
Copy link
Contributor Author

SteBaum commented Oct 18, 2024

If I understand correctly, you're saying that the CLI doesn't display any message in the console for the *_install operations because their _process_operation_fn aren't returning any logs to append to the sch_status_log table.

If so, extracting the log generation logic from the _process_operation_fn is a good refactor. However, the DeploymentIterator signature likely shouldn't change. Why return two functions instead of simply doing the following:

for operation_rec, process_operation_fn in deployment_iterator:
    dao.session.commit()  # Update deployment and current operation status to RUNNING and next operations to PENDING
-   if process_operation_fn and (cluster_status_logs := process_operation_fn()):
+   if process_operation_fn:
        click.echo(
            f"Operation {operation_rec.operation} is {operation_rec.state} {'for hosts: ' + operation_rec.host if operation_rec.host is not None else ''}"
        )
+       if cluster_status_logs := process_operation_fn():
-       dao.session.add_all(cluster_status_logs)
+           dao.session.add_all(cluster_status_logs)
    dao.session.commit()  # Update operation status to SUCCESS, FAILURE or HELD
    

            dao.session.add_all(cluster_status_logs)
    dao.session.commit()  # Update operation status to SUCCESS, FAILURE or HELD

The seperation makes sens since executing the operations and creating the status logs are two different operations. However I have modified as you said to keep it as close as what was before and if the separation takes place it will be n another PR.

@SteBaum SteBaum requested a review from PaulFarault October 18, 2024 15:18
@SteBaum SteBaum merged commit 105f062 into master Oct 21, 2024
5 checks passed
@SteBaum SteBaum deleted the stephan/fix/deployment branch October 21, 2024 08:45
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