Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

add more location to OVH and avoid exception when location is not in the list#2123

Open
ali-corpo wants to merge 3 commits intoapache:trunk from
ali-corpo:ovh-fix
Open

add more location to OVH and avoid exception when location is not in the list #2123
ali-corpo wants to merge 3 commits intoapache:trunk from
ali-corpo:ovh-fix

Conversation

@ali-corpo
Copy link

@ali-corpo ali-corpo commented Feb 17, 2026
edited
Loading

Description

add more location to OVH and avoid exception when location is not in the list

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)

Copilot AI review requested due to automatic review settings February 17, 2026 10:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the OVH driver to support additional datacenter locations and implements graceful handling of unknown locations instead of raising exceptions.

Changes:

  • Added 17 new location entries to the LOCATIONS dictionary, including parent regions (BHS, GRA, RBX, SBG, WAW) and specific locations (CA-EAST-TOR, EU-SOUTH-MIL, EU-WEST-PAR, etc.)
  • Modified the _to_location method to use .get() for safe dictionary access and fall back to creating a basic location object when encountering unknown location codes
  • Added logging to warn when unknown locations are encountered

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
libcloud/common/ovh.py Added 17 new OVH datacenter location mappings to expand geographic coverage
libcloud/compute/drivers/ovh.py Implemented graceful fallback for unknown locations with logging support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from libcloud.compute.types import Provider, StorageVolumeState, VolumeSnapshotState
from libcloud.compute.drivers.openstack import OpenStackKeyPair, OpenStackNodeDriver

from libcloud.libcloud.utils import logging
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The import path is incorrect and contains a duplicate 'libcloud' segment. This should be import logging (standard library) or from libcloud.utils.logging import ... if using a custom logging utility. The current path from libcloud.libcloud.utils import logging will cause an ImportError at runtime.

Suggested change
fromlibcloud.libcloud.utilsimport logging
import logging

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove logging import and calls, drivers do not call logging.

Comment on lines +81 to +82
"UK": {"id": "UK", "name": "United Kingdom", "country": "UK"},
"UK1": {"id": "UK1", "name": "United Kingdom 1", "country": "UK"},
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Using 'UK' as a country code is inconsistent with ISO 3166-1 alpha-2 standards, which uses 'GB' for the United Kingdom. However, this appears to be an existing pattern in the codebase (see line 50 with LON1). For consistency with existing entries, this may be acceptable, but consider using 'GB' for proper ISO compliance in future additions.

Suggested change
"UK": {"id": "UK", "name": "United Kingdom", "country": "UK"},
"UK1": {"id": "UK1", "name": "United Kingdom 1", "country": "UK"},
"UK": {"id": "UK", "name": "United Kingdom", "country": "GB"},
"UK1": {"id": "UK1", "name": "United Kingdom 1", "country": "GB"},

Copilot uses AI. Check for mistakes.
Comment on lines 542 to 545
location = self.connectionCls.LOCATIONS.get(obj)
if not location:
logging.warning(f"Unknown location {obj} for OVH")
location = {"id": obj, "name": obj, "country": ""}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The new fallback logic for unknown locations lacks test coverage. Consider adding a test case that verifies the behavior when an unknown location is encountered, ensuring that it creates a NodeLocation with the location ID as both id and name, an empty country field, and logs an appropriate warning message.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the logic behind the location being empty?
May be raising an error will be better...

location = self.connectionCls.LOCATIONS[obj]
location = self.connectionCls.LOCATIONS.get(obj)
if not location:
logging.warning(f"Unknown location {obj} for OVH")
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

After fixing the import statement, you should create a module-level logger instance (e.g., logger = logging.getLogger(__name__)) and use logger.warning() instead of calling logging.warning() directly. This follows the established pattern in the codebase (see libcloud/compute/drivers/vsphere.py:53 and libcloud/common/google.py:103).

Copilot uses AI. Check for mistakes.
from libcloud.compute.types import Provider, StorageVolumeState, VolumeSnapshotState
from libcloud.compute.drivers.openstack import OpenStackKeyPair, OpenStackNodeDriver

from libcloud.libcloud.utils import logging
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove logging import and calls, drivers do not call logging.

Comment on lines 542 to 545
location = self.connectionCls.LOCATIONS.get(obj)
if not location:
logging.warning(f"Unknown location {obj} for OVH")
location = {"id": obj, "name": obj, "country": ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the logic behind the location being empty?
May be raising an error will be better...

ali-corpo and others added 2 commits February 17, 2026 16:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed logging warning for unknown OVH locations.
Copy link

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.36%. Comparing base (a96b098) to head (a26c788).
⚠️ Report is 10 commits behind head on trunk.

Files with missing lines Patch % Lines
libcloud/compute/drivers/ovh.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@
## trunk #2123 +/- ##
==========================================
- Coverage 83.36% 83.36% -0.00% 
==========================================
 Files 353 353 
 Lines 81876 81878 +2 
 Branches 9003 9004 +1 
==========================================
 Hits 68250 68250 
- Misses 10798 10799 +1 
- Partials 2828 2829 +1 
Files with missing lines Coverage Δ
libcloud/common/ovh.py 79.35% <ø> (ø)
libcloud/compute/drivers/ovh.py 83.02% <33.33%> (-0.79%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Reviewers

Copilot code review Copilot Copilot left review comments

@micafer micafer micafer requested changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /