Skip to content

Conversation

luis4a0
Copy link
Contributor

@luis4a0 luis4a0 commented Dec 15, 2020

This PR adds the ability to gather all the IP's used by each instance.

The private bits of this PR are in https://github.com/canonical/multipass-private/pull/338.

@luis4a0 luis4a0 marked this pull request as draft December 15, 2020 13:47
@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #1886 (d281627) into master (f2c175f) will increase coverage by 0.01%.
The diff coverage is 64.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1886      +/-   ##
==========================================
+ Coverage   78.46%   78.47%   +0.01%     
==========================================
  Files         234      234              
  Lines        8768     8856      +88     
==========================================
+ Hits         6880     6950      +70     
- Misses       1888     1906      +18     
Impacted Files Coverage Δ
include/multipass/virtual_machine.h 100.00% <ø> (ø)
src/daemon/daemon.cpp 45.48% <27.90%> (-0.62%) ⬇️
src/platform/backends/lxd/lxd_virtual_machine.cpp 98.63% <66.66%> (-0.11%) ⬇️
...rc/platform/backends/qemu/qemu_virtual_machine.cpp 76.20% <83.33%> (+2.82%) ⬆️
src/client/cli/formatter/csv_formatter.cpp 100.00% <100.00%> (ø)
src/client/cli/formatter/json_formatter.cpp 100.00% <100.00%> (ø)
src/client/cli/formatter/table_formatter.cpp 96.55% <100.00%> (+1.22%) ⬆️
src/client/cli/formatter/yaml_formatter.cpp 100.00% <100.00%> (ø)
...tform/backends/libvirt/libvirt_virtual_machine.cpp 72.63% <100.00%> (ø)
...rc/platform/backends/shared/shared_backend_utils.h 100.00% <100.00%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2c175f...d281627. Read the comment docs.

@luis4a0 luis4a0 marked this pull request as ready for review December 16, 2020 13:48
@luis4a0 luis4a0 force-pushed the multiple-ips-list-info branch from 0e9b9cd to 277d920 Compare December 16, 2020 19:26
@luis4a0 luis4a0 force-pushed the multiple-ips-list-info branch from 277d920 to f3d3d4e Compare January 4, 2021 14:39
Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

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

Thanks @luis4a0, the approach and code look good! I will do some more testing when reviewing the private side, but everything seems to work well so far.

I have some requests and suggestions for refinement (many are repeated), but the strategy looks solid 😃

Comment on lines 539 to 541
ON_CALL(mock_dnsmasq_server, get_ip_for(_)).WillByDefault([&expected_ip](auto...) {
return mp::optional<mp::IPAddress>{expected_ip};
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the lambda? Should be able to just ....WillByDefault(Return(expected_ip)).

And might as well EXPECT_CALL, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, changed the lambda and added the EXPECT_CALL.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you keep the ON_CALL though? You have both ON_CALL and EXPECT_CALL now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just read the difference between them. I was just confused on the meaning of ON_CALL. Changed.

mpt::StubVMStatusMonitor stub_monitor;
NiceMock<mpt::MockDNSMasqServer> mock_dnsmasq_server{data_dir.path(), bridge_name, subnet};

ON_CALL(mock_dnsmasq_server, get_ip_for(_)).WillByDefault([](auto...) { return mp::optional<mp::IPAddress>{}; });
Copy link
Collaborator

Choose a reason for hiding this comment

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

idem: return (with nullopt here) and expect call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

idem: {ON,EXPECT}_CALL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@luis4a0 luis4a0 force-pushed the multiple-ips-list-info branch from f66e6ec to f3189ff Compare January 15, 2021 13:35
Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

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

Final details inline. You know you can just accept the suggestions (in batches) on GH, right?

info->set_disk_total(
run_in_vm("df --output=size `awk '$2 == \"/\" { print $1 }' /proc/mounts` -B1 | sed 1d"));
info->set_ipv4(vm->ipv4());
for (auto extra_ipv4 : all_ipv4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for (auto extra_ipv4 : all_ipv4)
for (const auto& extra_ipv4 : all_ipv4)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if (is_ipv4_valid(management_ip))
entry->add_ipv4(management_ip);

for (auto extra_ipv4 : all_ipv4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for (auto extra_ipv4 : all_ipv4)
for (const auto& extra_ipv4 : all_ipv4)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

const std::string expected_ip{"10.10.0.35"};
NiceMock<mpt::MockDNSMasqServer> mock_dnsmasq_server{data_dir.path(), bridge_name, subnet};

EXPECT_CALL(mock_dnsmasq_server, get_ip_for(_)).Times(1).WillRepeatedly(Return(expected_ip));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
EXPECT_CALL(mock_dnsmasq_server, get_ip_for(_)).Times(1).WillRepeatedly(Return(expected_ip));
EXPECT_CALL(mock_dnsmasq_server, get_ip_for(_)).WillOnce(Return(expected_ip));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

mpt::StubVMStatusMonitor stub_monitor;
NiceMock<mpt::MockDNSMasqServer> mock_dnsmasq_server{data_dir.path(), bridge_name, subnet};

EXPECT_CALL(mock_dnsmasq_server, get_ip_for(_)).Times(1).WillRepeatedly(Return(mp::nullopt));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
EXPECT_CALL(mock_dnsmasq_server, get_ip_for(_)).Times(1).WillRepeatedly(Return(mp::nullopt));
EXPECT_CALL(mock_dnsmasq_server, get_ip_for(_)).WillOnce(Return(mp::nullopt));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@luis4a0 luis4a0 force-pushed the multiple-ips-list-info branch from f3189ff to d281627 Compare January 15, 2021 16:06
Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

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

OK, this is good now, thanks!

bors r+

bors bot added a commit that referenced this pull request Jan 15, 2021
1886: Show multiple IP's in `list` and `info` commands r=ricab a=luis4a0

This PR adds the ability to gather all the IP's used by each instance.

The private bits of this PR are in https://github.com/canonical/multipass-private/pull/338.

Co-authored-by: Luis Peñaranda <[email protected]>
@ricab
Copy link
Collaborator

ricab commented Jan 15, 2021

Canceling so that this does not go away before rebasing the other side (which will need to merge with this)

bors r-

@bors
Copy link
Contributor

bors bot commented Jan 15, 2021

Canceled.

@ricab
Copy link
Collaborator

ricab commented Jan 15, 2021

Alright, all's good

bors r+

bors bot added a commit that referenced this pull request Jan 15, 2021
1886: Show multiple IP's in `list` and `info` commands r=ricab a=luis4a0

This PR adds the ability to gather all the IP's used by each instance.

The private bits of this PR are in https://github.com/canonical/multipass-private/pull/338.

Co-authored-by: Luis Peñaranda <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jan 15, 2021

Build failed:

@ricab
Copy link
Collaborator

ricab commented Jan 15, 2021

bors retry

@bors
Copy link
Contributor

bors bot commented Jan 15, 2021

Build failed:

@ricab ricab merged commit 8823c92 into master Jan 15, 2021
@bors bors bot deleted the multiple-ips-list-info branch January 15, 2021 19:10
Saviq pushed a commit that referenced this pull request Jan 17, 2021
1886: Show multiple IP's in `list` and `info` commands r=ricab a=luis4a0

This PR adds the ability to gather all the IP's used by each instance.

The private bits of this PR are in canonical/multipass-private#338.

Co-authored-by: Luis Peñaranda <[email protected]>
@Saviq Saviq added this to the v1.6.0 milestone Feb 2, 2021
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