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

adding backup targets #170

Merged
merged 23 commits into from
Jun 5, 2023
Merged

adding backup targets #170

merged 23 commits into from
Jun 5, 2023

Conversation

TAlonglong
Copy link
Collaborator

@TAlonglong TAlonglong commented May 21, 2023

@TAlonglong TAlonglong requested review from pnuu and mraspaud as code owners May 21, 2023 16:50
@codecov
Copy link

codecov bot commented May 21, 2023

Codecov Report

Merging #170 (95c847f) into main (47dd25f) will increase coverage by 0.19%.
The diff coverage is 95.93%.

@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
+ Coverage   90.00%   90.19%   +0.19%     
==========================================
  Files          24       24              
  Lines        5100     5203     +103     
==========================================
+ Hits         4590     4693     +103     
  Misses        510      510              
Flag Coverage Δ
unittests 90.19% <95.93%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
trollmoves/client.py 83.21% <83.33%> (-0.03%) ⬇️
trollmoves/movers.py 84.05% <93.10%> (+0.59%) ⬆️
trollmoves/server.py 67.96% <93.33%> (+0.15%) ⬆️
trollmoves/move_it_base.py 79.80% <100.00%> (ø)
trollmoves/tests/test_client.py 99.62% <100.00%> (+0.01%) ⬆️
trollmoves/tests/test_ssh_server.py 98.26% <100.00%> (+0.18%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

LGTM. Just couple of small thoughts that can be ignored.

trollmoves/movers.py Outdated Show resolved Hide resolved
trollmoves/tests/conftest.py Outdated Show resolved Hide resolved
@TAlonglong TAlonglong requested a review from pnuu May 23, 2023 11:48
Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

LGTM, just one styling comment.

trollmoves/tests/test_ssh_server.py Outdated Show resolved Hide resolved
@pnuu
Copy link
Member

pnuu commented May 23, 2023

I also tested that the Publisher(...).start() didn't break usage with older Posttroll versions. At least tests pass locally with v1.9.0 and the latest v.1.10.0.

@pnuu
Copy link
Member

pnuu commented May 24, 2023

One thing I forgot to ask for: example configuration. Which made me realise that the original primary destination is configured in the Client side, but the backups need to be in the Server config, right? Should the backup servers be sent in the request message by the Client? That way the Server process could be used also for other transfers and it wouldn't fallback to push the data to wrong backup hosts.

@TAlonglong
Copy link
Collaborator Author

Ah, crap. You are right.

@TAlonglong
Copy link
Collaborator Author

The implementation I came up with does not work at all.

@TAlonglong
Copy link
Collaborator Author

So, I think I will revert all of this work and start over. Maybe I'll start a new PR to add the start() to the publisher to be compatible with posttroll 1.10.0

Then I need a sanity check. I think I will implement the backup target if I hit here: https://github.com/pytroll/trollmoves/blob/main/trollmoves/client.py#L671

So the idea is then to, if backup targets/destinations config is provided, restart the request.

Any ideas?

@pnuu
Copy link
Member

pnuu commented May 24, 2023

I would keep the structure you have here, but instead of putting the backup destinations to Server config, put them in Client config and add them in the request message maybe in this else block. Then in Server check the message for backup_destinations list in the message data if the retries go to zero.

@TAlonglong
Copy link
Collaborator Author

Ah, yes. That looks doable.

So, where is this tested then. Then I can try from there

@TAlonglong
Copy link
Collaborator Author

Updated to have the backup targets config in the client config.
This is then sent to the server, which change the destination if the primary fails.
It's tricky to propagate this info from the message to the actual mover, so I added a extra function parameter for this.
One issue I see is that the final message contains the primary target, I have not found a way to replace that information in the message.

Please let me know id you see anything odd

@pnuu
Copy link
Member

pnuu commented May 25, 2023

One issue I see is that the final message contains the primary target, I have not found a way to replace that information in the message.

This is a tricky one. The message should maybe be updated here, but that would require rather large changes so that the actual destination were passed down from the individual Mover to movers.move_it() to server.RequestManager._move_file() to server.RequestManager._move_files() and eventually to movers.RequestManager.push(). And then there's the complication that _move_files() already returns either an error message or None.

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

Just couple of small comments inline, otherwise LGTM.

The comment on the config made me think that later we could move the retry logic to movers.move_it() so that all of the movers would have the possibility. Then we could also have backup destinations with different transport schemes; the primary could be scp:// and backups scp:// and ftp:// for example. But that's for another PR.

trollmoves/tests/test_client.py Show resolved Hide resolved
trollmoves/tests/test_client.py Outdated Show resolved Hide resolved
@TAlonglong
Copy link
Collaborator Author

I'm quite happy with this. Please let me know what you think

trollmoves/movers.py Show resolved Hide resolved
trollmoves/movers.py Show resolved Hide resolved
@TAlonglong
Copy link
Collaborator Author

A step further. What do you think?

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

Couple more things. And a live test would be great 😁

trollmoves/server.py Outdated Show resolved Hide resolved
trollmoves/server.py Show resolved Hide resolved
@TAlonglong
Copy link
Collaborator Author

You mean at the status update? And show this is working on the screen? Sure no problem.

@pnuu
Copy link
Member

pnuu commented May 25, 2023

No need to demonstrate 😂 Just run a test that this works in real life.

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

LGTM.

Does @mraspaud want to have a look?

@TAlonglong
Copy link
Collaborator Author

Then I see something that might be a feature. First time a backup target is used, the active connection is tagged with the primary target. Therefore the next time, if the previous connection is still alive, this is used even if the actual connection is to the backup target. SO that way if this occur it looks like the primary target is used but the actual cache connection is to the bakcup target.

changing line https://github.com/pytroll/trollmoves/blob/main/trollmoves/movers.py#L136 to
self.active_connections[(self.destination.hostname, port, username)] = connection, timer will solve this, but I'm not sure how the behaviour should be

@TAlonglong
Copy link
Collaborator Author

Not sure if this is ready to merge as I see the approval from @mraspaud is old/changes after the approval.

@lahtinep
Copy link
Contributor

lahtinep commented Jun 5, 2023

I'm merging this, we need a new release with the .start() method to make PyPI installation work with the latest Posttroll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

In the server add backup target host for scp
4 participants