-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor ExportService and ReplicateExistingClusterService #300
Refactor ExportService and ReplicateExistingClusterService #300
Conversation
// ImportClusterResources gets resources from the target cluster via exportService | ||
// and then apply those resources to the simulator. | ||
// Note: this method doesn't handle scheduler configuration. | ||
// If you want to use their scheduler configuration, you need to set config of `KUBE_SCHEDULER_CONFIG_PATH`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the configuration via env vers is deprecated; so describe this with the scheduler config file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you probably forgot it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanposhiho
Sorry..🙏
How about this?
afd265f
simulator/server/di/di.go
Outdated
} | ||
|
||
// NewDIContainer initializes Container. | ||
// It initializes all service and puts to Container. | ||
// If externalImportEnabled is false, the simulator will not use externalClient and will not create ReplicateExistingClusterService. | ||
// If externalImportEnabled is false, the simulator will not use externalClient and will not create ImportClusterResourceService. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be easier to read.
// If externalImportEnabled is false, the simulator will not use externalClient and will not create ImportClusterResourceService. | |
// Only when externalImportEnabled is true, the simulator uses externalClient and creates ImportClusterResourceService. |
Export(ctx context.Context, opts ...export.Option) (*export.ResourcesForExport, error) | ||
Import(ctx context.Context, resources *export.ResourcesForImport, opts ...export.Option) error | ||
IgnoreErr() export.Option | ||
type SnapshotService interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe it's related to export/import feature.
simulator/server/server.go
Outdated
v1.GET("/export", exportHandler.Save) | ||
v1.POST("/import", exportHandler.Load) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer Snap
instead of Save
.
Save
can be mistakenly interpreted as "take a snapshot file and save it to somewhere, or save all resources into kube-apiserver".
simulator/server/server.go
Outdated
@@ -33,7 +33,7 @@ func NewSimulatorServer(cfg *config.Config, dic *di.Container) *SimulatorServer | |||
|
|||
// initialize each handler | |||
schedulercfgHandler := handler.NewSchedulerConfigHandler(dic.SchedulerService()) | |||
exportHandler := handler.NewExportHandler(dic.ExportService()) | |||
exportHandler := handler.NewSnapshotHandler(dic.ExportService()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename: exportHandler -> snapshotHandler
simulator/snapshot/snapshot.go
Outdated
@@ -52,8 +52,8 @@ type ResourcesForExport struct { | |||
Namespaces []corev1.Namespace `json:"namespaces"` | |||
} | |||
|
|||
// ResourcesForImport denotes all resources and scheduler configuration for import. | |||
type ResourcesForImport struct { | |||
// ResourcesForLoad denotes indicates all resources and scheduler configuration to be loaded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ResourcesForLoad denotes indicates all resources and scheduler configuration to be loaded. | |
// ResourcesForLoad indicates all resources and scheduler configuration to be loaded. |
@sanposhiho |
simulator/snapshot/snapshot.go
Outdated
schedulerService SchedulerService | ||
} | ||
|
||
// ResourcesForExport denotes all resources and scheduler configuration for export. | ||
type ResourcesForExport struct { | ||
// ResourcesForSnap indicates all resources and scheduler configuration to be saved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
// ResourcesForSnap indicates all resources and scheduler configuration to be saved. | |
// ResourcesForSnap indicates all resources and scheduler configuration to be snapped. |
simulator/snapshot/snapshot.go
Outdated
return xerrors.Errorf("restart scheduler with Loaded configuration: %w", err) | ||
} | ||
klog.Info("The scheduler configuration hasn't been imported because of an external scheduler is enabled.") | ||
klog.Info("The scheduler configuration hasn't been Loaded because of an external scheduler is enabled.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits: Loaded -> loaded
@sanposhiho |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 196Ikuchil, sanposhiho 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:
Approvers can indicate their approval by writing |
What type of PR is this?
/area simulator
/kind cleanup
What this PR does / why we need it:
The name of ExportService and ReplicateExisitngClusterService didn't represent the function well.
Renamed these.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Mainly, renamed as
/label tide/merge-method-squash