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

WIP: OCPBUGS-8526: gateway-service-dns: Use gateway addresses to configure DNS #969

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Jul 26, 2023

gateway-service-dns: Test_Reconcile: Parameterize record type

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change dnsrecord helper to parameterize the DNS record type in test cases for Test_Reconcile.

gateway-service-dns: Test_Reconcile: Change listeners to slice

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change gw helper's listeners parameter from a variadic parameter to slice.

gateway-service-dns: Use gateway addresses to configure DNS records

  • pkg/operator/controller/gateway-service-dns/controller.go (managedByIstioLabelKey): Remove const, which is no longer needed after subsequent changes.
    (NewUnmanaged): Remove the watch on services and the watch's associated predicates. Enqueue reconciliation requests for gateways instead of services. Define a predicate that checks the gateway addresses, using the new gatewayAddressesChanged helper function, and use this predicate to enqueue a reconciliation request for a gateway when any of its addresses changes.
    (gatewayAddressesChanged): New function. Return a Boolean value indicating whether the given gateway's addresses have changed.
    (Reconcile): Expect the reconciliation request to be for a gateway instead of a service. Use the new getGatewayAddresses helper function to get the gateway's addresses, and pass these addresses to ensureDNSRecordsForGateway and deleteStaleDNSRecordsForGateway.
    (getGatewayAddresses): New helper function. Return a list of addresses that can be used as targets for a DNSRecord CR, as well as a record type.
    (ensureDNSRecordsForGateway): Replace the service parameter with "targets" and "recordType" parameters. Pass targets and recordType to EnsureDNSRecord. Change the owner reference for the DNSRecord CR to specify the gateway instead of the service.
    (deleteStaleDNSRecordsForGateway): Replace the service parameter with a "targets" parameter. Use the new targets parameter and existing domains parameter to preserve any DNSRecord CR that has both a valid domain and a valid target.
  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Add addresses to gateway test inputs, and remove services as test inputs. Add a test case for a gateway with an address but no listeners, as well as a test case for various combinations of addresses.
    (Test_gatewayAddressesChanged): New test. Verify that gatewayAddressesChanged behaves as expected.
  • pkg/resources/dnsrecord/dns.go (EnsureDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Pass these new parameters to desiredDNSRecord.
    (desiredDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Move service-specific logic from here...
    (desiredWildcardDNSRecord): ...to here.

* pkg/operator/controller/gateway-service-dns/controller_test.go
(Test_Reconcile): Change dnsrecord helper to parameterize the DNS record
type in test cases for Test_Reconcile.
* pkg/operator/controller/gateway-service-dns/controller_test.go
(Test_Reconcile): Change gw helper's listeners parameter from a variadic
parameter to slice.
* pkg/operator/controller/gateway-service-dns/controller.go
(managedByIstioLabelKey): Remove const, which is no longer needed after
subsequent changes.
(NewUnmanaged): Remove the watch on services and the watch's associated
predicates.  Enqueue reconciliation requests for gateways instead of
services.  Define a predicate that checks the gateway addresses, using the
new gatewayAddressesChanged helper function, and use this predicate to
enqueue a reconciliation request for a gateway when any of its addresses
changes.
(gatewayAddressesChanged): New function.  Return a Boolean value indicating
whether the given gateway's addresses have changed.
(Reconcile): Expect the reconciliation request to be for a gateway instead
of a service.  Use the new getGatewayAddresses helper function to get the
gateway's addresses, and pass these addresses to ensureDNSRecordsForGateway
and deleteStaleDNSRecordsForGateway.
(getGatewayAddresses): New helper function.  Return a list of addresses
that can be used as targets for a DNSRecord CR, as well as a record type.
(ensureDNSRecordsForGateway): Replace the service parameter with "targets"
and "recordType" parameters.  Pass targets and recordType to
EnsureDNSRecord.  Change the owner reference for the DNSRecord CR to
specify the gateway instead of the service.
(deleteStaleDNSRecordsForGateway): Replace the service parameter with a
"targets" parameter.  Use the new targets parameter and existing domains
parameter to preserve any DNSRecord CR that has both a valid domain and a
valid target.
* pkg/operator/controller/gateway-service-dns/controller_test.go
(Test_Reconcile): Add addresses to gateway test inputs, and remove services
as test inputs.  Add a test case for a gateway with an address but no
listeners, as well as a test case for various combinations of addresses.
(Test_gatewayAddressesChanged): New test.  Verify that
gatewayAddressesChanged behaves as expected.
* pkg/resources/dnsrecord/dns.go (EnsureDNSRecord): Replace the service
parameter with "targets" and "recordType" parameters.  Pass these new
parameters to desiredDNSRecord.
(desiredDNSRecord): Replace the service parameter with "targets" and
"recordType" parameters.  Move service-specific logic from here...
(desiredWildcardDNSRecord): ...to here.
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 26, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. labels Jul 26, 2023
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Jira Issue OCPBUGS-8526, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.14.0) matches configured target version for branch (4.14.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @lihongan

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

gateway-service-dns: Test_Reconcile: Parameterize record type

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change dnsrecord helper to parameterize the DNS record type in test cases for Test_Reconcile.

gateway-service-dns: Test_Reconcile: Change listeners to slice

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change gw helper's listeners parameter from a variadic parameter to slice.

gateway-service-dns: Use gateway addresses to configure DNS records

  • pkg/operator/controller/gateway-service-dns/controller.go (managedByIstioLabelKey): Remove const, which is no longer needed after subsequent changes.
    (NewUnmanaged): Remove the watch on services and the watch's associated predicates. Enqueue reconciliation requests for gateways instead of services. Define a predicate that checks the gateway addresses, using the new gatewayAddressesChanged helper function, and use this predicate to enqueue a reconciliation request for a gateway when any of its addresses changes.
    (gatewayAddressesChanged): New function. Return a Boolean value indicating whether the given gateway's addresses have changed.
    (Reconcile): Expect the reconciliation request to be for a gateway instead of a service. Use the new getGatewayAddresses helper function to get the gateway's addresses, and pass these addresses to ensureDNSRecordsForGateway and deleteStaleDNSRecordsForGateway.
    (getGatewayAddresses): New helper function. Return a list of addresses that can be used as targets for a DNSRecord CR, as well as a record type.
    (ensureDNSRecordsForGateway): Replace the service parameter with "targets" and "recordType" parameters. Pass targets and recordType to EnsureDNSRecord. Change the owner reference for the DNSRecord CR to specify the gateway instead of the service.
    (deleteStaleDNSRecordsForGateway): Replace the service parameter with a "targets" parameter. Use the new targets parameter and existing domains parameter to preserve any DNSRecord CR that has both a valid domain and a valid target.
  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Add addresses to gateway test inputs, and remove services as test inputs. Add a test case for a gateway with an address but no listeners, as well as a test case for various combinations of addresses.
    (Test_gatewayAddressesChanged): New test. Verify that gatewayAddressesChanged behaves as expected.
  • pkg/resources/dnsrecord/dns.go (EnsureDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Pass these new parameters to desiredDNSRecord.
    (desiredDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Move service-specific logic from here...
    (desiredWildcardDNSRecord): ...to here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Jul 26, 2023
@openshift-ci openshift-ci bot requested a review from lihongan July 26, 2023 00:25
@candita
Copy link
Contributor

candita commented Jul 26, 2023

/assign
/assign @gcs278

Comment on lines +142 to +143
// Set the DNS management policy on the dnsrecord to "Unmanaged" if ingresscontroller has "Unmanaged" DNS policy or
// if the ingresscontroller domain isn't a subdomain of the cluster's base domain.
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this referenced condition examined: "or if the ingresscontroller domain isn't a subdomain of the cluster's base domain" ?

haveWC, current, err := CurrentDNSRecord(client, name)
if err != nil {
return false, nil, err
}

switch {
case wantWC && !haveWC:
case !haveWC:
Copy link
Contributor

Choose a reason for hiding this comment

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

The WC suffix can be removed, just use have.

func EnsureDNSRecord(client client.Client, name types.NamespacedName, dnsRecordLabels map[string]string, ownerRef metav1.OwnerReference, domain string, service *corev1.Service) (bool, *iov1.DNSRecord, error) {
wantWC, desired := desiredDNSRecord(name, dnsRecordLabels, ownerRef, domain, iov1.ManagedDNS, service)
func EnsureDNSRecord(client client.Client, name types.NamespacedName, dnsRecordLabels map[string]string, ownerRef metav1.OwnerReference, domain string, targets []string, recordType iov1.DNSRecordType) (bool, *iov1.DNSRecord, error) {
desired := desiredDNSRecord(name, dnsRecordLabels, ownerRef, domain, iov1.ManagedDNS, targets, recordType)
Copy link
Contributor

Choose a reason for hiding this comment

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

desiredDNSRecord used to do a bit of validation and return false under certain circumstances. That logic was moved to desiredWildcardDNSRecord. Is L69 supposed to be calling the latter?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 6, 2023
@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 5, 2023
@candita
Copy link
Contributor

candita commented Nov 6, 2023

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 6, 2023
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 5, 2024
@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 6, 2024
@openshift-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Apr 29, 2024
Copy link
Contributor

openshift-ci bot commented Apr 29, 2024

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Jira Issue OCPBUGS-8526. The bug has been updated to no longer refer to the pull request using the external bug tracker. All external bug links have been closed. The bug has been moved to the NEW state.

In response to this:

gateway-service-dns: Test_Reconcile: Parameterize record type

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change dnsrecord helper to parameterize the DNS record type in test cases for Test_Reconcile.

gateway-service-dns: Test_Reconcile: Change listeners to slice

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change gw helper's listeners parameter from a variadic parameter to slice.

gateway-service-dns: Use gateway addresses to configure DNS records

  • pkg/operator/controller/gateway-service-dns/controller.go (managedByIstioLabelKey): Remove const, which is no longer needed after subsequent changes.
    (NewUnmanaged): Remove the watch on services and the watch's associated predicates. Enqueue reconciliation requests for gateways instead of services. Define a predicate that checks the gateway addresses, using the new gatewayAddressesChanged helper function, and use this predicate to enqueue a reconciliation request for a gateway when any of its addresses changes.
    (gatewayAddressesChanged): New function. Return a Boolean value indicating whether the given gateway's addresses have changed.
    (Reconcile): Expect the reconciliation request to be for a gateway instead of a service. Use the new getGatewayAddresses helper function to get the gateway's addresses, and pass these addresses to ensureDNSRecordsForGateway and deleteStaleDNSRecordsForGateway.
    (getGatewayAddresses): New helper function. Return a list of addresses that can be used as targets for a DNSRecord CR, as well as a record type.
    (ensureDNSRecordsForGateway): Replace the service parameter with "targets" and "recordType" parameters. Pass targets and recordType to EnsureDNSRecord. Change the owner reference for the DNSRecord CR to specify the gateway instead of the service.
    (deleteStaleDNSRecordsForGateway): Replace the service parameter with a "targets" parameter. Use the new targets parameter and existing domains parameter to preserve any DNSRecord CR that has both a valid domain and a valid target.
  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Add addresses to gateway test inputs, and remove services as test inputs. Add a test case for a gateway with an address but no listeners, as well as a test case for various combinations of addresses.
    (Test_gatewayAddressesChanged): New test. Verify that gatewayAddressesChanged behaves as expected.
  • pkg/resources/dnsrecord/dns.go (EnsureDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Pass these new parameters to desiredDNSRecord.
    (desiredDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Move service-specific logic from here...
    (desiredWildcardDNSRecord): ...to here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@candita
Copy link
Contributor

candita commented May 2, 2024

/reopen

@openshift-ci openshift-ci bot reopened this May 2, 2024
Copy link
Contributor

openshift-ci bot commented May 2, 2024

@candita: Reopened this PR.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels May 2, 2024
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Jira Issue OCPBUGS-8526, which is invalid:

  • expected the bug to target either version "4.16." or "openshift-4.16.", but it targets "4.15.z" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

gateway-service-dns: Test_Reconcile: Parameterize record type

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change dnsrecord helper to parameterize the DNS record type in test cases for Test_Reconcile.

gateway-service-dns: Test_Reconcile: Change listeners to slice

  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Change gw helper's listeners parameter from a variadic parameter to slice.

gateway-service-dns: Use gateway addresses to configure DNS records

  • pkg/operator/controller/gateway-service-dns/controller.go (managedByIstioLabelKey): Remove const, which is no longer needed after subsequent changes.
    (NewUnmanaged): Remove the watch on services and the watch's associated predicates. Enqueue reconciliation requests for gateways instead of services. Define a predicate that checks the gateway addresses, using the new gatewayAddressesChanged helper function, and use this predicate to enqueue a reconciliation request for a gateway when any of its addresses changes.
    (gatewayAddressesChanged): New function. Return a Boolean value indicating whether the given gateway's addresses have changed.
    (Reconcile): Expect the reconciliation request to be for a gateway instead of a service. Use the new getGatewayAddresses helper function to get the gateway's addresses, and pass these addresses to ensureDNSRecordsForGateway and deleteStaleDNSRecordsForGateway.
    (getGatewayAddresses): New helper function. Return a list of addresses that can be used as targets for a DNSRecord CR, as well as a record type.
    (ensureDNSRecordsForGateway): Replace the service parameter with "targets" and "recordType" parameters. Pass targets and recordType to EnsureDNSRecord. Change the owner reference for the DNSRecord CR to specify the gateway instead of the service.
    (deleteStaleDNSRecordsForGateway): Replace the service parameter with a "targets" parameter. Use the new targets parameter and existing domains parameter to preserve any DNSRecord CR that has both a valid domain and a valid target.
  • pkg/operator/controller/gateway-service-dns/controller_test.go (Test_Reconcile): Add addresses to gateway test inputs, and remove services as test inputs. Add a test case for a gateway with an address but no listeners, as well as a test case for various combinations of addresses.
    (Test_gatewayAddressesChanged): New test. Verify that gatewayAddressesChanged behaves as expected.
  • pkg/resources/dnsrecord/dns.go (EnsureDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Pass these new parameters to desiredDNSRecord.
    (desiredDNSRecord): Replace the service parameter with "targets" and "recordType" parameters. Move service-specific logic from here...
    (desiredWildcardDNSRecord): ...to here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented May 2, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from candita. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants