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

Use a custom designate driver for FIP's #70

Open
wants to merge 16 commits into
base: stable/yoga-m3
Choose a base branch
from

Conversation

misamoylov
Copy link

No description provided.

@misamoylov misamoylov force-pushed the fip_update branch 5 times, most recently from 672dc6d to 1be302f Compare November 15, 2024 12:53
@misamoylov misamoylov marked this pull request as ready for review November 15, 2024 13:17
Use designate /v2/reverse/floatingips/ endpoint to create DNS zones and
DNS entries during FIP creation.
Current driver uses zones and recordset endpoints instead of specific
designate endpoint.
@misamoylov misamoylov marked this pull request as draft January 30, 2025 14:02
@misamoylov misamoylov marked this pull request as ready for review February 5, 2025 10:09
Copy link

@mutax mutax left a comment

Choose a reason for hiding this comment

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

only some minor things

@misamoylov misamoylov requested a review from mutax February 12, 2025 10:13
Comment on lines +80 to +81
class DesignateCcloud(driver.ExternalDNSService):
"""Driver for Designate."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like your code is almost identical to neutron.services.externaldns.drivers.designate.driver.Designate. You could inherit that class and then only use the methods that changed, i.e. create_record_set() and delete_record_set.

Copy link

Choose a reason for hiding this comment

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

If I read the git log correctly, we already extensively modified that driver compared to upstream.
This means updating to a new release would mean patching two classes. If we want to avoid that we would need to compare the currently proposed new driver to upstream first and then overwrite the changed methods.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, we already have a changes for driver.py.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see. Would it then make sense to - in an extra commit - change the driver back to original? Then we have the usptream driver there and only our changes in our own driver.

Copy link

Choose a reason for hiding this comment

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

I did a diff between the real upstream, our changes in yoga and the new ccloud driver, as well as the 2024.2 version.

Given that most of the code changes and only __init__ and 4 class-internal helper methods are not changed, inheriting from the upstream class seems to have no advantages, but would make the code hard to follow.

Reverting driver.py back to the upstream version would, in my opinion, defeat the purpose of adding a new ccloud driver instead of replacing driver.py. The original upstream driver will not work for us at all, and the reason to keep the our existing driver.py was, to be able to quickly switch back to that version by config, in case the new driver shows bad behavior.

If we replace our existing driver.py with upstream, we could also just replace driver.py by the ccloud_driver.py and be done.

Comment on lines +244 to +245
client, admin_client = get_all_projects_edit_managed_client(
context)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be the only change to the already existing Designate externaldns driver for this class. Why do we need this change here? It doesn't seem to be related to the FIP problem you set out to solve. If we don't need it we could just use the already existing delete_record_set() and would have less code duplication.

Copy link
Author

Choose a reason for hiding this comment

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

We need it to avoid leftover ptr's.

@@ -1,4 +1,4 @@
# Copyright (c) 2016 IBM
# Copyright (c) 2025 SAP SE
Copy link

Choose a reason for hiding this comment

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

Copyright is cumulative (i.e. as long as we keep some of the original code, the original's author still applies to that part of the code).
So please don't remove IBMs copyright, but instead add ours next to it, else this would be an IP infringement.
(Needed only for files that we actually change.)

@@ -1,4 +1,4 @@
# Copyright 2012 VMware, Inc.
# Copyright (c) 2025 SAP SE
Copy link

Choose a reason for hiding this comment

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

Same issue with the copyright - we cannot remove other companies as long as there is upstream code left in the file.

Comment on lines 44 to 77
def get_clients(context, all_projects=False, edit_managed=False):
global _SESSION

if not _SESSION:
_SESSION = loading.load_session_from_conf_options(
CONF, 'designate')

auth = token_endpoint.Token(CONF.designate.url, context.auth_token)
client = d_client.Client(session=_SESSION, auth=auth)
if CONF.designate.auth_type:
admin_auth = loading.load_auth_from_conf_options(
CONF, 'designate')
else:
# TODO(tkajinam): Make this fail when admin_* parameters are removed.
admin_auth = password.Password(
auth_url=CONF.designate.admin_auth_url,
username=CONF.designate.admin_username,
password=CONF.designate.admin_password,
tenant_name=CONF.designate.admin_tenant_name,
tenant_id=CONF.designate.admin_tenant_id)
admin_client = d_client.Client(session=_SESSION, auth=admin_auth,
endpoint_override=CONF.designate.url,
all_projects=all_projects,
edit_managed=edit_managed)
return client, admin_client


def get_all_projects_client(context):
auth = token_endpoint.Token(CONF.designate.url, context.auth_token)
return d_client.Client(session=_SESSION, auth=auth, all_projects=True)


def get_all_projects_edit_managed_client(context):
return get_clients(context, all_projects=True, edit_managed=True)
Copy link

Choose a reason for hiding this comment

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

get_clients is modified to support all_projects and edit_managed, which we need.
get_all_projects_client is not used and can be omitted, that is true
and get_all_projects_edit_managed_client is a local addition that is not present in the original upstream.
So there is nothing to import left I think.

Comment on lines +80 to +81
class DesignateCcloud(driver.ExternalDNSService):
"""Driver for Designate."""
Copy link

Choose a reason for hiding this comment

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

I did a diff between the real upstream, our changes in yoga and the new ccloud driver, as well as the 2024.2 version.

Given that most of the code changes and only __init__ and 4 class-internal helper methods are not changed, inheriting from the upstream class seems to have no advantages, but would make the code hard to follow.

Reverting driver.py back to the upstream version would, in my opinion, defeat the purpose of adding a new ccloud driver instead of replacing driver.py. The original upstream driver will not work for us at all, and the reason to keep the our existing driver.py was, to be able to quickly switch back to that version by config, in case the new driver shows bad behavior.

If we replace our existing driver.py with upstream, we could also just replace driver.py by the ccloud_driver.py and be done.

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.

None yet

3 participants