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

Bug 1809354: dns: Avoid unnecessary updates #390

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Apr 12, 2020

dns: Avoid spuriously updating a DNSRecord's status

  • pkg/operator/controller/dns/controller.go (Reconcile): Use the new dnsZoneStatusSlicesEqual function to check whether an update is needed, and skip the update if it not.
    (publishRecordToZones): Use the new mergeStatuses function to merge the new zone statuses into the existing ones.
    (mergeStatuses): New function. Merge a slice of updated zone statuses into a slice of old zone statuses, using the new mergeConditions function.
    (clock): New variable.
    (mergeConditions): New function. Merge a slice of updated zone status conditions into an slice of old status conditions, using conditionChanged.
    (conditionChanged): New function. Return a Boolean value indicating whether two zone status conditions should be considered equal.
    (dnsZoneStatusSlicesEqual): New function. Return a Boolean value indicating whether two slices of zone statuses should be considered equal for the purpose of determining whether a status update is needed.
  • pkg/operator/controller/dns/controller_test.go (TestPublishRecordToZonesMergesStatus): New test. Verify that publishRecordToZones correctly merges status updates.
    (TestDnsZoneStatusSlicesEqual): New test. Verify that dnsZoneStatusSlicesEqual behaves correctly.

dns: Log success or failure to publish record

  • pkg/operator/controller/dns/controller.go (publishRecordToZones): Log success or failure to publish the DNS record to a given DNS zone.

Bump openshift/api for DNSRecord observedGeneration

