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

Commit

Permalink
Replace "controller" with "reconciler" in hnc/pkg/controllers directory
Browse files Browse the repository at this point in the history
Replace "controller" with "reconciler" in hnc/pkg/controllers directory. "Controllers" can refer to both reconcilers and admission controllers. Since thecontrollers we implemented under hnc/pkg/controllers are actually reconcilers, using "reconciler" instead of "controller" would be more precise.
  • Loading branch information
sophieliu15 committed Feb 24, 2020
1 parent 2b5c819 commit 4ea5c31
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 26 deletions.
12 changes: 7 additions & 5 deletions incubator/hnc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,18 @@ interesting directories are probably:

* `/api`: the API definition.
* `/cmd`: top-level executables. Currently the manager and the kubectl plugin.
* `/pkg/controllers`: the reconcilers and their tests
* `/pkg/reconcilers`: the reconcilers and their tests
* `/pkg/validators`: validating admission controllers
* `/pkg/forest`: the in-memory data structure, shared between the controllers
* `/pkg/forest`: the in-memory data structure, shared between the reconcilers
and validators.

Within the `controllers` directory, there are two controller:
Within the `reconcilers` directory, there are three reconcilers:

* **Hierarchy controller:** manages the hierarchy via the `Hierarchy` singleton
* **HNCConfiguration reconciler:** manages the HNCConfiguration via the
cluster-wide `config` singleton.
* **Hierarchy reconciler:** manages the hierarchy via the `Hierarchy` singleton
as well as the namespace in which it lives.
* **Object controller:** Propagates (copies and deletes) the relevant objects
* **Object reconciler:** Propagates (copies and deletes) the relevant objects
from parents to children. Instantiated once for every supported object GVK
(group/version/kind) - e.g., `Role`, `Secret`, etc.

Expand Down
4 changes: 2 additions & 2 deletions incubator/hnc/cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import (
// +kubebuilder:scaffold:imports

api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/controllers"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/forest"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/reconcilers"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/stats"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/validators"
)
Expand Down Expand Up @@ -131,7 +131,7 @@ func main() {
// Create all reconciling controllers
f := forest.NewForest()
setupLog.Info("Creating controllers", "maxReconciles", maxReconciles)
if err := controllers.Create(mgr, f, maxReconciles); err != nil {
if err := reconcilers.Create(mgr, f, maxReconciles); err != nil {
setupLog.Error(err, "cannot create controllers")
os.Exit(1)
}
Expand Down
1 change: 1 addition & 0 deletions incubator/hnc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kubernetes-sigs/multi-tenancy v0.0.0-20200221171633-2b5c81967af0 h1:JzZCwDzWZpZOMNgir26AiVSDuCWsJSGB2CX5pzT2/fM=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controllers
package reconcilers

import (
"context"
Expand Down Expand Up @@ -153,7 +153,7 @@ func (r *ConfigReconciler) createObjectReconciler(gvk schema.GroupVersionKind) e

or := &ObjectReconciler{
Client: r.Client,
Log: ctrl.Log.WithName("controllers").WithName(gvk.Kind),
Log: ctrl.Log.WithName("reconcilers").WithName(gvk.Kind),
Forest: r.Forest,
GVK: gvk,
Affected: make(chan event.GenericEvent),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controllers_test
package reconcilers_test

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package reconcilers

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controllers_test
package reconcilers_test

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package reconcilers

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controllers_test
package reconcilers_test

import (
"context"
Expand Down Expand Up @@ -91,7 +91,7 @@ var _ = Describe("Secret", func() {
time.Sleep(1 * time.Second)
modifyRole(ctx, barName, "foo-role")

// Set as parent. Give the controller a chance to copy the objects and make
// Set as parent. Give the reconciler a chance to copy the objects and make
// sure that at least the correct one was copied. This gives us more confidence
// that if the other one *isn't* copied, this is because we decided not to, and
// not that we just haven't gotten to it yet.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controllers
package reconcilers

import (
"fmt"
Expand All @@ -9,7 +9,7 @@ import (
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/forest"
)

// The ex map is used by controllers to exclude namespaces to reconcile. We explicitly
// The ex map is used by reconcilers to exclude namespaces to reconcile. We explicitly
// exclude some default namespaces with constantly changing objects.
// TODO make the exclusion configurable - https://github.com/kubernetes-sigs/multi-tenancy/issues/374
var ex = map[string]bool{
Expand All @@ -27,24 +27,24 @@ func Create(mgr ctrl.Manager, f *forest.Forest, maxReconciles int) error {
// Create the HierarchyReconciler.
hr := &HierarchyReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("Hierarchy"),
Log: ctrl.Log.WithName("reconcilers").WithName("Hierarchy"),
Forest: f,
Affected: hcChan,
}
if err := hr.SetupWithManager(mgr, maxReconciles); err != nil {
return fmt.Errorf("cannot create Hierarchy controller: %s", err.Error())
return fmt.Errorf("cannot create Hierarchy reconciler: %s", err.Error())
}

// Create the ConfigReconciler.
cr := &ConfigReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("HNCConfiguration"),
Log: ctrl.Log.WithName("reconcilers").WithName("HNCConfiguration"),
Manager: mgr,
Forest: f,
HierarchyConfigUpdates: hcChan,
}
if err := cr.SetupWithManager(mgr); err != nil {
return fmt.Errorf("cannot create Config controller: %s", err.Error())
return fmt.Errorf("cannot create Config reconciler: %s", err.Error())
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers_test
package reconcilers_test

import (
"context"
"path/filepath"
"testing"
"time"

"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/reconcilers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -36,7 +37,6 @@ import (

api "github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/api/v1alpha1"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/config"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/controllers"
"github.com/kubernetes-sigs/multi-tenancy/incubator/hnc/pkg/forest"
)

Expand All @@ -55,7 +55,7 @@ func TestAPIs(t *testing.T) {

SetDefaultEventuallyTimeout(time.Second * 2)
RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
"Reconciler Suite",
[]Reporter{envtest.NewlineReporter{}})
}

Expand Down Expand Up @@ -86,7 +86,7 @@ var _ = BeforeSuite(func(done Done) {
Scheme: scheme.Scheme,
})
Expect(err).ToNot(HaveOccurred())
err = controllers.Create(k8sManager, forest.NewForest(), 100)
err = reconcilers.Create(k8sManager, forest.NewForest(), 100)
Expect(err).ToNot(HaveOccurred())

k8sClient = k8sManager.GetClient()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controllers_test
package reconcilers_test

import (
"context"
Expand Down

0 comments on commit 4ea5c31

Please sign in to comment.