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

Use service-handler for restore operations #4714

Merged
merged 10 commits into from
Nov 28, 2023
Merged

Use service-handler for restore operations #4714

merged 10 commits into from
Nov 28, 2023

Conversation

ashmrtn
Copy link
Contributor

@ashmrtn ashmrtn commented Nov 17, 2023

Switch restore code path to use service-level handlers. Does a few
things:

  • switches existing service-level functions to be methods on
    service-level handlers
  • update interfaces as necessary
  • moves some logic from old controller-level restore function to either
    the new handlers or the operation-level function
  • removes old code

May be easiest to review by commit


Does this PR need a docs update or release note?

  • ✅ Yes, it's included
  • 🕐 Yes, but in a later PR
  • ⛔ No

Type of change

  • 🌻 Feature
  • 🐛 Bugfix
  • 🗺️ Documentation
  • 🤖 Supportability/Tests
  • 💻 CI/Deployment
  • 🧹 Tech Debt/Cleanup

Issue(s)

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@ashmrtn ashmrtn added restore tech-debt Non-feature, non-bug improvements to the codebase. labels Nov 17, 2023
@ashmrtn ashmrtn self-assigned this Nov 17, 2023
Copy link
Contributor

aviator-app bot commented Nov 17, 2023

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.

Use the Aviator Chrome Extension to see the status of your PR within GitHub.

progressBar := observe.MessageWithCompletion(ctx, observe.ProgressCfg{}, "Restoring data")
defer close(progressBar)

ctx, end := diagnostics.Span(ctx, "m365:restore")
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the wrong layer to specify m365. operations should be agnostic to the provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, copy/paste error. I'll switch to something like operations for this annotation

Comment on lines +31 to +36
// TODO(ashmrtn): We should stop relying on the context for rate limiter stuff
// and instead configure this when we make the handler instance. We can't
Copy link
Contributor

Choose a reason for hiding this comment

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

Two requests.
1/ can you please make a tech debt ticket for this, instead of todo comments?
2/ while i'm fine that we avoid hijacking the context for this, I worry that the lack of a suggested alternative leaves this open to going back to global singletons as a solution, which I'd like to avoid. We've been pretty loose (ie: not centralized) when it comes to handling our http client configuration, and that's caused a handful of problems around statefulness and leaky configs. It'd be nice for a refactor to look at solving all of that, and I worry a quick todo resolution won't have the necessary breathing room to solve many problems beyond the ctx usage itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can we switch up how we do http client init a little? From my understanding, we need the client in the CLI layer to do some name resolution and in the operation itself. Would it be alright to make those two separate clients instead of reusing the same one? That would get us out of needing a global config that's initialized before we get all the info we need

The one question there is if it would scale nicely for something like corso backup create exchange --user "*". If we tie the client to the operation (or functions like this) it's unclear how garbage collection/reuse of the old client's connection pool will go

Base automatically changed from 4254-restore-status to main November 27, 2023 17:09
Switch the existing restore functions for each service to be a method of
the service handler for the service instead of a free function.
Just making sure everything will continue to compile at the end.
Update where ConsumeRestoreCollections and some other functions are
called. Mostly just switching things to make a handler and making return
values and parameters line up.
These statements were originally in the internal/m365/restore.go file,
but that's going to be removed soon. Move them to operations since it's
still a centralized place.
Move check to more centralized place to give same behavior but in a more
maintainable manner.
Return error if there's no data given to restore.
Copy link

sonarcloud bot commented Nov 28, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@aviator-app aviator-app bot merged commit d366362 into main Nov 28, 2023
25 checks passed
@aviator-app aviator-app bot deleted the 4254-restore branch November 28, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mergequeue restore tech-debt Non-feature, non-bug improvements to the codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants