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 bridging authorization #3395

Merged
merged 10 commits into from
Feb 27, 2024
Merged

Fix bridging authorization #3395

merged 10 commits into from
Feb 27, 2024

Conversation

luis4a0
Copy link
Contributor

@luis4a0 luis4a0 commented Feb 1, 2024

The prompt asking the user for authorization to disrupt networking to create a bridge was not working. This PR fixes issue 1 of this review.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 88.67%. Comparing base (f51d0cc) to head (cee21ad).

Files Patch % Lines
src/daemon/daemon.cpp 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3395      +/-   ##
==========================================
+ Coverage   88.63%   88.67%   +0.04%     
==========================================
  Files         252      253       +1     
  Lines       13949    13993      +44     
==========================================
+ Hits        12363    12408      +45     
+ Misses       1586     1585       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@luis4a0 luis4a0 force-pushed the add-network-bridges-issue1 branch from 2bbffc2 to bd4eabe Compare February 2, 2024 12:57
@townsend2010 townsend2010 changed the title Fix birdging authorization Fix bridging authorization Feb 5, 2024
@luis4a0 luis4a0 force-pushed the add-network-bridges-issue1 branch from 94be183 to 2e3fb9d Compare February 6, 2024 15:34
Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Hi @luis4a0! Thanks for this!

It appears the output is not quite correct when it prompts for allowing to create the bridge. Here is what I see:

$ multipass set local.test-issue-1.bridged=true
Multipass needs to create a bridge to connect to true.
This will temporarily disrupt connectivity on that interface.

Do you want to continue (yes/no)?

The first line says Multipass needs to create a bridge to connect to true. and notice that it ends with true which is not correct.

Also, I really feel this is overloading generic commands/RPC in a very specific way which is kind of changing this interface to bend to the needs of asking for bridging authorization. I feel the asking for bridging authorization should somehow be decoupled somewhat from all of this or at least make it to where the prompting could be more generalized. I think we need to give this some more thought and I would also like @ricab's opinion on this as well.

@townsend2010
Copy link
Contributor

I will add that aside from the wrong string that I pointed out, it does work as intended. 🙂

@ricab
Copy link
Collaborator

ricab commented Feb 14, 2024

I agree with @townsend2010. The handling for the bridging prompt is too specific for the generic set code. I would rather see a generic scheme to accommodate generic confirmation prompts, ideally applying to all commands and covering other cases of confirmation/choice prompts (e.g. auto snapshot prompt in restore). That said, I am not sure that this is the right time and place for that... Maybe there's a more accessible middle ground for now? I wouldn't mind seeing a proposal for what shape that could take. WDYT @luis4a0?

@luis4a0
Copy link
Contributor Author

luis4a0 commented Feb 14, 2024

Hey @townsend2010, @ricab! You are both right, we can do better in the prompt. Something which comes to my mind is to change the BridgePrompter to a sort of YesNoPrompter, which accepts a custom string to be displayed as prompt. WDYT?

OTOH, @townsend2010, that true in the string comes from a wrong call. I'll fix it.

Thanks to both for the comments and the review!

@townsend2010
Copy link
Contributor

I think a more generic Prompter type is better. Thinking about it some, I can envision a Yes/No prompter, essentially something that accepts a bool. I also envision a prompter that would accept a string. So yes, for this PR, I think switching to a YesNoPrompter that accepts a custom string used for displaying to the user is good.

Also, I'm thinking instead of the "custom" failure handling, using the StreamingCallback may be more efficient here. It's what I used to implement the SMB mount password handling in Windows and seemed to work well for client/daemon ping ponging.

@luis4a0 luis4a0 force-pushed the add-network-bridges-issue1 branch from 2e3fb9d to b23431d Compare February 14, 2024 15:47
@luis4a0
Copy link
Contributor Author

luis4a0 commented Feb 14, 2024

@townsend2010, fixed the true in the prompt. Now the displayed network is correct.

@luis4a0 luis4a0 force-pushed the add-network-bridges-issue1 branch from 3e4b35d to 3cd1d86 Compare February 20, 2024 18:07
Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Hi @luis4a0!

Thanks for the changes you've done. I have one request below and then I think we are good pending your investigation as to why the test coverage fell so much.

src/client/cli/cmd/remote_settings_handler.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Hey @luis4a0!

Thanks for this. Just one more comment below regarding test coverage. I'll await your reply 🙂

src/daemon/daemon.cpp Show resolved Hide resolved
Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Hey @luis4a0,

I answered your reply about more coverage and have some more questions below regarding the tests.

tests/test_daemon.cpp Outdated Show resolved Hide resolved
tests/test_instance_settings_handler.cpp Outdated Show resolved Hide resolved
tests/test_instance_settings_handler.cpp Outdated Show resolved Hide resolved
tests/test_common_callbacks.cpp Outdated Show resolved Hide resolved
src/daemon/daemon.cpp Show resolved Hide resolved
@luis4a0 luis4a0 force-pushed the add-network-bridges-issue1 branch 4 times, most recently from 1ef67ea to 6f9f601 Compare February 27, 2024 14:12
@luis4a0 luis4a0 force-pushed the add-network-bridges-issue1 branch from 6f9f601 to cee21ad Compare February 27, 2024 14:30
@luis4a0
Copy link
Contributor Author

luis4a0 commented Feb 27, 2024

Hey @townsend2010! I addressed your comments and improved testing. This is ready for a new review!

Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Hey @luis4a0!

This looks much better! Thanks! I'm approving, but I will wait on CI to complete before adding it to the merge queue.

@townsend2010 townsend2010 added this pull request to the merge queue Feb 27, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2024
@townsend2010 townsend2010 added this pull request to the merge queue Feb 27, 2024
Merged via the queue into main with commit 8c7a226 Feb 27, 2024
14 checks passed
@townsend2010 townsend2010 deleted the add-network-bridges-issue1 branch February 27, 2024 18:36
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