Skip to content

Conversation

@danehans
Copy link
Contributor

Previously, ensureIngressDeleted() was not ensuring ingresscontroller dependent resources no longer existed. This PR updates ensureIngressDeleted() to check for the existence of each ingresscontroller dependent resource. If a dependent resource still exists, ensureIngressDeleted() will add an error to the error list. The ingresscontroller finalizer is only removed when no errors exist in the error list.

/assign @ironcladlou @Miciah

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 20, 2019
if err != nil {
errs = append(errs, fmt.Errorf("failed to get current wildcard dnsrecord for ingress %s/%s: %v", ingress.Namespace, ingress.Name, err))
}
if record != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't use this return value if err is not nil

if err != nil {
errs = append(errs, fmt.Errorf("failed to get deployment for ingress %s/%s: %v", ingress.Namespace, ingress.Name, err))
}
if deploy != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't use this return value if err is not nil

errs := []error{}
if err := r.finalizeLoadBalancerService(ingress); err != nil {
errs = append(errs, fmt.Errorf("failed to finalize load balancer service for %s/%s: %v", ingress.Namespace, ingress.Name, err))
svc, err := r.finalizeLoadBalancerService(ingress)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't read svc is err is not nil... how about just returning a "service still exist" error and when the service is not found return no error?

Copy link
Contributor

Choose a reason for hiding this comment

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

retryable.New could be used for such resource-still-exists errors.

if err != nil {
errs = append(errs, fmt.Errorf("failed to finalize load balancer service for ingress %s/%s: %v", ingress.Namespace, ingress.Name, err))
}
if svc != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use else if. It should not matter in this case since finalizeLoadBalancerService returns a nil service value when it returns a non-nil error value, but generally non-error return values should be ignored in the case of a non-nil error value.

if err != nil {
errs = append(errs, fmt.Errorf("failed to get current wildcard dnsrecord for ingress %s/%s: %v", ingress.Namespace, ingress.Name, err))
}
if record != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

else if?

if err != nil {
errs = append(errs, fmt.Errorf("failed to get deployment for ingress %s/%s: %v", ingress.Namespace, ingress.Name, err))
}
if deploy != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

else if?

// on existing resources.
// TODO: How can we delete this code?
func (r *reconciler) finalizeLoadBalancerService(ci *operatorv1.IngressController) error {
func (r *reconciler) finalizeLoadBalancerService(ci *operatorv1.IngressController) (*corev1.Service, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of a pointer, how about returning a Boolean value to indicate presence of the service?

func (r *reconciler) finalizeLoadBalancerService(ci *operatorv1.IngressController) error {
func (r *reconciler) finalizeLoadBalancerService(ci *operatorv1.IngressController) (*corev1.Service, error) {
service, err := r.currentLoadBalancerService(ci)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if not found, return nil? No reason to return the service

Copy link
Contributor

Choose a reason for hiding this comment

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

currentLoadBalancerService returns nil if the service does not exist.

@danehans
Copy link
Contributor Author

@ironcladlou @Miciah commit 8f1465d addresses your initial feedback.

@Miciah
Copy link
Contributor

Miciah commented Nov 21, 2019

/lgtm
but
/hold
in case @ironcladlou (or anyone else) wants to review again.

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Nov 21, 2019
@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

Details 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

@ironcladlou
Copy link
Contributor

Great, thanks

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 21, 2019
@openshift-merge-robot openshift-merge-robot merged commit 1f864f6 into openshift:master Nov 21, 2019
@danehans danehans deleted the bz_1766141_v2 branch July 31, 2020 16:16
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. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants