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

Add support for Linode's API v4 #1504

Merged
merged 10 commits into from Dec 9, 2020
Merged

Add support for Linode's API v4 #1504

merged 10 commits into from Dec 9, 2020

Conversation

dimgal1
Copy link
Contributor

@dimgal1 dimgal1 commented Oct 13, 2020

Add Linode Compute Driver for APIv4

Description

This Pull Request adds Linode Compute Driver compatible with Linode's API v4 while simultaneously supporting the previous API version.

Status

done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

@Kami
Copy link
Member

Kami commented Nov 5, 2020

Sorry for the delay.

This is a relatively large PR so it will take a while to review.

@micafer
Copy link
Contributor

micafer commented Nov 13, 2020

HI @dimgal1 and @Kami,

I'm interested in this new version.

I tested some of the functionality of the compute driver:

  • list_nodes
  • list_sizes
  • list_locations
  • list_volumes
  • create_node
  • create_volume
  • ex_resize_node
  • start_node
  • stop_node
  • reboot_node
  • destroy_node
  • destroy_volume

I found some minor issues I will put inline.

'migrating': NodeState.MIGRATING,
'rebuilding': NodeState.UPDATING,
'cloning': NodeState.MIGRATING,
'restoring': NodeState.PENDING,
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a missing state 'resizing'. I checked the API documentation and it does not appear. But I made some tests and it does exist. May be a good map value could be:
'resizing': NodeState.RECONFIGURING

'location': data['region'],
'linode_id': data['linode_id'],
'linode_label': data['linode_label'],
'state': self.LINODE_VOLUME_STATES[data['status']]
Copy link
Contributor

Choose a reason for hiding this comment

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

filesystem_path' is an important value that is not returned in the extra fields:

'filesystem_path': data['filesystem_path']

@dimgal1
Copy link
Contributor Author

dimgal1 commented Nov 15, 2020

Hi @micafer,
made the recommendations you mentioned.
Thanks for the feedback!

@codecov-io
Copy link

codecov-io commented Nov 16, 2020

Codecov Report

Merging #1504 (6b253ff) into trunk (c0c4743) will increase coverage by 0.05%.
The diff coverage is 88.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk    #1504      +/-   ##
==========================================
+ Coverage   83.00%   83.06%   +0.05%     
==========================================
  Files         390      392       +2     
  Lines       83701    84667     +966     
  Branches     8882     8997     +115     
==========================================
+ Hits        69480    70332     +852     
- Misses      11222    11272      +50     
- Partials     2999     3063      +64     
Impacted Files Coverage Δ
libcloud/compute/drivers/linode.py 66.98% <71.48%> (+4.24%) ⬆️
libcloud/dns/drivers/linode.py 82.80% <78.18%> (-5.03%) ⬇️
libcloud/common/linode.py 87.62% <95.74%> (+7.62%) ⬆️
libcloud/test/dns/test_linode_v4.py 97.08% <97.08%> (ø)
libcloud/test/compute/test_linode_v4.py 98.29% <98.29%> (ø)
libcloud/test/compute/test_linode.py 98.05% <100.00%> (ø)
libcloud/test/dns/test_linode.py 95.73% <100.00%> (ø)

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 c0c4743...6b253ff. Read the comment docs.

@Kami
Copy link
Member

Kami commented Dec 6, 2020

@micafer Since you originally reviewed this PR, can you please have a look again when you get a chance?

And if everything looks OK, feel free to add a CHANGELOG entry and merge it into master.

@micafer
Copy link
Contributor

micafer commented Dec 7, 2020

@micafer Since you originally reviewed this PR, can you please have a look again when you get a chance?

And if everything looks OK, feel free to add a CHANGELOG entry and merge it into master.

OK, I will take a look.

status = int(self.status)
data = self.parse_body()
# Use only the first error, as there'll be only one most of the time
error = data['errors'][0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not:
error = " ".join(data['errors'])
In this case all error messages will be returned, not only the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

data['errors'] is a list of dictionaries so I think this will not work.
Maybe it could be something like this?

Suggested change
error = data['errors'][0]
error_list = []
for error in data['errors']:
reason = error.get('reason')
# The field in the request that caused this error
field = error.get('field')
if field is not None:
msg = '%s-%s' % (reason, field)
else:
msg = reason
error_list.append(msg)
error_msg = ' '.join(error_list)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you are right. May be you can leave the original one. As you said in the first error is the most important one.

:type volume: :class:`StorageVolume`

:param volume: Node to attach the volume to(required)
:type volume: :class:`Node`
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be:
:param node:
:type node:

:type volume: :class:`Node`

:keyword persist_across_boots: Node to attach the volume to(required)
:type volume: :class:`Node`
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be:
:type persist_across_boots: bool

:type node: :class:`Node`

:keyword address_type: Type of IP address
:type address_type: `bool`
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be:
:type address_type: str

method='POST').object
return self._to_address(response)

def ex_share_address(self, node, addresses=[]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why setting addresses as an optional keyword?
It is required to share an address.
I think it shoul be better:

def ex_share_address(self, node, addresses):

:type node: :class:`Node`

:param size: the size of the new node
:type node: :class:`NodeSize`
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be:
:type size:

@micafer
Copy link
Contributor

micafer commented Dec 7, 2020

Adding other methods as:
ex_get_node or ex_get_volume will be very useful.

@dimgal1
Copy link
Contributor Author

dimgal1 commented Dec 7, 2020

Thanks for the feedback @micafer .
Fixed the issues and added these two methods you mentioned.

@micafer
Copy link
Contributor

micafer commented Dec 9, 2020

LGTM.

@micafer micafer merged commit 137d41d into apache:trunk Dec 9, 2020
@Kami
Copy link
Member

Kami commented Dec 13, 2020

Looks like that merging this "broke" automatically generated provider tables - it shows Linode DNS driver doesn't implement any methods.

I believe that's related to the way driver is now structured - our table generation script only changes methods on the base class.

I will work on a workaround.

@Kami
Copy link
Member

Kami commented Dec 13, 2020

Here we go - 85d6bbb :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants