Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Compute NumPropagatedObjects in HNCConfiguration status #542

Merged

Conversation

sophieliu15
Copy link
Contributor

This PR computes NumPropagatedObjects as a part of HNCConfiguration status. NumPropagatedObjects indicates the number of propagated objects of a specific type created by HNC.

Tested:unit tests, GKE cluster

Issue: #411

@k8s-ci-robot k8s-ci-robot requested review from rjbez17 and srampal March 24, 2020 13:50
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 24, 2020
@sophieliu15
Copy link
Contributor Author

/assign @adrianludwin
/assign @yiqigao217

@sophieliu15 sophieliu15 force-pushed the num_propagated_1 branch 4 times, most recently from 8bc9af3 to ec26995 Compare March 24, 2020 16:57
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 24, 2020
Note: This PR is implemented on top of kubernetes-retired#542, please review that first. I will rebase and remove the hold once kubernetes-retired#542 is merged. Thank you!

This PR computes NumSourceObjects as a part of HNCConfiguration status. NumSourceObjects indicates the number of objects of a specific type created by users.

Tested:unit tests, GKE cluster

Issue: kubernetes-retired#411

initial commit
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Nice! Circling back to review the tests now but I wanted to send you what I already had.

incubator/hnc/pkg/forest/forest.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/forest/forest.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config.go Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config.go Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Eh, now I see the downside to putting the Sleep at the beginning of the Reconciler - it means that the regular business logic (e.g. adding/removing types) is also delayed by 3s. I'm not sure we want that. Sorry I missed that.

How about we write some logic to intercept the calls from the object reconcilers and make sure we only trigger one reconciliation every N seconds? That way, most of the reconciler will still work ASAP. You'll have to write the deduping logic yourself but that should be pretty simple. Talk to Yiqi about how to trigger a periodic event using a long-running goroutine. It'll look something like this in the Setup function:

go func() {
  for { // have some kind of way to break the loop when the controller exits
    time.Sleep(3 * time.Second) // use constant instead
    if r.objCountChanged {
      r.objCountChanged = false
      r.enqueueReconcile()
    }
  }
}()

incubator/hnc/pkg/reconcilers/object_test.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config_test.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config_test.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config_test.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config_test.go Outdated Show resolved Hide resolved
@sophieliu15
Copy link
Contributor Author

Eh, now I see the downside to putting the Sleep at the beginning of the Reconciler - it means that the regular business logic (e.g. adding/removing types) is also delayed by 3s. I'm not sure we want that. Sorry I missed that.

How about we write some logic to intercept the calls from the object reconcilers and make sure we only trigger one reconciliation every N seconds? That way, most of the reconciler will still work ASAP. You'll have to write the deduping logic yourself but that should be pretty simple. Talk to Yiqi about how to trigger a periodic event using a long-running goroutine. It'll look something like this in the Setup function:

go func() {
  for { // have some kind of way to break the loop when the controller exits
    time.Sleep(3 * time.Second) // use constant instead
    if r.objCountChanged {
      r.objCountChanged = false
      r.enqueueReconcile()
    }
  }
}()

Thanks for the suggestion! I will resolve the comments about tests later after I change to this method. Hopefully it won't take that long after.

@sophieliu15 sophieliu15 force-pushed the num_propagated_1 branch 5 times, most recently from 46bea33 to f13a919 Compare March 26, 2020 17:41
@sophieliu15
Copy link
Contributor Author

Hi @adrianludwin

Thanks so much for the review. I updated the code and replied to all your comments. Feel free to take a look!

Thank you!

Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Sorry for the terse comments, just trying to get this back to you ASAP. Almost ready to go, just a few last comments

incubator/hnc/api/v1alpha1/hnc_config.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/forest/forest.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config_test.go Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/object.go Outdated Show resolved Hide resolved
This PR computes NumPropagatedObjects as a part of HNCConfiguration
status. NumPropagatedObjects indicates the number of propagated objects
of a specific type created by HNC.

Tested: unit tests, GKE cluster

Issue: kubernetes-retired#411
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/assign @rjbez17
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 26, 2020
@k8s-ci-robot k8s-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 26, 2020
@rjbez17
Copy link

rjbez17 commented Mar 26, 2020

/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 26, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, rjbez17, sophieliu15

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [adrianludwin,rjbez17]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 6a1a45c into kubernetes-retired:master Mar 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

5 participants