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 25, 2020
1 parent 546727c commit ab57534
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 27 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.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/go-logr/logr v0.1.0
github.com/go-openapi/spec v0.19.3 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/gophercloud/gophercloud v0.4.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/json-iterator/go v1.1.6 // indirect
Expand Down
2 changes: 1 addition & 1 deletion incubator/hnc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,4 @@ sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5
sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs=
sigs.k8s.io/testing_frameworks v0.1.1/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
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
@@ -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 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 ab57534

Please sign in to comment.