Bump to github.com/openshift/api@17ada6e4245b4cc7a1f81ec04228e9093ec4f89e to get DNSRecordStatus's ObservedGeneration field.

  • go.mod: Bump.
  • go.sum:
  • manifests/00-custom-resource-definition-internal.yaml:
  • pkg/manifests/bindata.go:
  • vendor/*: Regenerate.

dns: Avoid publishing already published DNSRecords

When publishing a DNSRecord to a zone, check its status to determine whether the DNSRecord is already published to that zone, and if it is, skip publishing it to that zone.

  • pkg/operator/controller/dns/controller.go (Reconcile): Update the DNSRecord's observed generation.
    (publishRecordToZones): Use the observed generation and the new recordIsAlreadyPublishedToZone function to skip publishing the DNSRecord to a zone if the DNSRecord has previously been observed and its status conditions indicate that it is already published to the zone.
    (recordIsAlreadyPublishedToZone): New function. Use the provided DNSRecord's status to determine whether the DNSRecord is already published to the provided zone.
  • pkg/operator/controller/dns/controller_test.go (TestRecordIsAlreadyPublishedToZone): New test.

dns/aws: Delete record caching

Delete caching in the DNS provider implementation for AWS now that the DNS controller uses the DNSRecord's status to avoid performing unnecessary updates.

  • pkg/dns/aws/dns.go (Provider): Delete the updatedRecords field.
    (NewProvider): Delete initialization of updatedRecords.
    (change): Delete updating of updatedRecords.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 12, 2020
@ironcladlou
Copy link
Contributor

As discussed offline: this doesn't address a perhaps bigger problem which is that we're still unnecessarily updating the cloud provider every time because we're not comparing spec to status to identify diffs. If we did, not only would we only update the cloud provider when we think there's a change to be made, we could remove the AWS provider's internal caching logic.

We also discussed how when Ensure() fails, we should only update the condition last transition time if the condition has a material change, and in the face of repeated failures, we should log events so that a timeline of failure can be established.

@Miciah Miciah force-pushed the dns-avoid-spuriously-updating-a-DNSRecords-status branch 2 times, most recently from a5e8142 to 9997222 Compare May 12, 2020 23:21
@Miciah Miciah changed the title dns: Avoid spuriously updating a DNSRecord's status WIP: Bug 1809354: dns: Avoid unnecessary updates May 12, 2020
@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 12, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Bugzilla bug 1809354, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

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

In response to this:

WIP: Bug 1809354: dns: Avoid unnecessary updates

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 Bugzilla bug 1809354, which is valid.

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

In response to this:

WIP: Bug 1809354: dns: Avoid unnecessary updates

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.

@Miciah
Copy link
Contributor Author

Miciah commented May 19, 2020

The test failure should be resolved by #396.

/test e2e-aws-operator

This change should also fix https://bugzilla.redhat.com/show_bug.cgi?id=1837324.

/retitle Bug 1809354, 1837324: dns: Avoid unnecessary updates

@openshift-ci-robot openshift-ci-robot changed the title WIP: Bug 1809354: dns: Avoid unnecessary updates Bug 1809354, 1837324: dns: Avoid unnecessary updates May 19, 2020
@openshift-ci-robot openshift-ci-robot removed bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 19, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

Bug 1809354, 1837324: dns: Avoid unnecessary updates

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.

@Miciah
Copy link
Contributor Author

Miciah commented May 19, 2020

Apparently support for linking multiple bugs was never merged.

/retitle Bug 1809354: dns: Avoid unnecessary updates

@openshift-ci-robot openshift-ci-robot changed the title Bug 1809354, 1837324: dns: Avoid unnecessary updates Bug 1809354: dns: Avoid unnecessary updates May 19, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 19, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Bugzilla bug 1809354, which is valid.

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

In response to this:

Bug 1809354: dns: Avoid unnecessary updates

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.

@Miciah
Copy link
Contributor Author

Miciah commented May 19, 2020

I forgot that the reason that this was marked WIP was that it was blocked on openshift/api#644.

/retitle WIP: Bug 1809354: dns: Avoid unnecessary updates

@openshift-ci-robot openshift-ci-robot changed the title Bug 1809354: dns: Avoid unnecessary updates WIP: Bug 1809354: dns: Avoid unnecessary updates May 19, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 19, 2020
@Miciah Miciah force-pushed the dns-avoid-spuriously-updating-a-DNSRecords-status branch from 9997222 to 3af46dc Compare May 19, 2020 17:57
@danehans
Copy link
Contributor

@Miciah regarding #390 (comment), yes that's my understanding. Then the go.mod/go.sum in this PR needs to be updated to use openshift/api instead of your modified version.

@Miciah Miciah force-pushed the dns-avoid-spuriously-updating-a-DNSRecords-status branch from 3af46dc to 5876f2f Compare May 22, 2020 18:49
@Miciah Miciah changed the title WIP: Bug 1809354: dns: Avoid unnecessary updates Bug 1809354: dns: Avoid unnecessary updates May 22, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 22, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Bugzilla bug 1809354, which is valid.

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

In response to this:

Bug 1809354: dns: Avoid unnecessary updates

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.

@Miciah
Copy link
Contributor Author

Miciah commented May 22, 2020

Rebased onto github.com/openshift/api@17ada6e4245b4cc7a1f81ec04228e9093ec4f89e.

@Miciah Miciah force-pushed the dns-avoid-spuriously-updating-a-DNSRecords-status branch from 5876f2f to 4e7bcd6 Compare May 26, 2020 17:12
@Miciah
Copy link
Contributor Author

Miciah commented May 26, 2020

Rebased to resolve a conflict in bindata.go from #401.

@danehans
Copy link
Contributor

error: unable to parse image registry.svc.ci.openshift.org/ci-op-qxhzdvvc/stable@sha256:bc679512a4ddcf2d7b433ed99b0ef3014ec167cddfcba95079b38aae5e28d0ef: cannot retrieve image configuration for manifest sha256:bc679512a4ddcf2d7b433ed99b0ef3014ec167cddfcba95079b38aae5e28d0ef: received unexpected HTTP status: 503 Service Unavailable

/retest

@Miciah Miciah force-pushed the dns-avoid-spuriously-updating-a-DNSRecords-status branch from 4e7bcd6 to 3c839e6 Compare May 26, 2020 17:36
@Miciah
Copy link
Contributor Author

Miciah commented May 26, 2020

I added a test case to TestPublishRecordToZonesMergesStatus to make sure we have complete coverage of mergeConditions (thanks @sgreene570!).

* pkg/operator/controller/dns/controller.go (Reconcile): Use the new
dnsZoneStatusSlicesEqual function to check whether an update is needed,
and skip the update if it not.
(publishRecordToZones): Use the new mergeStatuses function to merge the new
zone statuses into the existing ones.
(mergeStatuses): New function.  Merge a slice of updated zone statuses into
a slice of old zone statuses, using the new mergeConditions function.
(clock): New variable.
(mergeConditions): New function.  Merge a slice of updated zone status
conditions into an slice of old status conditions, using conditionChanged.
(conditionChanged): New function.  Return a Boolean value indicating
whether two zone status conditions should be considered equal.
(dnsZoneStatusSlicesEqual): New function.  Return a Boolean value
indicating whether two slices of zone statuses should be considered equal
for the purpose of determining whether a status update is needed.
* pkg/operator/controller/dns/controller_test.go
(TestPublishRecordToZonesMergesStatus): New test.  Verify that
publishRecordToZones correctly merges status updates.
(TestDnsZoneStatusSlicesEqual): New test.  Verify that
dnsZoneStatusSlicesEqual behaves correctly.
* pkg/operator/controller/dns/controller.go (publishRecordToZones): Log
success or failure to publish the DNS record to a given DNS zone.
Bump to github.com/openshift/api@17ada6e4245b4cc7a1f81ec04228e9093ec4f89e
to get DNSRecordStatus's ObservedGeneration field.

* go.mod: Bump.
* go.sum:
* manifests/00-custom-resource-definition-internal.yaml:
* pkg/manifests/bindata.go:
* vendor/*: Regenerate.
When publishing a DNSRecord to a zone, check its status to determine
whether the DNSRecord is already published to that zone, and if it is,
skip publishing it to that zone.

This commit fixes bug 1809354.

https://bugzilla.redhat.com/show_bug.cgi?id=1809354

* pkg/operator/controller/dns/controller.go (Reconcile): Update the
DNSRecord's observed generation.
(publishRecordToZones): Use the observed generation and the new
recordIsAlreadyPublishedToZone function to skip publishing the DNSRecord to
a zone if the DNSRecord has previously been observed and its status
conditions indicate that it is already published to the zone.
(recordIsAlreadyPublishedToZone): New function.  Use the provided
DNSRecord's status to determine whether the DNSRecord is already published
to the provided zone.
* pkg/operator/controller/dns/controller_test.go
(TestRecordIsAlreadyPublishedToZone): New test.
Delete caching in the DNS provider implementation for AWS now that the DNS
controller uses the DNSRecord's status to avoid performing unnecessary
updates.

* pkg/dns/aws/dns.go (Provider): Delete the updatedRecords field.
(NewProvider): Delete initialization of updatedRecords.
(change): Delete updating of updatedRecords.
@Miciah Miciah force-pushed the dns-avoid-spuriously-updating-a-DNSRecords-status branch from 3c839e6 to 8cae0a4 Compare May 26, 2020 17:42
@danehans
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 26, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danehans, Miciah

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

The pull request process is described 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

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 59d6032 into openshift:master May 27, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: All pull requests linked via external trackers have merged: openshift/api#644, openshift/cluster-ingress-operator#390. Bugzilla bug 1809354 has been moved to the MODIFIED state.

In response to this:

Bug 1809354: dns: Avoid unnecessary updates

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants