Skip to content

Add ClusterBus status and refactor Bus status#414

Merged
knative-prow-robot merged 7 commits into
knative:masterfrom
neosab:clusterbus_add_status
Sep 27, 2018
Merged

Add ClusterBus status and refactor Bus status#414
knative-prow-robot merged 7 commits into
knative:masterfrom
neosab:clusterbus_add_status

Conversation

@neosab
Copy link
Copy Markdown
Contributor

@neosab neosab commented Sep 4, 2018

Fixes #371 #370

Proposed Changes

  • Refactors Bus status update code
  • Adds status reporting for ClusterBus

TODO: Add tests.

This is an attempt at refactoring the bus status update code, I will add some tests to the PR if this is found reasonable.

Release Note

ClusterBus now reports Status

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 4, 2018
@evankanderson
Copy link
Copy Markdown
Member

evankanderson commented Sep 4, 2018 via email

@knative-prow-robot knative-prow-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 4, 2018
Copy link
Copy Markdown
Contributor

@scothis scothis left a comment

Choose a reason for hiding this comment

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

@neosab Thanks for picking this up.

I left comments inline. Let me know if you have any questions.

Comment thread pkg/controller/bus/controller.go Outdated
dispatcherDeployment, dispatcherDeplErr,
provisionerDeployment, provisionerDeplError)
return dispatcherServiceErr
err = c.syncDispatcherServiceBusStatus(bus)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While this portion of the syncHandler function is much cleaner, it has significant semantic changes which we don't want.

By moving the status update into the sync sync call for each sub resource, even in the most optimistic case, we'll have three calls to update the Bus resource. Worse, the second call to update will fail because the resource was mutated (by the first update). This means that not only are we making multiple update calls placing a higher burden on all api server and all other watchers of buses, but we're requiring at least three attempts to fully reconcile the bus.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I was trying to retain the existing control flow but misinterpreted it. Now, the Bus/ClusterBus Status is only updated once during the sync.

Comment thread pkg/controller/clusterbus/controller.go Outdated

// Sync Service derived from the ClusterBus
dispatcherService, err := c.syncClusterBusDispatcherService(clusterBus)
err = c.syncDispatcherServiceClusterBusStatus(clusterBus)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same general comment from the bus controller apply here as well.

Comment thread pkg/controller/bus/controller.go Outdated
dispatcherDeployment, dispatcherDeplErr,
provisionerDeployment, provisionerDeplError)
return dispatcherServiceErr
err = c.syncDispatcherServiceBusStatus(busCopy)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm generally not a fan of passing a struct to a function expecting the function to mutate that struct. Perhaps we should split out adding status to ClusterBus and refactoring the syncHandler function.

My general thought of how to cleanup the syncHandler function is to create a status factory where we can incrementally update the resources and then call update status on that.

Something like:

status := busStatusBuilder{}

// Sync Service derived from the Bus
status.dispatcherService, status.dispatcherServiceErr = c.syncBusDispatcherService(bus)
if err := status.error(); err != nil {
	_ = status.apply()
	return err
}

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My original intent was the cleanup of the updateBusStatus method signature but ended up splitting it into different handlers. I agree it's not nice to mutate the struct. I restored it to what I initially intended, please take a look.

If you still think we need to break up updating the Status, the Builder approach seems reasonable to me.

Comment thread pkg/controller/bus/controller.go Outdated
var dispatcherService *corev1.Service
var dispatcherDeployment, provisionerDeployment *appsv1.Deployment
var dispatcherServiceErr, dispatcherDeplErr, provisionerDeplError error
err = c.updateBusStatus(bus)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

updateBusStatus should only be concerned with updating the status field on the bus resource. With your change it is also syncing deployments and services.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My intention is to do both in the function, I can probably rename it to syncAndUpdateBusStatus or remove the function and add the code into syncHandler itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you have other recommendations?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the purpose of syncHandler is to sync the actual and desired state for the Bus, so it makes sense that it should delegate the syncing of controlled resources and then collect and update the status for the bus based on the results of the syncing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added them under syncHandler

