preemption_test.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package preemption
  14. import (
  15. "fmt"
  16. "testing"
  17. "k8s.io/api/core/v1"
  18. "k8s.io/apimachinery/pkg/api/resource"
  19. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  20. "k8s.io/client-go/tools/record"
  21. kubeapi "k8s.io/kubernetes/pkg/apis/core"
  22. "k8s.io/kubernetes/pkg/apis/scheduling"
  23. )
  24. const (
  25. clusterCritical = "cluster-critical"
  26. nodeCritical = "node-critical"
  27. bestEffort = "bestEffort"
  28. burstable = "burstable"
  29. highRequestBurstable = "high-request-burstable"
  30. guaranteed = "guaranteed"
  31. highRequestGuaranteed = "high-request-guaranteed"
  32. tinyBurstable = "tiny"
  33. maxPods = 110
  34. )
  35. type fakePodKiller struct {
  36. killedPods []*v1.Pod
  37. errDuringPodKilling bool
  38. }
  39. func newFakePodKiller(errPodKilling bool) *fakePodKiller {
  40. return &fakePodKiller{killedPods: []*v1.Pod{}, errDuringPodKilling: errPodKilling}
  41. }
  42. func (f *fakePodKiller) clear() {
  43. f.killedPods = []*v1.Pod{}
  44. }
  45. func (f *fakePodKiller) getKilledPods() []*v1.Pod {
  46. return f.killedPods
  47. }
  48. func (f *fakePodKiller) killPodNow(pod *v1.Pod, status v1.PodStatus, gracePeriodOverride *int64) error {
  49. if f.errDuringPodKilling {
  50. f.killedPods = []*v1.Pod{}
  51. return fmt.Errorf("problem killing pod %v", pod)
  52. }
  53. f.killedPods = append(f.killedPods, pod)
  54. return nil
  55. }
  56. type fakePodProvider struct {
  57. pods []*v1.Pod
  58. }
  59. func newFakePodProvider() *fakePodProvider {
  60. return &fakePodProvider{pods: []*v1.Pod{}}
  61. }
  62. func (f *fakePodProvider) setPods(pods []*v1.Pod) {
  63. f.pods = pods
  64. }
  65. func (f *fakePodProvider) getPods() []*v1.Pod {
  66. return f.pods
  67. }
  68. func getTestCriticalPodAdmissionHandler(podProvider *fakePodProvider, podKiller *fakePodKiller) *CriticalPodAdmissionHandler {
  69. return &CriticalPodAdmissionHandler{
  70. getPodsFunc: podProvider.getPods,
  71. killPodFunc: podKiller.killPodNow,
  72. recorder: &record.FakeRecorder{},
  73. }
  74. }
  75. func TestEvictPodsToFreeRequestsWithError(t *testing.T) {
  76. type testRun struct {
  77. testName string
  78. inputPods []*v1.Pod
  79. insufficientResources admissionRequirementList
  80. expectErr bool
  81. expectedOutput []*v1.Pod
  82. }
  83. podProvider := newFakePodProvider()
  84. podKiller := newFakePodKiller(true)
  85. criticalPodAdmissionHandler := getTestCriticalPodAdmissionHandler(podProvider, podKiller)
  86. allPods := getTestPods()
  87. runs := []testRun{
  88. {
  89. testName: "multiple pods eviction error",
  90. inputPods: []*v1.Pod{
  91. allPods[clusterCritical], allPods[bestEffort], allPods[burstable], allPods[highRequestBurstable],
  92. allPods[guaranteed], allPods[highRequestGuaranteed]},
  93. insufficientResources: getAdmissionRequirementList(0, 550, 0),
  94. expectErr: false,
  95. expectedOutput: nil,
  96. },
  97. }
  98. for _, r := range runs {
  99. podProvider.setPods(r.inputPods)
  100. outErr := criticalPodAdmissionHandler.evictPodsToFreeRequests(allPods[clusterCritical], r.insufficientResources)
  101. outputPods := podKiller.getKilledPods()
  102. if !r.expectErr && outErr != nil {
  103. t.Errorf("evictPodsToFreeRequests returned an unexpected error during the %s test. Err: %v", r.testName, outErr)
  104. } else if r.expectErr && outErr == nil {
  105. t.Errorf("evictPodsToFreeRequests expected an error but returned a successful output=%v during the %s test.", outputPods, r.testName)
  106. } else if !podListEqual(r.expectedOutput, outputPods) {
  107. t.Errorf("evictPodsToFreeRequests expected %v but got %v during the %s test.", r.expectedOutput, outputPods, r.testName)
  108. }
  109. podKiller.clear()
  110. }
  111. }
  112. func TestEvictPodsToFreeRequests(t *testing.T) {
  113. type testRun struct {
  114. testName string
  115. inputPods []*v1.Pod
  116. insufficientResources admissionRequirementList
  117. expectErr bool
  118. expectedOutput []*v1.Pod
  119. }
  120. podProvider := newFakePodProvider()
  121. podKiller := newFakePodKiller(false)
  122. criticalPodAdmissionHandler := getTestCriticalPodAdmissionHandler(podProvider, podKiller)
  123. allPods := getTestPods()
  124. runs := []testRun{
  125. {
  126. testName: "critical pods cannot be preempted",
  127. inputPods: []*v1.Pod{allPods[clusterCritical]},
  128. insufficientResources: getAdmissionRequirementList(0, 0, 1),
  129. expectErr: true,
  130. expectedOutput: nil,
  131. },
  132. {
  133. testName: "best effort pods are not preempted when attempting to free resources",
  134. inputPods: []*v1.Pod{allPods[bestEffort]},
  135. insufficientResources: getAdmissionRequirementList(0, 1, 0),
  136. expectErr: true,
  137. expectedOutput: nil,
  138. },
  139. {
  140. testName: "multiple pods evicted",
  141. inputPods: []*v1.Pod{
  142. allPods[clusterCritical], allPods[bestEffort], allPods[burstable], allPods[highRequestBurstable],
  143. allPods[guaranteed], allPods[highRequestGuaranteed]},
  144. insufficientResources: getAdmissionRequirementList(0, 550, 0),
  145. expectErr: false,
  146. expectedOutput: []*v1.Pod{allPods[highRequestBurstable], allPods[highRequestGuaranteed]},
  147. },
  148. }
  149. for _, r := range runs {
  150. podProvider.setPods(r.inputPods)
  151. outErr := criticalPodAdmissionHandler.evictPodsToFreeRequests(allPods[clusterCritical], r.insufficientResources)
  152. outputPods := podKiller.getKilledPods()
  153. if !r.expectErr && outErr != nil {
  154. t.Errorf("evictPodsToFreeRequests returned an unexpected error during the %s test. Err: %v", r.testName, outErr)
  155. } else if r.expectErr && outErr == nil {
  156. t.Errorf("evictPodsToFreeRequests expected an error but returned a successful output=%v during the %s test.", outputPods, r.testName)
  157. } else if !podListEqual(r.expectedOutput, outputPods) {
  158. t.Errorf("evictPodsToFreeRequests expected %v but got %v during the %s test.", r.expectedOutput, outputPods, r.testName)
  159. }
  160. podKiller.clear()
  161. }
  162. }
  163. func BenchmarkGetPodsToPreempt(t *testing.B) {
  164. allPods := getTestPods()
  165. inputPods := []*v1.Pod{}
  166. for i := 0; i < maxPods; i++ {
  167. inputPods = append(inputPods, allPods[tinyBurstable])
  168. }
  169. for n := 0; n < t.N; n++ {
  170. getPodsToPreempt(allPods[bestEffort], inputPods, admissionRequirementList([]*admissionRequirement{
  171. {
  172. resourceName: v1.ResourceCPU,
  173. quantity: parseCPUToInt64("110m"),
  174. }}))
  175. }
  176. }
  177. func TestGetPodsToPreempt(t *testing.T) {
  178. type testRun struct {
  179. testName string
  180. preemptor *v1.Pod
  181. inputPods []*v1.Pod
  182. insufficientResources admissionRequirementList
  183. expectErr bool
  184. expectedOutput []*v1.Pod
  185. }
  186. allPods := getTestPods()
  187. runs := []testRun{
  188. {
  189. testName: "no requirements",
  190. preemptor: allPods[clusterCritical],
  191. inputPods: []*v1.Pod{},
  192. insufficientResources: getAdmissionRequirementList(0, 0, 0),
  193. expectErr: false,
  194. expectedOutput: []*v1.Pod{},
  195. },
  196. {
  197. testName: "no pods",
  198. preemptor: allPods[clusterCritical],
  199. inputPods: []*v1.Pod{},
  200. insufficientResources: getAdmissionRequirementList(0, 0, 1),
  201. expectErr: true,
  202. expectedOutput: nil,
  203. },
  204. {
  205. testName: "equal pods and resources requirements",
  206. preemptor: allPods[clusterCritical],
  207. inputPods: []*v1.Pod{allPods[burstable]},
  208. insufficientResources: getAdmissionRequirementList(100, 100, 1),
  209. expectErr: false,
  210. expectedOutput: []*v1.Pod{allPods[burstable]},
  211. },
  212. {
  213. testName: "higher requirements than pod requests",
  214. preemptor: allPods[clusterCritical],
  215. inputPods: []*v1.Pod{allPods[burstable]},
  216. insufficientResources: getAdmissionRequirementList(200, 200, 2),
  217. expectErr: true,
  218. expectedOutput: nil,
  219. },
  220. {
  221. testName: "choose between bestEffort and burstable",
  222. preemptor: allPods[clusterCritical],
  223. inputPods: []*v1.Pod{allPods[burstable], allPods[bestEffort]},
  224. insufficientResources: getAdmissionRequirementList(0, 0, 1),
  225. expectErr: false,
  226. expectedOutput: []*v1.Pod{allPods[bestEffort]},
  227. },
  228. {
  229. testName: "choose between burstable and guaranteed",
  230. preemptor: allPods[clusterCritical],
  231. inputPods: []*v1.Pod{allPods[burstable], allPods[guaranteed]},
  232. insufficientResources: getAdmissionRequirementList(0, 0, 1),
  233. expectErr: false,
  234. expectedOutput: []*v1.Pod{allPods[burstable]},
  235. },
  236. {
  237. testName: "choose lower request burstable if it meets requirements",
  238. preemptor: allPods[clusterCritical],
  239. inputPods: []*v1.Pod{allPods[bestEffort], allPods[highRequestBurstable], allPods[burstable]},
  240. insufficientResources: getAdmissionRequirementList(100, 100, 0),
  241. expectErr: false,
  242. expectedOutput: []*v1.Pod{allPods[burstable]},
  243. },
  244. {
  245. testName: "choose higher request burstable if lower does not meet requirements",
  246. preemptor: allPods[clusterCritical],
  247. inputPods: []*v1.Pod{allPods[bestEffort], allPods[burstable], allPods[highRequestBurstable]},
  248. insufficientResources: getAdmissionRequirementList(150, 150, 0),
  249. expectErr: false,
  250. expectedOutput: []*v1.Pod{allPods[highRequestBurstable]},
  251. },
  252. {
  253. testName: "multiple pods required",
  254. preemptor: allPods[clusterCritical],
  255. inputPods: []*v1.Pod{allPods[bestEffort], allPods[burstable], allPods[highRequestBurstable], allPods[guaranteed], allPods[highRequestGuaranteed]},
  256. insufficientResources: getAdmissionRequirementList(350, 350, 0),
  257. expectErr: false,
  258. expectedOutput: []*v1.Pod{allPods[burstable], allPods[highRequestBurstable]},
  259. },
  260. {
  261. testName: "evict guaranteed when we have to, and dont evict the extra burstable",
  262. preemptor: allPods[clusterCritical],
  263. inputPods: []*v1.Pod{allPods[bestEffort], allPods[burstable], allPods[highRequestBurstable], allPods[guaranteed], allPods[highRequestGuaranteed]},
  264. insufficientResources: getAdmissionRequirementList(0, 550, 0),
  265. expectErr: false,
  266. expectedOutput: []*v1.Pod{allPods[highRequestBurstable], allPods[highRequestGuaranteed]},
  267. },
  268. {
  269. testName: "evict cluster critical pod for node critical pod",
  270. preemptor: allPods[nodeCritical],
  271. inputPods: []*v1.Pod{allPods[clusterCritical]},
  272. insufficientResources: getAdmissionRequirementList(100, 0, 0),
  273. expectErr: false,
  274. expectedOutput: []*v1.Pod{allPods[clusterCritical]},
  275. },
  276. {
  277. testName: "can not evict node critical pod for cluster critical pod",
  278. preemptor: allPods[clusterCritical],
  279. inputPods: []*v1.Pod{allPods[nodeCritical]},
  280. insufficientResources: getAdmissionRequirementList(100, 0, 0),
  281. expectErr: true,
  282. expectedOutput: nil,
  283. },
  284. }
  285. for _, r := range runs {
  286. outputPods, outErr := getPodsToPreempt(r.preemptor, r.inputPods, r.insufficientResources)
  287. if !r.expectErr && outErr != nil {
  288. t.Errorf("getPodsToPreempt returned an unexpected error during the %s test. Err: %v", r.testName, outErr)
  289. } else if r.expectErr && outErr == nil {
  290. t.Errorf("getPodsToPreempt expected an error but returned a successful output=%v during the %s test.", outputPods, r.testName)
  291. } else if !podListEqual(r.expectedOutput, outputPods) {
  292. t.Errorf("getPodsToPreempt expected %v but got %v during the %s test.", r.expectedOutput, outputPods, r.testName)
  293. }
  294. }
  295. }
  296. func TestAdmissionRequirementsDistance(t *testing.T) {
  297. type testRun struct {
  298. testName string
  299. requirements admissionRequirementList
  300. inputPod *v1.Pod
  301. expectedOutput float64
  302. }
  303. allPods := getTestPods()
  304. runs := []testRun{
  305. {
  306. testName: "no requirements",
  307. requirements: getAdmissionRequirementList(0, 0, 0),
  308. inputPod: allPods[burstable],
  309. expectedOutput: 0,
  310. },
  311. {
  312. testName: "no requests, some requirements",
  313. requirements: getAdmissionRequirementList(100, 100, 1),
  314. inputPod: allPods[bestEffort],
  315. expectedOutput: 2,
  316. },
  317. {
  318. testName: "equal requests and requirements",
  319. requirements: getAdmissionRequirementList(100, 100, 1),
  320. inputPod: allPods[burstable],
  321. expectedOutput: 0,
  322. },
  323. {
  324. testName: "higher requests than requirements",
  325. requirements: getAdmissionRequirementList(50, 50, 0),
  326. inputPod: allPods[burstable],
  327. expectedOutput: 0,
  328. },
  329. }
  330. for _, run := range runs {
  331. output := run.requirements.distance(run.inputPod)
  332. if output != run.expectedOutput {
  333. t.Errorf("expected: %f, got: %f for %s test", run.expectedOutput, output, run.testName)
  334. }
  335. }
  336. }
  337. func TestAdmissionRequirementsSubtract(t *testing.T) {
  338. type testRun struct {
  339. testName string
  340. initial admissionRequirementList
  341. inputPod *v1.Pod
  342. expectedOutput admissionRequirementList
  343. }
  344. allPods := getTestPods()
  345. runs := []testRun{
  346. {
  347. testName: "subtract a pod from no requirements",
  348. initial: getAdmissionRequirementList(0, 0, 0),
  349. inputPod: allPods[burstable],
  350. expectedOutput: getAdmissionRequirementList(0, 0, 0),
  351. },
  352. {
  353. testName: "subtract no requests from some requirements",
  354. initial: getAdmissionRequirementList(100, 100, 1),
  355. inputPod: allPods[bestEffort],
  356. expectedOutput: getAdmissionRequirementList(100, 100, 0),
  357. },
  358. {
  359. testName: "equal requests and requirements",
  360. initial: getAdmissionRequirementList(100, 100, 1),
  361. inputPod: allPods[burstable],
  362. expectedOutput: getAdmissionRequirementList(0, 0, 0),
  363. },
  364. {
  365. testName: "subtract higher requests than requirements",
  366. initial: getAdmissionRequirementList(50, 50, 0),
  367. inputPod: allPods[burstable],
  368. expectedOutput: getAdmissionRequirementList(0, 0, 0),
  369. },
  370. {
  371. testName: "subtract lower requests than requirements",
  372. initial: getAdmissionRequirementList(200, 200, 1),
  373. inputPod: allPods[burstable],
  374. expectedOutput: getAdmissionRequirementList(100, 100, 0),
  375. },
  376. }
  377. for _, run := range runs {
  378. output := run.initial.subtract(run.inputPod)
  379. if !admissionRequirementListEqual(output, run.expectedOutput) {
  380. t.Errorf("expected: %s, got: %s for %s test", run.expectedOutput.toString(), output.toString(), run.testName)
  381. }
  382. }
  383. }
  384. func getTestPods() map[string]*v1.Pod {
  385. allPods := map[string]*v1.Pod{
  386. tinyBurstable: getPodWithResources(tinyBurstable, v1.ResourceRequirements{
  387. Requests: v1.ResourceList{
  388. v1.ResourceCPU: resource.MustParse("1m"),
  389. v1.ResourceMemory: resource.MustParse("1Mi"),
  390. },
  391. }),
  392. bestEffort: getPodWithResources(bestEffort, v1.ResourceRequirements{}),
  393. clusterCritical: getPodWithResources(clusterCritical, v1.ResourceRequirements{
  394. Requests: v1.ResourceList{
  395. v1.ResourceCPU: resource.MustParse("100m"),
  396. v1.ResourceMemory: resource.MustParse("100Mi"),
  397. },
  398. }),
  399. nodeCritical: getPodWithResources(nodeCritical, v1.ResourceRequirements{
  400. Requests: v1.ResourceList{
  401. v1.ResourceCPU: resource.MustParse("100m"),
  402. v1.ResourceMemory: resource.MustParse("100Mi"),
  403. },
  404. }),
  405. burstable: getPodWithResources(burstable, v1.ResourceRequirements{
  406. Requests: v1.ResourceList{
  407. v1.ResourceCPU: resource.MustParse("100m"),
  408. v1.ResourceMemory: resource.MustParse("100Mi"),
  409. },
  410. }),
  411. guaranteed: getPodWithResources(guaranteed, v1.ResourceRequirements{
  412. Requests: v1.ResourceList{
  413. v1.ResourceCPU: resource.MustParse("100m"),
  414. v1.ResourceMemory: resource.MustParse("100Mi"),
  415. },
  416. Limits: v1.ResourceList{
  417. v1.ResourceCPU: resource.MustParse("100m"),
  418. v1.ResourceMemory: resource.MustParse("100Mi"),
  419. },
  420. }),
  421. highRequestBurstable: getPodWithResources(highRequestBurstable, v1.ResourceRequirements{
  422. Requests: v1.ResourceList{
  423. v1.ResourceCPU: resource.MustParse("300m"),
  424. v1.ResourceMemory: resource.MustParse("300Mi"),
  425. },
  426. }),
  427. highRequestGuaranteed: getPodWithResources(highRequestGuaranteed, v1.ResourceRequirements{
  428. Requests: v1.ResourceList{
  429. v1.ResourceCPU: resource.MustParse("300m"),
  430. v1.ResourceMemory: resource.MustParse("300Mi"),
  431. },
  432. Limits: v1.ResourceList{
  433. v1.ResourceCPU: resource.MustParse("300m"),
  434. v1.ResourceMemory: resource.MustParse("300Mi"),
  435. },
  436. }),
  437. }
  438. allPods[clusterCritical].Namespace = kubeapi.NamespaceSystem
  439. allPods[clusterCritical].Spec.PriorityClassName = scheduling.SystemClusterCritical
  440. clusterPriority := scheduling.SystemCriticalPriority
  441. allPods[clusterCritical].Spec.Priority = &clusterPriority
  442. allPods[nodeCritical].Namespace = kubeapi.NamespaceSystem
  443. allPods[nodeCritical].Spec.PriorityClassName = scheduling.SystemNodeCritical
  444. nodePriority := scheduling.SystemCriticalPriority + 100
  445. allPods[nodeCritical].Spec.Priority = &nodePriority
  446. return allPods
  447. }
  448. func getPodWithResources(name string, requests v1.ResourceRequirements) *v1.Pod {
  449. return &v1.Pod{
  450. ObjectMeta: metav1.ObjectMeta{
  451. GenerateName: name,
  452. Annotations: map[string]string{},
  453. },
  454. Spec: v1.PodSpec{
  455. Containers: []v1.Container{
  456. {
  457. Name: fmt.Sprintf("%s-container", name),
  458. Resources: requests,
  459. },
  460. },
  461. },
  462. }
  463. }
  464. func parseCPUToInt64(res string) int64 {
  465. r := resource.MustParse(res)
  466. return (&r).MilliValue()
  467. }
  468. func parseNonCpuResourceToInt64(res string) int64 {
  469. r := resource.MustParse(res)
  470. return (&r).Value()
  471. }
  472. func getAdmissionRequirementList(cpu, memory, pods int) admissionRequirementList {
  473. reqs := []*admissionRequirement{}
  474. if cpu > 0 {
  475. reqs = append(reqs, &admissionRequirement{
  476. resourceName: v1.ResourceCPU,
  477. quantity: parseCPUToInt64(fmt.Sprintf("%dm", cpu)),
  478. })
  479. }
  480. if memory > 0 {
  481. reqs = append(reqs, &admissionRequirement{
  482. resourceName: v1.ResourceMemory,
  483. quantity: parseNonCpuResourceToInt64(fmt.Sprintf("%dMi", memory)),
  484. })
  485. }
  486. if pods > 0 {
  487. reqs = append(reqs, &admissionRequirement{
  488. resourceName: v1.ResourcePods,
  489. quantity: int64(pods),
  490. })
  491. }
  492. return admissionRequirementList(reqs)
  493. }
  494. // this checks if the lists contents contain all of the same elements.
  495. // this is not correct if there are duplicate pods in the list.
  496. // for example: podListEqual([a, a, b], [a, b, b]) will return true
  497. func admissionRequirementListEqual(list1 admissionRequirementList, list2 admissionRequirementList) bool {
  498. if len(list1) != len(list2) {
  499. return false
  500. }
  501. for _, a := range list1 {
  502. contains := false
  503. for _, b := range list2 {
  504. if a.resourceName == b.resourceName && a.quantity == b.quantity {
  505. contains = true
  506. }
  507. }
  508. if !contains {
  509. return false
  510. }
  511. }
  512. return true
  513. }
  514. // podListEqual checks if the lists contents contain all of the same elements.
  515. func podListEqual(list1 []*v1.Pod, list2 []*v1.Pod) bool {
  516. if len(list1) != len(list2) {
  517. return false
  518. }
  519. m := map[*v1.Pod]int{}
  520. for _, val := range list1 {
  521. m[val] = m[val] + 1
  522. }
  523. for _, val := range list2 {
  524. m[val] = m[val] - 1
  525. }
  526. for _, v := range m {
  527. if v != 0 {
  528. return false
  529. }
  530. }
  531. return true
  532. }