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 1898417: GCP the dns targets in Google Cloud DNS is not updated after recreating loadbalancer service #500
Bug 1898417: GCP the dns targets in Google Cloud DNS is not updated after recreating loadbalancer service #500
Conversation
537103f
to
b617bc6
Compare
pkg/dns/gcp/provider.go
Outdated
"google.golang.org/api/googleapi" | ||
"net/http" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standard go libraries should be imported first, so I would undo this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The go fmt does not allow to do this. I think it is ordering alphabetically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add the blank line back, sorting shouldn't matter. ie:
"net/http" | |
import ( | |
"context" | |
"net/http" | |
"google.golang.org/api/googleapi" | |
... |
pkg/dns/gcp/provider.go
Outdated
delete := p.Delete(record, zone) | ||
if delete != nil { | ||
return delete | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete := p.Delete(record, zone) | |
if delete != nil { | |
return delete | |
} | |
if err := p.Delete(record, zone); err != nil { | |
return err | |
} |
pkg/dns/gcp/provider.go
Outdated
return delete | ||
} | ||
create := p.Ensure(record, zone) | ||
if create != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion as above.
32d3c02
to
af0ebd5
Compare
@miheer: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
/bugzilla cc-qa |
@lihongan: No Bugzilla bug is referenced in the title of this pull request. In response to this:
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. |
@miheer could you please update the title of this pull request to |
@miheer: This pull request references Bugzilla bug 1898417, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
In response to this:
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. |
/bugzilla cc-qa |
@lihongan: This pull request references Bugzilla bug 1898417, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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. |
pkg/dns/gcp/provider.go
Outdated
@@ -2,6 +2,8 @@ package gcp | |||
|
|||
import ( | |||
"context" | |||
"fmt" | |||
"log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't import the log
package; instead, import github.com/openshift/cluster-ingress-operator/pkg/log
and declare a logger as the other DNS providers do:
import (
// ...
logf "github.com/openshift/cluster-ingress-operator/pkg/log"
)
var (
_ dns.Provider = &Provider{}
log = logf.Logger.WithName("dns")
)
pkg/dns/gcp/provider.go
Outdated
oldRecord := p.dnsService.ResourceRecordSets.List(p.config.Project, zone.ID).Name(record.Spec.DNSName) | ||
if err := oldRecord.Pages(ctx, func(page *gdnsv1.ResourceRecordSetsListResponse) error { | ||
for _, resourceRecordSet := range page.Rrsets { | ||
log.Println(fmt.Printf("%#v\n", resourceRecordSet)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be deleted, or replaced with something like this: log.Info("found old DNS resource record set", "resourceRecordSet" resourceRecordSet)
.
pkg/dns/gcp/provider.go
Outdated
} | ||
return nil | ||
}); err != nil { | ||
log.Fatal(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this fatal? Why not just return err
?
_, err := call.Do() | ||
if ae, ok := err.(*googleapi.Error); ok && ae.Code == http.StatusNotFound { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a return err
after this if
block so that the anonymous function returns the error value, which the Pages
method will then return to be handled below.
if record.Generation == record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone) { | ||
log.Info("skipping zone to which the DNS record is already published", "record", record.Spec, "dnszone", zone) | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move this block?
log.Info("replacing DNS record", "record", record.Spec, "dnszone", zone) | ||
|
||
if err := r.dnsProvider.Replace(record, zone); err != nil { | ||
log.Error(err, "failed to replace DNS record to zone", "record", record.Spec, "dnszone", zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error(err, "failed to replace DNS record to zone", "record", record.Spec, "dnszone", zone) | |
log.Error(err, "failed to replace DNS record in zone", "record", record.Spec, "dnszone", zone) |
Or just delete " to zone".
condition.Message = fmt.Sprintf("The DNS provider failed to replace the record: %v", err) | ||
result.RequeueAfter = 30 * time.Second | ||
} else { | ||
log.Info("replaced DNS record to zone", "record", record.Spec, "dnszone", zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info("replaced DNS record to zone", "record", record.Spec, "dnszone", zone) | |
log.Info("replaced DNS record in zone", "record", record.Spec, "dnszone", zone) |
condition.Reason = "ProviderSuccess" | ||
condition.Message = "The DNS provider succeeded in replacing the record" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to update statuses
and then continue
here to avoid executing the Ensure
logic below (and failing). Alternatively, add an else
block and pull the Ensure
logic into it, which would be simpler and more readable:
if record.Generation == record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone) {
log.Info("skipping zone to which the DNS record is already published", "record", record.Spec, "dnszone", zone)
continue
}
condition := iov1.DNSZoneCondition{
Status: string(operatorv1.ConditionUnknown),
Type: iov1.DNSRecordFailedConditionType,
LastTransitionTime: metav1.Now(),
}
if recordIsAlreadyPublishedToZone(record, &zone) {
if err := r.dnsProvider.Replace(record, zone); err != nil {
log.Error(err, "failed to replace DNS record", "record", record.Spec, "dnszone", zone)
condition.Status = string(operatorv1.ConditionTrue)
condition.Reason = "ProviderError"
condition.Message = fmt.Sprintf("The DNS provider failed to replace the record: %v", err)
result.RequeueAfter = 30 * time.Second
} else {
log.Info("replaced DNS record", "record", record.Spec, "dnszone", zone)
condition.Status = string(operatorv1.ConditionFalse)
condition.Reason = "ProviderSuccess"
condition.Message = "The DNS provider succeeded in replacing the record"
}
} else {
if err := r.dnsProvider.Ensure(record, zone); err != nil {
log.Error(err, "failed to publish DNS record to zone", "record", record.Spec, "dnszone", zone)
condition.Status = string(operatorv1.ConditionTrue)
condition.Reason = "ProviderError"
condition.Message = fmt.Sprintf("The DNS provider failed to ensure the record: %v", err)
result.RequeueAfter = 30 * time.Second
} else {
log.Info("published DNS record to zone", "record", record.Spec, "dnszone", zone)
condition.Status = string(operatorv1.ConditionFalse)
condition.Reason = "ProviderSuccess"
condition.Message = "The DNS provider succeeded in ensuring the record"
}
}
statuses = append(statuses, iov1.DNSZoneStatus{
DNSZone: zone,
Conditions: []iov1.DNSZoneCondition{condition},
})
|
||
condition := iov1.DNSZoneCondition{ | ||
Status: string(operatorv1.ConditionUnknown), | ||
Type: iov1.DNSRecordFailedConditionType, | ||
LastTransitionTime: metav1.Now(), | ||
} | ||
|
||
if record.Generation != record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone) { | ||
log.Info("replacing DNS record", "record", record.Spec, "dnszone", zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't need this log statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK just added so that in the logs we can get it went to replace action
pkg/dns/dns.go
Outdated
@@ -13,11 +13,15 @@ type Provider interface { | |||
|
|||
// Delete will delete record. | |||
Delete(record *iov1.DNSRecord, zone configv1.DNSZone) error | |||
|
|||
//Replace will replace the record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//Replace will replace the record | |
// Replace will replace the record |
af0ebd5
to
a1e1b39
Compare
pkg/dns/gcp/provider.go
Outdated
@@ -13,10 +13,13 @@ import ( | |||
|
|||
gdnsv1 "google.golang.org/api/dns/v1" | |||
"google.golang.org/api/option" | |||
|
|||
logf "github.com/openshift/cluster-ingress-operator/pkg/log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be grouped with "github.com/openshift/cluster-ingress-operator/pkg/dns"
.
condition.Reason = "ProviderError" | ||
condition.Message = fmt.Sprintf("The DNS provider failed to ensure the record: %v", err) | ||
result.RequeueAfter = 30 * time.Second | ||
if record.Generation != record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check record.Generation == record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone)
above and return if that condition is true, so we can simplify this condition as follows:
if record.Generation != record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone) { | |
if recordIsAlreadyPublishedToZone(record, &zone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't need to check the Generation ? @Miciah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it because we already checked that condition on line 254 ? @Miciah
} else if record.Generation == record.Status.ObservedGeneration && recordIsAlreadyPublishedToZone(record, &zone) { | ||
log.Info("skipping zone to which the DNS record is already published", "record", record.Spec, "dnszone", zone) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else if
block is redundant and can be deleted.
@Miciah Here is what I did -> Also this issue does not seem to be related this PR. I deleted the svc router default from a cluster which did not have this PR fix and that also hung where I had to delete the finalizer from the svc to get the delete command completed from hung state. After that the external IP was assigned. |
That does look like a new issue. The service controller adds the annotation, but it should be adding it when the service is created. How quickly did you delete the service after it was created? Can you check the service controller logs for clues? This likely warrants a new Bugzilla report. |
/retest |
@Miciah I think we don't have any control at kubernetes service level code so before deleting the service we need to delete the finalizers and then perform the delete action. Shall we close this BZ bhttps://bugzilla.redhat.com/show_bug.cgi?id=1914127 |
@Miciah also can you approve this PR ? |
7323f44
to
db0d237
Compare
… after recreating loadbalancer service
db0d237
to
eb4c9be
Compare
Last couple of updates fixed the only remaining outstanding feedback, so |
/retest Please review the full test history for this PR and help us cut down flakes. |
6 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/test ? |
@Miciah: The following commands are available to trigger jobs:
Use
In response to this:
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. |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lihongan, Miciah, miheer 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 |
@miheer: Bugzilla bug 1898417 is in an unrecognized state (ON_QA) and will not be moved to the MODIFIED state. In response to this:
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. |
GCP: the dns targets in Google Cloud DNS is not updated after recreating loadbalancer service