@neosab
Copy link
Copy Markdown
Contributor Author

neosab commented Sep 7, 2018

/assign @evankanderson

Copy link
Copy Markdown
Contributor

@scothis scothis left a comment

Choose a reason for hiding this comment

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

/lgtm

I ran this locally with a couple different failure cases, seems to work well.

// ClusterBusStatus (computed) for a clusterbus
type ClusterBusStatus struct {
}
type ClusterBusStatus = BusStatus
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bus and ClusterBus may not always have the same status, but the they do at the moment and I don't foresee that changing in the short term.

Copy link
Copy Markdown
Contributor

@greghaynes greghaynes Sep 11, 2018

Choose a reason for hiding this comment

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

I see we have this pattern already with ClusterBusSpec but I think we'd want a new type rather than an alias here (e.g. type ClusterBusStatus BusStatus). I'm curious if there's a reason for the alias?

No need to block this PR on that, can fix it later on, but interested to know :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not using an alias is a good idea as it will be easier to fork the two types in the future should a distinction arise. Right now someone could do something silly like:

bus := Bus{
    Spec: ClusterBusSpec{},
}

I also agree it doesn't need to block this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was also done to re-use some of the bus_util functions that deals with Status for ClusterBus. I agree ClusterBusStatus can be its own type when it diverges from BusStatus.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 7, 2018
scothis added a commit to scothis/eventing that referenced this pull request Sep 11, 2018
From [ROLES.MD](https://github.com/knative/docs/blob/dfc53c67c8e80d30b8863353c9e9b4ad00c41fa0/community/ROLES.md#approver):

> Reviewer of the codebase for at least 3 months or 50% of project lifetime, whichever is shorter

- [First Issue](knative#80). Opened 6/11
- [First PR](knative#66). Opened 5/31
- [First Review](knative#79 (review)) 6/11

> Primary reviewer for at least 10 substantial PRs to the codebase

- knative#422 (review)
- knative#414 (review)
- knative#325 (review)
- knative#225 (review)
- knative#189 (review)
- knative#168 (review)
- knative#165 (review)
- knative#99 (review)
- knative#79 (review)
- knative#111 (review)

> Reviewed or merged at least 30 PRs to the codebase

- [Reviewed 23 PRs](https://github.com/knative/eventing/pulls?utf8=✓&q=is%3Apr+reviewed-by%3Ascothis)
- [Authored 34 merged PRs](https://github.com/knative/eventing/pulls?utf8=✓&q=is%3Apr+author%3Ascothis+is%3Amerged)
- [Authored 5 open PRs](https://github.com/knative/eventing/pulls/scothis)

> Nominated by an area lead

From [WORKING_GROUPS.MD](https://github.com/knative/docs/blob/dfc53c67c8e80d30b8863353c9e9b4ad00c41fa0/community/WORKING-GROUPS.md#events)

/assign @vaikas-google

> With no objections from other leads

🤞

/cc @evankanderson @grantr @inlined @mattmoor
knative-prow-robot pushed a commit that referenced this pull request Sep 12, 2018
From [ROLES.MD](https://github.com/knative/docs/blob/dfc53c67c8e80d30b8863353c9e9b4ad00c41fa0/community/ROLES.md#approver):

> Reviewer of the codebase for at least 3 months or 50% of project lifetime, whichever is shorter

- [First Issue](#80). Opened 6/11
- [First PR](#66). Opened 5/31
- [First Review](#79 (review)) 6/11

> Primary reviewer for at least 10 substantial PRs to the codebase

- #422 (review)
- #414 (review)
- #325 (review)
- #225 (review)
- #189 (review)
- #168 (review)
- #165 (review)
- #99 (review)
- #79 (review)
- #111 (review)

> Reviewed or merged at least 30 PRs to the codebase

- [Reviewed 23 PRs](https://github.com/knative/eventing/pulls?utf8=✓&q=is%3Apr+reviewed-by%3Ascothis)
- [Authored 34 merged PRs](https://github.com/knative/eventing/pulls?utf8=✓&q=is%3Apr+author%3Ascothis+is%3Amerged)
- [Authored 5 open PRs](https://github.com/knative/eventing/pulls/scothis)

> Nominated by an area lead

From [WORKING_GROUPS.MD](https://github.com/knative/docs/blob/dfc53c67c8e80d30b8863353c9e9b4ad00c41fa0/community/WORKING-GROUPS.md#events)

/assign @vaikas-google

> With no objections from other leads

🤞

/cc @evankanderson @grantr @inlined @mattmoor
@neosab
Copy link
Copy Markdown
Contributor Author

neosab commented Sep 12, 2018

@evankanderson Will this PR be accepted in the light of the new spec? If not, I can close it.

@grantr
Copy link
Copy Markdown
Contributor

grantr commented Sep 27, 2018

/approve

Sorry for the extreme delay @neosab. The community docs state that reviews are expected to be "timely", and we missed that mark here. We'll try to be better about this. Expanding the list of designated approvers should help.

Will this PR be accepted in the light of the new spec? If not, I can close it.

We want to keep the currently documented objects and controllers working while we're building the new ones, so this PR is definitely acceptable.

TODO: Add tests.

Are you still planning to work on tests?

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grantr, neosab

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 27, 2018
@neosab
Copy link
Copy Markdown
Contributor Author

neosab commented Sep 27, 2018

Sorry for the extreme delay @neosab

No issues!

Are you still planning to work on tests?

I will follow up with tests in a new PR

@neosab
Copy link
Copy Markdown
Contributor Author

neosab commented Sep 27, 2018

/test pull-knative-eventing-integration-tests

@knative-prow-robot knative-prow-robot merged commit 07b12ab into knative:master Sep 27, 2018
@neosab neosab deleted the clusterbus_add_status branch September 27, 2018 21:24
matzew pushed a commit to matzew/eventing that referenced this pull request Apr 11, 2019
From [ROLES.MD](https://github.com/knative/docs/blob/dfc53c67c8e80d30b8863353c9e9b4ad00c41fa0/community/ROLES.md#approver):

> Reviewer of the codebase for at least 3 months or 50% of project lifetime, whichever is shorter

- [First Issue](knative#80). Opened 6/11
- [First PR](knative#66). Opened 5/31
- [First Review](knative#79 (review)) 6/11

> Primary reviewer for at least 10 substantial PRs to the codebase

- knative#422 (review)
- knative#414 (review)
- knative#325 (review)
- knative#225 (review)
- knative#189 (review)
- knative#168 (review)
- knative#165 (review)
- knative#99 (review)
- knative#79 (review)
- knative#111 (review)

> Reviewed or merged at least 30 PRs to the codebase

- [Reviewed 23 PRs](https://github.com/knative/eventing/pulls?utf8=✓&q=is%3Apr+reviewed-by%3Ascothis)
- [Authored 34 merged PRs](https://github.com/knative/eventing/pulls?utf8=✓&q=is%3Apr+author%3Ascothis+is%3Amerged)
- [Authored 5 open PRs](https://github.com/knative/eventing/pulls/scothis)

> Nominated by an area lead

From [WORKING_GROUPS.MD](https://github.com/knative/docs/blob/dfc53c67c8e80d30b8863353c9e9b4ad00c41fa0/community/WORKING-GROUPS.md#events)

/assign @vaikas-google

> With no objections from other leads

🤞

/cc @evankanderson @grantr @inlined @mattmoor
matzew pushed a commit to matzew/eventing that referenced this pull request Nov 27, 2023
…ve#414)

The default 2-minute timeout might not be enough in some scenarios where
deploying takes longer (like with Istio).
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