-
Notifications
You must be signed in to change notification settings - Fork 220
Publish ClusterIngress status #38
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
Conversation
d1dd7ad to
55e50d0
Compare
55e50d0 to
b782675
Compare
|
Rebased. |
pkg/apis/ingress/v1alpha1/status.go
Outdated
| ci.SetStatusCondition(condition) | ||
| } | ||
|
|
||
| // clusterIngressStatusEqual returns true iff the status conditions (ignoring |
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.
typo "iff"
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.
It's short for "if and only if". I see it used a lot in included packages, but I can expand it.
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.
Fixed.
pkg/apis/ingress/v1alpha1/status.go
Outdated
| } | ||
|
|
||
| err := sdk.Update(ci) | ||
| for tries := 3; tries > 0; tries-- { |
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 the loop needed?
the err variable is updated outside the loop or am i missing something?
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.
Whoops! err := sdk.Update(ci) needs to be inside the loop. Thanks!
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 deleted the loop. Now UpdateStatus returns an error value, and callers return any error from UpdateStatus to the handler so that the event gets reprocessed.
693970d to
f7c0d9f
Compare
|
Latest push deletes the retry logic in |
30ce1e0 to
5c07898
Compare
|
/lgtm |
|
I plan to review this Friday, I need the branch to be as stable as possible through Thursday. Thanks! |
pravisankar
left a comment
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.
Added some comments, rest of the changes lgtm.
pkg/apis/ingress/v1alpha1/status.go
Outdated
| if numConditions != len(oldCi.Status.Conditions) { | ||
| return false | ||
| } | ||
| for i := 0; i < numConditions; i++ { |
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.
Depending on various circumstances, we could end up with:
Old ci conditions in order: { A, B, C }
New ci conditions in order: { B, C, A }
I think we should return true even if they are in out of order.
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.
Fixed. Thanks!
pkg/apis/ingress/v1alpha1/status.go
Outdated
| if numIngresses != len(oldCi.Status.LoadBalancer.Ingress) { | ||
| return false | ||
| } | ||
| for i := 0; i < numIngresses; i++ { |
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 as above, check should be agnostic to ingress order.
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.
Fixed. Thanks!
pkg/apis/ingress/v1alpha1/status.go
Outdated
| operatorName, err := k8sutil.GetOperatorName() | ||
| if err != nil { | ||
| logrus.Fatalf("Failed to get operator name: %v", 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.
k8sutil.GetWatchNamespace(), k8sutil.GetOperatorName() can be initially cached in Handler struct and reused in every status update (Nice to do but i'm fine with this for now)
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 added the fields to Handler. Since this means CreateOrUpdateOperatorStatus needs the Handler, and since it didn't really need the ClusterIngress, I changed its receiver to h *Handler, moved it to handler.go, and changed it to createOrUpdateOperatorStatus.
pkg/stub/handler.go
Outdated
|
|
||
| return nil | ||
| case *corev1.Service: | ||
| isDeleted := o.GetDeletionTimestamp() != 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.
Will there be a case where event.Deleted = true and o.GetDeletionTimestamp() == nil?
or is it better to check isDeleted := (event.Deleted || (o.GetDeletionTimestamp() != 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.
My understanding is that event.Deleted will go away that and o.GetDeletionTimestamp() will be the source of truth.
pkg/apis/ingress/v1alpha1/status.go
Outdated
| } | ||
|
|
||
| numIngresses := len(ci.Status.LoadBalancer.Ingress) | ||
| if numIngresses != len(oldCi.Status.LoadBalancer.Ingress) { |
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.
Perform load balancer checks only when ci.Spec.HighAvailability.Type == ingressv1alpha1.CloudClusterIngressHA ?
When ci.Spec.HighAvailability.Type != CloudClusterIngressHA , need to clear old Status.LoadBalancer field.
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.
As you point out in another comment, the logic in syncServiceUpdate needs to be fixed for ci.Spec.HighAvailability.Type != CloudClusterIngressHA, but once that is fixed, I think the equality check should still always compare .Status.LoadBalancer.Ingress. If we ever support changing from CloudClusterIngressHA to some other value, we want the equality check to return false so that we update with the status with the empty list of ingresses. Am I missing anything?
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.
Yes, you are right. Once we fix syncServiceUpdate, the equality check need to be performed to ensure there is no change in cluster ingress type.
pkg/stub/handler.go
Outdated
| return nil | ||
| } | ||
|
|
||
| if len(service.Status.LoadBalancer.Ingress) == 0 { |
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.
Check valid only in case of ci.Spec.HighAvailability.Type == ingressv1alpha1.CloudClusterIngressHA
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.
Good point. Thanks!
| } | ||
|
|
||
| ci.SetStatusAvailableCondition(true, "") | ||
| ci.Status.LoadBalancer.Ingress = service.Status.LoadBalancer.Ingress |
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.
Set this field only when ci.Spec.HighAvailability.Type == ingressv1alpha1.CloudClusterIngressHA ?
|
Latest push makes the following changes per Ravi's comments: • Move |
5c07898 to
30f4f50
Compare
pkg/apis/ingress/v1alpha1/status.go
Outdated
| // objects are equal. | ||
| func clusterIngressStatusEqual(oldCi, ci *ClusterIngress) bool { | ||
| numConditions := len(ci.Status.Conditions) | ||
| if numConditions != len(oldCi.Status.Conditions) { |
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.
nit: numConditions var is no longer needed after this check, we could do len(ci.Status.Conditions) != len(oldCi.Status.Conditions)
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.
Fixed.
pkg/apis/ingress/v1alpha1/status.go
Outdated
| } | ||
| } | ||
|
|
||
| numIngresses := len(ci.Status.LoadBalancer.Ingress) |
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.
nit: Same as above
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.
Fixed.
pkg/apis/ingress/v1alpha1/status.go
Outdated
| } | ||
|
|
||
| numIngresses := len(ci.Status.LoadBalancer.Ingress) | ||
| if numIngresses != len(oldCi.Status.LoadBalancer.Ingress) { |
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.
Yes, you are right. Once we fix syncServiceUpdate, the equality check need to be performed to ensure there is no change in cluster ingress type.
pkg/stub/handler.go
Outdated
|
|
||
| ciName := service.Name[7:] | ||
|
|
||
| ciNamespace, err := k8sutil.GetWatchNamespace() |
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.
Use h.operatorNamespace instead?
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.
Fixed. Thanks!
30f4f50 to
f5a0c27
Compare
|
Latest push makes the following changes per Ravi's comments: • Delete I made the following additional changes: • Added some unit tests in After some further consideration, I think we should discuss during the next planning call how the operator should handle the "Available" condition when |
pravisankar
left a comment
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.
/lgtm
f5a0c27 to
0c4d519
Compare
pravisankar
left a comment
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.
/lgtm
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: imcsk8, Miciah, pravisankar If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
* Gopkg.lock: * Gopkg.toml: * vendor/github.com/openshift/cluster-version-operator: Import package in order to have the necessary API types for updating OperatorStatus.
Create (if necessary) and update an OperatorStatus object to indicate the operator's status. * manifests/00-cluster-role.yaml: Allow the operator to create, get, and update operatorstatuses. * pkg/stub/handler.go: Add new fields to Handler: operatorNamespace and operatorName, and initialize them in NewHandler. Add new functions: syncOperatorStatus and syncOperatorStatusDegraded. Use syncOperatorStatus in Handle to update OperatorStatus. Use syncOperatorStatusDegraded in syncIngressUpdate for errors that require intervention (such as RBAC problems).
Update the status conditions of ClusterIngress objects to indicate synchronization status and availability. Watch Services in cluster-ingress-operator's namespace in order to reflect their status and any associated load-balancer ingresses to the corresponding ClusterIngress objects. * cmd/cluster-ingress-operator/main.go: Watch services and endpoints in the operator's namespace. * manifests/00-cluster-role.yaml: Allow operator to get services and endpoints. * pkg/apis/ingress/v1alpha1/status.go: Add new functions for setting status on ClusterIngress objects: setStatusCondition, SetStatusSyncCondition, SetStatusAvailableCondition, clusterIngressStatusEqual, UpdateStatus. * pkg/apis/ingress/v1alpha1/types.go: Add fields to ClusterIngressStatus for operator and load balancer status. * pkg/apis/ingress/v1alpha1/status_test.go: Add tests. * pkg/stub/handler.go: Use SetStatusSyncCondition, SetStatusAvailableCondition, and UpdateStatus in syncIngressUpdate. Add new functions: getClusterIngress, syncServiceUpdate, syncEndpointsUpdate, and syncServiceOrEndpointsUpdate. Use these new functions in Handle to handle Service and Endpoints events and to update the corresponding ClusterIngress status according to the Service and Endpoints status.
0c4d519 to
00c747f
Compare
|
New changes are detected. LGTM label has been removed. |
|
Latest push removes the OperatorStatus code; this PR now depends on #47 to import github.com/openshift/cluster-version-operator, which has some required types. This push also adds a watch on endpoints and event handling for the same in order to resolve a race condition that would leave the "Available" condition as false with the message "service has no endpoints" when a service's ingresses are ready before its endpoints. |
|
Looks ok, just rebase and squash. |
|
This is probably hopelessly out of date; going to close it and revisit later. /close |
|
@ironcladlou: Closing this PR. DetailsIn 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. |
Update the status conditions of ClusterIngress objects to indicate synchronization status and availability.
Watch Services in cluster-ingress-operator's namespace in order to reflect their status and any associated load-balancer ingresses to the corresponding ClusterIngress objects.
cmd/cluster-ingress-operator/main.go: Watch services and endpoints in the operator's namespace.manifests/00-cluster-role.yaml: Allow operator to get services and endpoints.pkg/apis/ingress/v1alpha1/status.go: Add new functions for setting status on ClusterIngress objects:setStatusCondition,SetStatusSyncCondition,SetStatusAvailableCondition,clusterIngressStatusEqual,UpdateStatus.pkg/apis/ingress/v1alpha1/types.go: Add fields toClusterIngressStatusfor operator and load balancer status.pkg/apis/ingress/v1alpha1/status_test.go: Add tests.pkg/stub/handler.go: UseSetStatusSyncCondition,SetStatusAvailableCondition, andUpdateStatusinsyncIngressUpdate.Add new functions:
getClusterIngress,syncServiceUpdate,syncEndpointsUpdate, andsyncServiceOrEndpointsUpdate.Use these new functions in
Handleto handle Service and Endpoints events and to update the corresponding ClusterIngress status according to the Service and Endpoints status.This PR depends on #47.