Skip to content

feat(dns): dns record requirer#506

Open
yanksyoon wants to merge 34 commits into
mainfrom
feat/ISD-3237/dns-record-requirer
Open

feat(dns): dns record requirer#506
yanksyoon wants to merge 34 commits into
mainfrom
feat/ISD-3237/dns-record-requirer

Conversation

@yanksyoon
Copy link
Copy Markdown
Member

@yanksyoon yanksyoon commented May 7, 2026

What this PR does

Adds an optional dns-record requirer integration that publishes DNS A records for HAProxy hostnames (derived from certificate requests), using the VIP when HA is active or the unit ingress address otherwise.

Why we need it

Automates DNS record management for hostnames served by HAProxy, removing the need for manual DNS configuration.

Checklist

  • I followed the contributing guide
  • I added or updated the documentation (if applicable)
  • I updated docs/changelog.md with user-relevant changes
  • I added a change artifact for user-relevant changes in docs/release-notes/artifacts. If no change artifact is necessary, I tagged the PR with the label no-release-note.
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and integration)
  • If integration test modules are used: I updated the workflow configuration
    (e.g., in .github/workflows/integration_tests.yaml, ensure the modules list is correct)
  • If this PR involves a Grafana dashboard: I added a screenshot of the dashboard
  • If this PR involves Terraform: terraform fmt passes and tflint reports no errors

yanksyoon and others added 6 commits May 7, 2026 16:56
….yaml

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… dns-record relation

- Add DNSRecordRequires import and initialize in HAProxyCharm.__init__
- Add _on_dns_record_relation_created and _on_dns_record_relation_joined event handlers
- Implement _update_dns_records method that:
  * Publishes A records for managed hostnames
  * Uses VIP when HA relation is active
  * Falls back to ingress binding address otherwise
- Call _update_dns_records from _reconcile to update DNS on config changes
- Add dns_record_relation fixture for testing
- Add context_with_dns_mock fixture with mocked services for unit tests
- Add 4 test cases covering relation events and IP address selection logic

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ator

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yanksyoon yanksyoon requested a review from a team as a code owner May 7, 2026 11:09
@alithethird alithethird added the no-release-note This PR does not require a change artifact label May 7, 2026
- Remove dns_record.dns_record from charm-libs (library is vendored,
  not published on Charmhub) — fixes 'Check libraries' CI failure
- Apply ruff format to integration conftest.py (unnecessary parens)
- Fix RUF005 violations in test_charm.py (use iterable unpacking)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the dns-record relation's network binding instead of the ingress
relation binding. This ensures DNS records are assigned IPs in whatever
subnet the dns-record interface is bound to.
…ord-requirer

# Conflicts:
#	docs/changelog.md
Comment thread haproxy-operator/src/charm.py Outdated
Comment on lines +566 to +567
# The try/except is needed for the relation_created/joined handlers which call
# _update_dns_records directly without going through _reconcile first.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Given that I think we are also updating the dns records towards the end of the reconcile loop, can't we also hook these 2 events to the reconcile loop? Since i think it's a bit strange to have this event-based logic in a holistic charm.

We're reloading the haproxy service so there should not be any impact on uptime if we run reconcile on all events

Copy link
Copy Markdown
Collaborator

@Thanhphan1147 Thanhphan1147 left a comment

Choose a reason for hiding this comment

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

Approved with one last comment

yanksyoon and others added 2 commits June 4, 2026 11:47
Address review feedback: instead of dedicated handlers for dns-record
relation_created/joined that call _update_dns_records directly, route
these events through _on_config_changed -> _reconcile() like all other
relation events in this holistic charm.

Also migrates dns_record lib from charms.dns_record to
charms.dns_integrator namespace (dns-record charm doesn't exist on
Charmhub; dns-integrator does).
The dns_record library is published under the dns-integrator charm on
Charmhub. Update charmcraft.yaml charm-libs so fetch-lib resolves
correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Libraries: Out of sync no-release-note This PR does not require a change artifact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants