-
Notifications
You must be signed in to change notification settings - Fork 220
Handle ingress domain updates to default cluster ingress #48
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,16 +69,56 @@ func (h *Handler) EnsureDefaultClusterIngress() error { | |
| return err | ||
| } | ||
|
|
||
| err = sdk.Create(ci) | ||
| if err == nil || errors.IsAlreadyExists(err) { | ||
| if err == nil { | ||
| logrus.Infof("created default cluster ingress %s/%s", ci.Namespace, ci.Name) | ||
| changed, nci, err := checkClusterIngress(ci) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if changed { | ||
| err = sdk.Update(nci) | ||
| if err != nil { | ||
| return fmt.Errorf("updating default cluster ingress %s/%s: %v", ci.Namespace, ci.Name, err) | ||
| } | ||
| logrus.Infof("updated default cluster ingress %s/%s", ci.Namespace, ci.Name) | ||
| } else if nci == nil { | ||
| err = sdk.Create(ci) | ||
| if err != nil { | ||
| return fmt.Errorf("creating default cluster ingress %s/%s: %v", ci.Namespace, ci.Name, err) | ||
| } | ||
| logrus.Infof("created default cluster ingress %s/%s", ci.Namespace, ci.Name) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| return nil | ||
| func checkClusterIngress(ci *ingressv1alpha1.ClusterIngress) (bool, *ingressv1alpha1.ClusterIngress, error) { | ||
| oldci := &ingressv1alpha1.ClusterIngress{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| Kind: ci.Kind, | ||
| APIVersion: ci.APIVersion, | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: ci.Name, | ||
| Namespace: ci.Namespace, | ||
| }, | ||
| } | ||
| err := sdk.Get(oldci) | ||
| if err != nil { | ||
| if !errors.IsNotFound(err) { | ||
| return false, nil, fmt.Errorf("failed to fetch existing default cluster ingress %s/%s, %v", ci.Namespace, ci.Name, err) | ||
| } | ||
| return false, nil, nil | ||
| } | ||
|
|
||
| return fmt.Errorf("creating default cluster ingress %s/%s: %v", ci.Namespace, ci.Name, err) | ||
| if ci.Spec.IngressDomain == nil { | ||
| return false, nil, fmt.Errorf("invalid ingress domain for default cluster ingress %s/%s", ci.Namespace, ci.Name) | ||
| } | ||
| if oldci.Spec.IngressDomain == nil { | ||
| oldci.Spec.IngressDomain = new(string) | ||
| } | ||
| if *oldci.Spec.IngressDomain != *ci.Spec.IngressDomain { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If either of this is
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tried this https://play.golang.org/p/i0W49iA8Gjh and I didn't see an issue.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me fix this |
||
| *oldci.Spec.IngressDomain = *ci.Spec.IngressDomain | ||
| return true, oldci, nil | ||
| } | ||
| return false, oldci, nil | ||
| } | ||
|
|
||
| // Reconcile performs a full reconciliation loop for ingress, including | ||
|
|
||
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.
I think this can use: clusterIngressStatusEqual
from PR: #38
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.
Maybe not
clusterIngressStatusEqual, but the part that compares.loadBalancer.Ingresscould be factored into a function that could be used both bycheckClusterIngressand byclusterIngressStatusEqual. Now that #47 is merged, I'll rebase #38 Tuesday and factor out aLoadBalancerStatusEqualfunction. No need for that to block this PR though; I can changecheckClusterIngressto useLoadBalancerStatusEqualif #48 merges before #38 is ready.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.
Err, actually,
checkClusterIngressis comparing only.spec.ingressDomain(a string) whereasclusterIngressStatusEqualis comparing.status.loadBalancer(a slice of a struct that has two string values), so there is really no opportunity for code re-use here as far as I see.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.
I might be confused but if the LoadBalancerIngress struct are different as being checked in your PR [1] it means there's an update it should be enough for this purpouse.
[1] https://github.com/openshift/cluster-ingress-operator/pull/38/files#diff-9ae69f8dcadd8df44e0b10265f3a91a8R107
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're talking about
cluster-ingress-operator/pkg/stub/handler.go
Lines 111 to 117 in 3f8735c
*stringvalues in order to determine whether the old ClusterIngress and new ClusterIngress specify the same ingress domain.clusterIngressStatusEqualcompares[]LoadBalancerIngressvalues, whereLoadBalancerIngressisstruct { IP, Hostname string }, in order to determine whether the old ClusterIngressStatus and new ClusterIngressStatus have the same ingresses.