-
Notifications
You must be signed in to change notification settings - Fork 140
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
support reset feature on web ui #114
support reset feature on web ui #114
Conversation
Hi @sivchari. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
/assign |
/retitle support reset feature on web ui |
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.
Thanks for your effort @sivchari. Looks good overall.
Left few comments.
if err := s.client.CoreV1().Pods(defaultNamespaceName).DeleteCollection(ctx, metav1.DeleteOptions{}, lopts); err != nil { | ||
noGrace := int64(0) | ||
if err := s.client.CoreV1().Pods(defaultNamespaceName).DeleteCollection(ctx, metav1.DeleteOptions{ | ||
GracePeriodSeconds: &noGrace, |
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.
Oops. Thanks for nice catch. Let's add the same doc as delete.
GracePeriodSeconds: &noGrace, | |
// need to use noGrace to avoid waiting kubelet checking. | |
// > When a force deletion is performed, the API server does not wait for confirmation from the kubelet that | |
// the Pod has been terminated on the node it was running on. | |
// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination-forced | |
GracePeriodSeconds: &noGrace, |
web/components/ResetButton.vue
Outdated
<template> | ||
<v-sheet class="transparent"> | ||
<v-btn color="primary ma-2" dark @click="reset()"> | ||
Reset Alll Resources</v-btn |
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.
Reset Alll Resources</v-btn | |
Reset All Resources</v-btn |
@@ -50,6 +50,11 @@ export default function snackbarStore() { | |||
this.setMessageType("error"); | |||
this.open(); | |||
}, | |||
setServerInfoMessage(message: string) { |
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.
👍
web/components/ResetButton.vue
Outdated
@@ -0,0 +1,94 @@ | |||
<template> | |||
<v-sheet class="transparent"> | |||
<v-btn color="primary ma-2" dark @click="reset()"> |
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.
Change it to the same color as Delete
button on ResourceBar.
<v-btn color="primary ma-2" dark @click="reset()"> | |
<v-btn color="error ma-2" dark @click="reset()"> |
@@ -92,6 +92,11 @@ func NewPluginConfig(pc []v1beta2.PluginConfig) ([]v1beta2.PluginConfig, error) | |||
for i := range pc { | |||
name := pc[i].Name | |||
ret := pluginConfig[name].DeepCopy() | |||
// If ret is nil, to reference ret.Object is occurred invalid memory address or nil pointer dereference. | |||
// To avoid this error, if ret is nil, we continue to next loop. | |||
if ret == nil { |
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.
Could you tell me how to get ret
to be nil? I'd like to investigate 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.
NewPluginConfig
for i := range pc {
name := pc[i].Name
klog.Info("plugin config: ", name)
ret := pluginConfig[name].DeepCopy()
// If ret is nil, to reference ret.Object is occurred invalid memory address or nil pointer dereference.
// To avoid this error, if ret is nil, we continue to next loop.
if ret == nil {
continue
}
// v1beta2.PluginConfig may have data in pc[i].Args.Raw as []byte.
// We have to encoding it in this case.
if len(pc[i].Args.Raw) != 0 {
// override default configuration
if err := json.Unmarshal(pc[i].Args.Raw, &ret.Object); err != nil {
return nil, err
}
}
if pc[i].Args.Object != nil {
// If data exists in both PluginConfig.Args.Raw and PluginConfig.Args.Object,
// PluginConfig.Args.Raw would be ignored
ret.Object = pc[i].Args.Object
}
pluginConfig[name] = ret
}
Resource
One node and two pods on it, own unscheduled pod.
To reset all resources and reset scheduler configuration, I click reset button.
This behavior outputs as the following.
output
default plugin config: map[DefaultPreemption:&RawExtension{Raw:nil,} InterPodAffinity:&RawExtension{Raw:nil,} NodeAffinity:&RawExtension{Raw:nil,} NodeResourcesBalancedAllocation:&RawExtension{Raw:nil,} NodeResourcesFit:&RawExtension{Raw:nil,} PodTopologySpread:&RawExtension{Raw:nil,} VolumeBinding:&RawExtension{Raw:nil,}]
/// snip
219 15:41:52.102498 1 plugins.go:95] plugin config: DefaultPreemption
I0219 15:41:52.102583 1 plugins.go:95] plugin config: InterPodAffinity
I0219 15:41:52.102646 1 plugins.go:95] plugin config: NodeAffinity
I0219 15:41:52.102663 1 plugins.go:95] plugin config: NodeResourcesBalancedAllocation
I0219 15:41:52.102725 1 plugins.go:95] plugin config: NodeResourcesFit
I0219 15:41:52.102752 1 plugins.go:95] plugin config: PodTopologySpread
I0219 15:41:52.102770 1 plugins.go:95] plugin config: VolumeBinding
/// snip
default plugin config: map[DefaultPreemption:&RawExtension{Raw:nil,} InterPodAffinity:&RawExtension{Raw:nil,} NodeAffinity:&RawExtension{Raw:nil,} NodeResourcesBalancedAllocation:&RawExtension{Raw:nil,} NodeResourcesFit:&RawExtension{Raw:nil,} PodTopologySpread:&RawExtension{Raw:nil,} VolumeBinding:&RawExtension{Raw:nil,}]
/// snip
I0219 15:42:31.684998 1 plugins.go:95] plugin config: DefaultPreemption
I0219 15:42:31.685039 1 plugins.go:95] plugin config: InterPodAffinity
I0219 15:42:31.685060 1 plugins.go:95] plugin config: NodeAffinity
I0219 15:42:31.685084 1 plugins.go:95] plugin config: NodeResourcesBalancedAllocation
I0219 15:42:31.685114 1 plugins.go:95] plugin config: NodeResourcesFit
I0219 15:42:31.685523 1 plugins.go:95] plugin config: PodTopologySpread
I0219 15:42:31.685557 1 plugins.go:95] plugin config: VolumeBinding
I0219 15:42:31.685607 1 plugins.go:95] plugin config: NodeResourcesBalancedAllocationForSimulator
I0219 15:42:31.685650 1 plugins.go:95] plugin config: InterPodAffinityForSimulator
I0219 15:42:31.685675 1 plugins.go:95] plugin config: NodeResourcesFitForSimulator
I0219 15:42:31.685698 1 plugins.go:95] plugin config: NodeAffinityForSimulator
I0219 15:42:31.685731 1 plugins.go:95] plugin config: PodTopologySpreadForSimulator
I0219 15:42:31.685756 1 plugins.go:95] plugin config: VolumeBindingForSimulator
If XXXForSimulator plugin calls DeepCopy(), return value is nil. So, ret.Object = pc.[i].Args.Object
is occurred invalid memory address or nil pointer dereference.
If this change isn't existed, NewPluginConfig calls panic
goroutine 4069 [running]:
net/http.(*conn).serve.func1(0xc00690fb80)
/usr/local/go/src/net/http/server.go:1804 +0x153
panic(0x2807aa0, 0x43762a0)
/usr/local/go/src/runtime/panic.go:971 +0x499
github.com/kubernetes-sigs/kube-scheduler-simulator/scheduler/plugin.NewPluginConfig(0xc005095880, 0xd, 0x10, 0x0, 0xd, 0x101, 0xc00b7c7c20, 0xc0039c7320)
/go/src/simulator-server/scheduler/plugin/plugins.go:113 +0x2d8
github.com/kubernetes-sigs/kube-scheduler-simulator/scheduler.convertConfigurationForSimulator(0xc0004ce360, 0xc0048c37a0, 0xc006423b80, 0x3063ae8)
/go/src/simulator-server/scheduler/scheduler.go:151 +0x16e
github.com/kubernetes-sigs/kube-scheduler-simulator/scheduler.(*Service).StartScheduler(0xc00643d6e0, 0xc0004ce360, 0x4c11ac, 0x3031910)
/go/src/simulator-server/scheduler/scheduler.go:73 +0x270
github.com/kubernetes-sigs/kube-scheduler-simulator/scheduler.(*Service).RestartScheduler(0xc00643d6e0, 0xc0004ce360, 0x2496bff, 0xc00b745e38)
/go/src/simulator-server/scheduler/scheduler.go:43 +0x6c
github.com/kubernetes-sigs/kube-scheduler-simulator/scheduler.(*Service).ResetScheduler(0xc00643d6e0, 0x0, 0x0)
/go/src/simulator-server/scheduler/scheduler.go:55 +0x34
github.com/kubernetes-sigs/kube-scheduler-simulator/reset.(*Service).Reset(0xc00643d740, 0x3031910, 0xc00647b000, 0x10, 0x10)
/go/src/simulator-server/reset/reset.go:58 +0x28e
github.com/kubernetes-sigs/kube-scheduler-simulator/server/handler.(*ResetHandler).Reset(0xc0052a1c00, 0x306e158, 0xc006562140, 0x1829846755732203, 0xc000111400)
/go/src/simulator-server/server/handler/reset.go:24 +0x8c
github.com/labstack/echo/v4.(*Echo).add.func1(0x306e158, 0xc006562140, 0x2bcc949, 0x20)
/go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/echo.go:544 +0x62
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(0x306e158, 0xc006562140, 0x43a88a0, 0x203002)
/go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/middleware/cors.go:186 +0x1016
github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1(0x306e158, 0xc006562140, 0x0, 0x0)
/go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/middleware/logger.go:117 +0x12c
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0074ebb00, 0x302da28, 0xc00c17d960, 0xc0066c9900)
/go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/echo.go:654 +0x2bc
net/http.serverHandler.ServeHTTP(0xc00c49f420, 0x302da28, 0xc00c17d960, 0xc0066c9900)
/usr/local/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc00690fb80, 0x30319b8, 0xc00647af40)
/usr/local/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2993 +0x39b
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.
Okay. I think there is another issue.
Could you change NewSchedulerService
like this? This initialSchedulerCfg
field should not be change, but is changing actually because it's pointer and passed without deepcopy. It's definitely a bug.
(It is not needed to revert your change on NewPluginConfig
.)
// NewSchedulerService starts scheduler and return *Service.
func NewSchedulerService(client clientset.Interface, restclientCfg *restclient.Config, initialSchedulerCfg *v1beta2config.KubeSchedulerConfiguration) *Service {
iniCfg := initialSchedulerCfg.DeepCopy()
return &Service{clientset: client, restclientCfg: restclientCfg, initialSchedulerCfg: iniCfg}
}
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 fixed it.
web/pages/index.vue
Outdated
<ResourceBar /> | ||
<SchedulerConfigurationEditButton /> | ||
<ResourceAddButton /> | ||
<ResetButton /> |
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.
For the position of reset button, I prefer to place it next to import/export button.
So, let's wait for #81 and place it on the topbar. I think #81 is about to merge.
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.
OK!, I wait 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.
I fixed codes of your suggestion. A position of reset button haven't changed, yet. |
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.
Thanks for addressing my reviews.
Added two comments 🙏
web/components/ResetButton.vue
Outdated
@@ -0,0 +1,92 @@ | |||
<template> | |||
<v-sheet class="transparent"> | |||
<v-btn color="error ma-2" dark @click="reset()"> Reset All Resources</v-btn> |
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.
This will reset scheduler config as well (not only resources)
<v-btn color="error ma-2" dark @click="reset()"> Reset All Resources</v-btn> | |
<v-btn color="error ma-2" dark @click="reset()"> Reset </v-btn> |
web/components/ResetButton.vue
Outdated
</v-sheet> | ||
</template> | ||
|
||
<script lang="ts"> |
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.
Could you change this component to behave like delete button on ResourceBar? You can refer to the implementation of that.
I think the dialog is needed:
- not to reset mistakenly.
- to tell users that this reset will also reset the scheduler settings.
https://github.com/kubernetes-sigs/kube-scheduler-simulator/blob/master/web/components/ResourceBar/DeleteButton.vue
#81 is merged, so I’ll fix thix PR |
0d38cfd
to
503d4a6
Compare
@sanposhiho |
|
||
<v-card> | ||
<v-card-title class="2"> | ||
Are you sure to reset all resources and scheduler configuration ? |
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.
Are you sure to reset all resources and scheduler configuration ? | |
Are you sure to reset all resources and scheduler configuration? |
<template> | ||
<v-dialog v-model="data.dialog" width="500"> | ||
<template #activator="{ on }"> | ||
<v-btn class="ma-5 mb-0" color="error" v-on="on"> Reset </v-btn> |
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.
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.
@sivchari Thanks for nice work!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sanposhiho, sivchari 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 |
* fix nil pointer reference * update delete collection method to force delete * fix conflict * delete debug print * fix lint * fix * update factory method * add provider * fix reset button * fix format
* fix nil pointer reference * update delete collection method to force delete * fix conflict * delete debug print * fix lint * fix * update factory method * add provider * fix reset button * fix format
…in (#121) * Able to configure API server and port, thus expose it is possible via compose * linters * update property name to be more descriptive * change the parameter arg to be more descriptive * WIP - use create server chain to start k8s api server. * WIP - remove unecessary shutdown fn * setup annoymoususer for insecure testing * update go mod sum * instead of building kube-api , only do openapi-gen * add vendor files into repo and keep existing openapi gen * forgot to add openapi * remove not needed generated api * refactor due to linters * change makefile to what it was for github action * refactor due to cyclomatic complexity * use original dockerfile step * unnecessary if * remove openapi step before test * disable admission plugins to for node taints and service account checks * Added docs to describe our kube-apiserver creation process and env var * add permission doc * Import from existing cluster (#111) * feat:add ignoreRestart Option to Import on ExportService * add:impl ReplicateExistingClusterService * add:ExternalKubeClientCfg to config * add:impl interface of ReplicateExistingClusterService * feat:impl replicate existing cluster's resources logic if ExternalImportEnabled is enabled * test:add Import with ignoreRestart test * refactor:add interface of ExportService * add:create mock of ExportService(run go generate) * Update config/config.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update export/export.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update export/export.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update replicateexistingcluster/replicateexistingcluster.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update replicateexistingcluster/replicateexistingcluster.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update server/di/di.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update server/di/di.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update replicateexistingcluster/replicateexistingcluster.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update replicateexistingcluster/replicateexistingcluster.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update replicateexistingcluster/replicateexistingcluster.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * refactor:rename IgnoreRestart option to IgnoreSchedulerConfiguration * refactor:rename _exportService to exportService * refactor:rename to replicateExistingClusterService * refactor:change convert logic of resources * refactor:move private functions to utils.go of export package * test:export utils test * test:add test for replicateexistingcluster * fix:return value of ConvertToResourcesForImportFromResourcesForExport * fix:get a context in arg of ImportFromExistingCluster * fix:remove comment * fix:rename to ConvertResourcesForImportToResourcesForExport * fix:do import before API server starting Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * support reset feature on web ui (#114) * fix nil pointer reference * update delete collection method to force delete * fix conflict * delete debug print * fix lint * fix * update factory method * add provider * fix reset button * fix format * Rename simulatorPlugin to wrappedPlugin (#126) * refactor:rename simulatorPlugin to wrappedPlugin * fix:prefix word * test:fix * refactor:receiver name * Implement table view on Web UI (#119) * refactor:move resource view components to under the ResourceViews/List/ directory * refactor:create ResourcesViewPanel component and replace it on index.vue * add: ResourcesViewPanel & RadioButton to select view * add:DataTable template * fix:typo * add:basic data tables for each resources * fix:import PodList on UnscheduledPodList * fix:change display columns * fix:declare of Array type * fix:remove debug comment * fix:change show columns * fix:change columns name * typo:lang * style:adjust search text field of tables * feat:add ALPHA_TABLE_VIEWS env * fix:show datatable if ALPHA_TABLE_VIEWS env val is "1" * fix:column name * refactor:separated into new component * refactor:change label to title * style:make it clear that each row on table is clickable * Display the kind/apiVersion in the scheduler configuration yaml (#129) * Display the kind/apiVersion in the scheduler configuration yaml * Add kind/apiVersion to the yaml as you might expect * For "APPLY" keep the profiles only so that ignored edits (e.g. apiVersion) are not displayed next time. * The editor still allows unsupported/ignored edits, but at least it is clear what was set when you revisit. Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> * Ensure only profiles get updated in ApplySchedulerConfig * Also don't yarn lint/format coverage directory * WIP - remove unecessary shutdown fn * fix rebase issue * merge master * Request kube apiserver directly from frontend (#115) * Request kube apiserver directly from frontend * Show axios errors on page * Add axios error judge * Change default kubeAPIserver port * Add simple cause err message, Fix typo * Delete comments * Fix err message * change kube apiserver request header * tmp * Delete pods when delete node * delete managed field before apply * Update web/components/ResourceBar/ResourceBar.vue Co-authored-by: Kensei Nakada <handbomusic@gmail.com> Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Add deprecate description (#127) * Add deprecate comment lines * change some docs description * fix indent and move not-deprecate APIs * fix linter err * setup annoymoususer for insecure testing * Request kube apiserver directly from frontend (#115) * Request kube apiserver directly from frontend * Show axios errors on page * Add axios error judge * Change default kubeAPIserver port * Add simple cause err message, Fix typo * Delete comments * Fix err message * change kube apiserver request header * tmp * Delete pods when delete node * delete managed field before apply * Update web/components/ResourceBar/ResourceBar.vue Co-authored-by: Kensei Nakada <handbomusic@gmail.com> Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Able to configure API server and port, thus expose it is possible via compose * refactor due to linters * remove unecessary error channel * log the error return from prepared aggregator server * add temp cert directory * remote unnecessary changes. * update md to reflect default api behavior * remove unnecessary flag * Enable Priority Plugin for admission Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Change the order of logging to ensure url is correct. Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * pass cleanupFunc all the way to shutdown * attemp to fix useragent issue * Revert "attemp to fix useragent issue" This reverts commit b06408a. Co-authored-by: 196Ikuchil <22634362+196Ikuchil@users.noreply.github.com> Co-authored-by: Kensei Nakada <handbomusic@gmail.com> Co-authored-by: sivchari <shibuuuu5@gmail.com> Co-authored-by: Mark Sturdevant <mark.sturdevant@ibm.com> Co-authored-by: momom-i <51011095+momom-i@users.noreply.github.com>
What type of PR is this?
/kind feature
What this PR does / why we need it:
I add reset button to delete all resources and to reset scheduler configuration.
I update to server logic to do correct execution.
Which issue(s) this PR fixes:
Fixes #26
Special notes for your reviewer:
/label tide/merge-method-squash