Skip to content
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

Merged

Conversation

196Ikuchil
Copy link
Contributor

@196Ikuchil 196Ikuchil commented Apr 29, 2023

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

  • ExportService → ShapshotService
    • Export → Snap
    • Import → Load
  • ReplicateExistingClusterService → ClusterResourceImportService

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added area/simulator Issues or PRs related to the simulator. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. labels Apr 29, 2023
@k8s-ci-robot k8s-ci-robot added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Apr 29, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 29, 2023
// 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`.
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

you probably forgot it.

Copy link
Contributor Author

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

}

// 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.
Copy link
Member

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.

Suggested change
// 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 {
Copy link
Member

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.

Comment on lines 49 to 50
v1.GET("/export", exportHandler.Save)
v1.POST("/import", exportHandler.Load)
Copy link
Member

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".

@@ -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())
Copy link
Member

Choose a reason for hiding this comment

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

rename: exportHandler -> snapshotHandler

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// ResourcesForLoad denotes indicates all resources and scheduler configuration to be loaded.
// ResourcesForLoad indicates all resources and scheduler configuration to be loaded.

@196Ikuchil
Copy link
Contributor Author

@sanposhiho
Thanks 👍 Fixed.

schedulerService SchedulerService
}

// ResourcesForExport denotes all resources and scheduler configuration for export.
type ResourcesForExport struct {
// ResourcesForSnap indicates all resources and scheduler configuration to be saved.
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
// ResourcesForSnap indicates all resources and scheduler configuration to be saved.
// ResourcesForSnap indicates all resources and scheduler configuration to be snapped.

Comment on lines 255 to 257
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.")
Copy link
Member

Choose a reason for hiding this comment

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

nits: Loaded -> loaded

@196Ikuchil
Copy link
Contributor Author

@sanposhiho
Thanks🙏

@sanposhiho
Copy link
Member

You missed this
https://github.com/kubernetes-sigs/kube-scheduler-simulator/pull/300/files#r1181016673

Copy link
Member

@sanposhiho sanposhiho 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

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 1, 2023
@k8s-ci-robot
Copy link
Contributor

[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:
  • OWNERS [196Ikuchil,sanposhiho]

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/simulator Issues or PRs related to the simulator. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants