Skip to content

Commit

Permalink
Merge pull request #1269 from machi1990/refactor/move-cluster-mgr-to-…
Browse files Browse the repository at this point in the history
…cluster-mgrs-package

refactor(cluster_mgrs): move the cluster manager onto the cluster_mgrs package
  • Loading branch information
machi1990 committed Aug 31, 2022
2 parents 46e0aba + a71e495 commit c5b4b40
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Why

1. To improve the architecture of kas-fleet-manager so that when there are changes to OCM, it should only have very small impact on the code base. At the moment, more components are directly depending on OCM than it should be, e.g. [`clusters_mgr.go`](../../internal/kafka/internal/workers/clusters_mgr.go), and this makes it difficult to change the code base if OCM changes.
1. To improve the architecture of kas-fleet-manager so that when there are changes to OCM, it should only have very small impact on the code base. At the moment, more components are directly depending on OCM than it should be, e.g. [`clusters_mgr.go`](../../internal/kafka/internal/workers/cluster_mgrs/clusters_mgr.go), and this makes it difficult to change the code base if OCM changes.
2. To allow us easily open source the project. With the right interface/contract in place for cluster management, OCM will just become an implementation detail of the interface. New implementations can then be added by us or the upstream community to support different mechanisms to manage OpenShift/Kubernetes clusters.

## How
Expand All @@ -17,4 +17,4 @@ Compared to the current implementation, the main changes are:
2. Each cluster could have different `Provider` implementation, this information needs to be stored. The `api.Cluster` type is updated to include additional fields to store this information.
3. A new `ProviderFactory` interface is added which will return the concrete `Provider` implementation based on the `Providertype` value in each `api.Cluster` instance.
4. Modify the [`ClusterService`](../../internal/kafka/internal/services/clusters.go) class to depend on the new `ProviderFactory`, and remove all dependencies on the OCM client.
5. Modify the [`ClusterManager`](../../internal/kafka/internal/workers/clusters_mgr.go) class to only depend on the `ClusterService`. It should not have any direct dependencies on the OCM clients.
5. Modify the [`ClusterManager`](../../internal/kafka/internal/workers/cluster_mgrs/clusters_mgr.go) class to only depend on the `ClusterService`. It should not have any direct dependencies on the OCM clients.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package workers
package cluster_mgrs

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package workers
package cluster_mgrs

import (
"fmt"
Expand Down
3 changes: 1 addition & 2 deletions internal/kafka/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/routes"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/services"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/services/quota"
kafka_internal_workers "github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/workers"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/workers/cluster_mgrs"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/workers/kafka_mgrs"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/pkg/workers"
Expand Down Expand Up @@ -72,7 +71,7 @@ func ServiceProviders() di.Option {
di.Provide(clusters.NewDefaultProviderFactory, di.As(new(clusters.ProviderFactory))),
di.Provide(routes.NewRouteLoader),
di.Provide(quota.NewDefaultQuotaServiceFactory),
di.Provide(kafka_internal_workers.NewClusterManager, di.As(new(workers.Worker))),
di.Provide(cluster_mgrs.NewClusterManager, di.As(new(workers.Worker))),
di.Provide(cluster_mgrs.NewDynamicScaleUpManager, di.As(new(workers.Worker))),
di.Provide(cluster_mgrs.NewCleanupClustersManager, di.As(new(workers.Worker))),
di.Provide(cluster_mgrs.NewDeprovisioningClustersManager, di.As(new(workers.Worker))),
Expand Down
4 changes: 2 additions & 2 deletions internal/kafka/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/api/public"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/config"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/services"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/workers"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/internal/kafka/internal/workers/cluster_mgrs"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/pkg/client/keycloak"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/pkg/client/observatorium"
"github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager/pkg/client/ocm"
Expand Down Expand Up @@ -46,7 +46,7 @@ type Services struct {
OCMConfig *ocm.OCMConfig
KafkaService services.KafkaService
ObservatoriumClient *observatorium.Client
ClusterManager *workers.ClusterManager
ClusterManager *cluster_mgrs.ClusterManager
ServerConfig *server.ServerConfig
}

Expand Down

0 comments on commit c5b4b40

Please sign in to comment.