Skip to content

Conversation

@ironcladlou
Copy link
Contributor

Refactor the handler to be level driven.

/cc @openshift/sig-network-edge

@openshift-ci-robot openshift-ci-robot requested a review from a team October 16, 2018 13:35
@ironcladlou
Copy link
Contributor Author

/hold

@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. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 16, 2018
@ironcladlou
Copy link
Contributor Author

Holy cow, not sure why the dep update dragged in so much new junk. I want to revert that and try again.

@ironcladlou
Copy link
Contributor Author

Okay, I decided to copy and paste a slightly modified slice.RemoveString rather than dragging in all of Kubernetes. 😁

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 16, 2018
@ironcladlou
Copy link
Contributor Author

Tested end-to-end in a 4.0 AWS cluster. Ensured defaulting and delete handling works.

@ironcladlou
Copy link
Contributor Author

/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 Oct 16, 2018
Refactor the handler to be level driven.
@imcsk8
Copy link
Contributor

imcsk8 commented Oct 16, 2018

nice!
it feels more on the operators reconciliation pattern

logrus.Infof("reconciling for update to clusteringress %q", o.Name)
}
return nil
return h.reconcile()

Choose a reason for hiding this comment

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

perform h.reconcole() only when we are dealing with ingressv1alpha1.ClusterIngress? This seems to call this reconciler for non cluster ingress objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'll trigger for any object we're actively watching in our entry point, which for now is just ClusterIngress, but in the future should be other types of resources that we might want to trigger a reconciliation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we log conditionally and reconcile unconditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason, logging can be tweaked

}
// Clean up the finalizer to allow the clusteringress to be deleted.
ingress.Finalizers = RemoveString(ingress.Finalizers, "ingress.openshift.io/default-cluster-ingress")
err = sdk.Update(&ingress)

Choose a reason for hiding this comment

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

Once we update ingress object, don't we see another event for the same object? if yes, that will have DeletionTimestamp but no finalizers section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and although that still works now, we're doing an additional pointless update. So I think we're at least still correct/reentrant/idempotent... I'll fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

func (h *Handler) reconcile() error {
// Ensure we have all the necessary scaffolding on which to place router
// instances.
err := h.ensureRouterNamespace()

Choose a reason for hiding this comment

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

Do we really want to do this for every event? Seems like one time op.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not, but it seems advantageous to keep it simple for now. We could do a lookup before bothering to try creating the namespace rather than relying on a superfluous create attempt.


// RemoveString returns a newly created []string that contains all items from slice that
// are not equal to s.
func RemoveString(slice []string, s string) []string {

Choose a reason for hiding this comment

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

removeString() if we don't expect to be used in other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish the upstream slice package were in a better place so we could use it and some other nice stuff I'll have to copy in 😞

manifestFactory *manifests.Factory
}

func (h *Handler) Handle(ctx context.Context, event sdk.Event) error {

Choose a reason for hiding this comment

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

What does ctx hold with this new scheme (not useful at this time)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to look at operator-sdk code, not sure. Nothing important for now AFAIK.

Copy link

@pravisankar pravisankar left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 16, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ironcladlou, pravisankar

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

@Miciah
Copy link
Contributor

Miciah commented Oct 16, 2018

I think ensureRouterForIngress should not get the ClusterIngress resource if it already exists because doing so means reconciliation will use the old resource's .spec instead of the new one's when creating the Service resource.

@ironcladlou
Copy link
Contributor Author

I think ensureRouterForIngress should not get the ClusterIngress resource if it already exists because doing so means reconciliation will use the old resource's .spec instead of the new one's when creating the Service resource.

What line is this in reference to?

@ironcladlou
Copy link
Contributor Author

/retest

@openshift-merge-robot openshift-merge-robot merged commit f89e652 into openshift:master Oct 16, 2018
@Miciah
Copy link
Contributor

Miciah commented Oct 16, 2018

I think ensureRouterForIngress should not get the ClusterIngress resource if it already exists because doing so means reconciliation will use the old resource's .spec instead of the new one's when creating the Service resource.

What line is this in reference to?

Line 199. I would have commented inline but it's outside of the diff context.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants