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

IH-728: Refactor SXM code, Pt1 #6084

Merged
merged 7 commits into from
Nov 18, 2024

Conversation

Vincent-lau
Copy link
Contributor

The Storage migration code is too messy to be maintainable, making the developing experience quite bad. This is the first attempt to make it less spaghetti.

I am intending to do this in several stages. This PR is just for those that are mostly "safe" operations that can probably be checked statically by the compiler. More risky changes on the way...

Best reviewed by commit.

@Vincent-lau Vincent-lau marked this pull request as draft October 25, 2024 10:41
@last-genius
Copy link
Contributor

Great stuff!

@@ -1383,14 +1376,14 @@ let with_task_and_thread ~dbg f =

let copy ~dbg ~sr ~vdi ~url ~dest ~verify_dest =
with_task_and_thread ~dbg (fun task ->
MigrateLocal.copy_into_sr ~task ~dbg:dbg.Debug_info.log ~sr ~vdi ~url
~dest ~verify_dest
MigrateLocal.copy_into_sr ~task ~dbg:(Debug_info.to_string dbg) ~sr ~vdi
Copy link
Member

Choose a reason for hiding this comment

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

This is a different string now. The dbg.Debug_info.log string was used here (and below), because the functions further down do not yet handle dbg strings that have both the "log" and "tracing" data combined, which can then end up in the "task" part of log lines. Or has that changed now?

Copy link
Contributor Author

@Vincent-lau Vincent-lau Oct 25, 2024

Choose a reason for hiding this comment

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

That is quite true. But line 733, which I deleted, has let dbg = dbg_and_tracing_of_trask task in start function will mean that anything below that line in the start function would be using a dbg parameter with "log" and "dbg" in them. Was this going to cause the same problem as you described?

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 had a look at the following functions which use dbg, it seems that they are all SMAPIv2 calls, which handles tracing already. If they are what you were referring to as functions further down?

@Vincent-lau
Copy link
Contributor Author

Thanks everyone for the quick review. I have messed up the commit messages in this PR a bit, where the middle PR "Restructuring Storage migration code" has a lot of changes in it. I will now force push the changes to make it more explicit in each commit I am changing.

@Vincent-lau Vincent-lau force-pushed the private/shul2/sxm-clean2 branch 2 times, most recently from 7f2bc78 to d608dd6 Compare October 25, 2024 12:17
@Vincent-lau Vincent-lau marked this pull request as ready for review October 25, 2024 12:47
@Vincent-lau Vincent-lau force-pushed the private/shul2/sxm-clean2 branch from d608dd6 to 20fb265 Compare October 25, 2024 12:52
@Vincent-lau Vincent-lau changed the title IH-728: Refactor the SXM code IH-728: Refactor SXM code, Pt1 Oct 25, 2024
There is no remote invocation of this function, so should be safe.

Signed-off-by: Vincent Liu <[email protected]>
Rather than copy and copy', rename them into `copy_into_sr` and
`copy_into_vdi`, which is what they actually do.

Signed-off-by: Vincent Liu <[email protected]>
Also make the logging information more verbose.

Signed-off-by: Vincent Liu <[email protected]>
- Introduce new `MigrateLocal` and `MigrateRemote` modules which contains
  the main implementations of the migration logic.
- Move the actual exposed SMAPIv2 functions in one place towards the end
  of the file, rather than spreading across the entire file.

These refactoring should all be statically verifiable by the compiler.

Signed-off-by: Vincent Liu <[email protected]>
Previously a task was constructed based on the log and tracing of a dbg
of the type Debug_info.t, and then later on a dbg is constructed based
on the previously constructued task. Instead of that, just convert the
first dbg into a string and thread it through the call.

Signed-off-by: Vincent Liu <[email protected]>
@psafont psafont added this pull request to the merge queue Nov 18, 2024
Merged via the queue into xapi-project:master with commit 77dd474 Nov 18, 2024
15 checks passed
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