-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1765 lines (746 loc) · 78.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="theme-next muse use-motion" lang="">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=6.4.2" rel="stylesheet" type="text/css" />
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.2">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.4.2">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.2">
<link rel="mask-icon" href="/images/logo.svg?v=6.4.2" color="#222">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Muse',
version: '6.4.2',
sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
fancybox: false,
fastclick: false,
lazyload: false,
tabs: true,
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<meta property="og:type" content="website">
<meta property="og:title" content="Kindule">
<meta property="og:url" content="http://kindule.github.io/index.html">
<meta property="og:site_name" content="Kindule">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Kindule">
<link rel="canonical" href="http://kindule.github.io/"/>
<script type="text/javascript" id="page.configurations">
CONFIG.page = {
sidebar: "",
};
</script>
<title>Kindule</title>
<noscript>
<style type="text/css">
.use-motion .motion-element,
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-title { opacity: initial; }
.use-motion .logo,
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion {
.logo-line-before i { left: initial; }
.logo-line-after i { right: initial; }
}
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="default">
<div class="container sidebar-position-left
page-home">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Kindule</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
</div>
<div class="site-nav-toggle">
<button aria-label="Toggle navigation bar">
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home menu-item-active">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />Home</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />Archives</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://kindule.github.io/2018/11/01/技术分享的价值/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Jin Ge">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Kindule">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/11/01/技术分享的价值/" itemprop="url">
技术分享的价值
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2018-11-01 14:23:55" itemprop="dateCreated datePublished" datetime="2018-11-01T14:23:55+08:00">2018-11-01</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2019-02-14 22:48:07" itemprop="dateModified" datetime="2019-02-14T22:48:07+08:00">2019-02-14</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>自工作以来,一直以工程师的角色工作,常常会思考一个问题,如何在技术上获得更多成长?可能很多工程师和我一样也有这样的疑惑。当然这个问题有很多方面可以探讨,今天想跟大家分享一下,技术分享是如何带给我成长的。总结下来,认为分享带给我的成长很多,于我而言,认为技术分享带给我以下四点</p>
<h3 id="目标"><a href="#目标" class="headerlink" title="目标"></a>目标</h3><p>技术分享,当拟定一个主题并且需要去实现这个主题的时候,头脑中肯定会有idea。但是当提笔开始落地的时候,往往会发现很难将idea连贯成为技术文章。比如,Kubernetes存储方面的各种组件,假设A B C三个组件,我也知道A B C大致做了什么,但是真要完成一篇《K8S存储系统概览》来讲清楚Kubernetes存储的时候,为什么需要A B C三个组件协作,A B C三个组件如何协作,会发现对于K8S存储系统的了解其实还有很多欠缺的地方,这个时候你就会回头再来通过代码和各种实现更加深入的了解此技术。</p>
<h3 id="总结归纳"><a href="#总结归纳" class="headerlink" title="总结归纳"></a>总结归纳</h3><p>技术分享的目的,总归是要让别人了解你做的事情,要讲清楚一件事情,之前以为很简单,真正开始做技术分享才发现其实很难,因为你面对的读者很大可能不了解你所做的事情,他们和你不在一个上下文中,如何将你做的事情能够讲到让读者听懂,考验的是对技术的理解深度和总结归纳能力。</p>
<h3 id="刻意练习"><a href="#刻意练习" class="headerlink" title="刻意练习"></a>刻意练习</h3><p>做技术常常有做笔记的习惯,做笔记是否能获得成长?</p>
<h3 id="与业界交流"><a href="#与业界交流" class="headerlink" title="与业界交流"></a>与业界交流</h3><p>当完成一次次技术分享的时候,除了获得个人成长的收获,意料之外的是,业界也给了很多反馈,比如在完成容器相关文章后,在docker社区也有一些比较有深度的提问,比如我们之前招聘时也有面试者说听过我的技术分享。</p>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p>总之,技术分享给我的不仅仅是技术上的成长,还带来了其他很多收获,谢谢!</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://kindule.github.io/2018/09/26/lost-volume/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Jin Ge">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Kindule">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/09/26/lost-volume/" itemprop="url">
lost-volume
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2018-09-26 11:00:41" itemprop="dateCreated datePublished" datetime="2018-09-26T11:00:41+08:00">2018-09-26</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2018-10-23 14:32:11" itemprop="dateModified" datetime="2018-10-23T14:32:11+08:00">2018-10-23</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h3 id="卷无法正常挂载,但是删除Pod,Pod被重新拉起能正常启动,使用本地存储"><a href="#卷无法正常挂载,但是删除Pod,Pod被重新拉起能正常启动,使用本地存储" class="headerlink" title="卷无法正常挂载,但是删除Pod,Pod被重新拉起能正常启动,使用本地存储"></a>卷无法正常挂载,但是删除Pod,Pod被重新拉起能正常启动,使用本地存储</h3><h4 id="思路"><a href="#思路" class="headerlink" title="思路"></a>思路</h4><ul>
<li><p>环境</p>
<ul>
<li>nfs</li>
<li>csi</li>
</ul>
</li>
<li><p>过程思考</p>
<ul>
<li><p>attach成功</p>
</li>
<li><p>global mount成功</p>
</li>
<li><p>mount -v 应该不成功–检查mount是否成功</p>
<ul>
<li><p>NFS未mount成功,原因<strong>执行mount nfs如果remote target没有也不会报错</strong></p>
</li>
<li><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@10-10-40-98 ~]# mount -t nfs -o nolock,async,rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600 172.16.130.1:pvc-3eef6820c13e11e8/root /mnt</span><br><span class="line">mount.nfs: backgrounding "172.16.130.1:pvc-3eef6820c13e11e8/root"</span><br><span class="line">mount.nfs: mount options: "rw,nolock,bg,hard,nointr,rsize=32768,wsize=32768,tcp,actimeo=0,vers=3,timeo=600"</span><br><span class="line">[root@10-10-40-98 ~]# echo $?</span><br><span class="line">0</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>最终发现nfs mount参数配置不正确,参数<code>bg</code>释义,简单来讲mount时立即返回,然后后天执行nfs挂载,退出码一直为0</p>
<blockquote>
<p>bg / fg</p>
<p>Determines how the mount(8) command behaves if an attempt to mount an export fails. The fg option causes mount(8) to exit with an error status if any part of the mount request times out or fails outright. This is called a “foreground” mount, and is the default behavior if neither the fg nor bg mount option is specified.<br>If the bg option is specified, a timeout or failure causes the mount(8) command to fork a child which continues to attempt to mount the export. The parent immediately returns with a zero exit code. This is known as a “background” mount.<br>If the local mount point directory is missing, the mount(8) command acts as if the mount request timed out. This permits nested NFS mounts specified in /etc/fstab to proceed in any order during system initialization, even if some NFS servers are not yet available. Alternatively these issues can be addressed using an automounter (refer to automount(8) for details).</p>
</blockquote>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://kindule.github.io/2018/09/25/Pod挂载Volume失败问题分析/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Jin Ge">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Kindule">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/09/25/Pod挂载Volume失败问题分析/" itemprop="url">
Pod挂载Volume失败问题分析
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2018-09-25 10:01:56" itemprop="dateCreated datePublished" datetime="2018-09-25T10:01:56+08:00">2018-09-25</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2019-02-14 22:48:02" itemprop="dateModified" datetime="2019-02-14T22:48:02+08:00">2019-02-14</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>本文同步发布于<a href="https://mp.weixin.qq.com/s/L0SYc6vHZN9mZkWpePuoxg" target="_blank" rel="noopener">dockerone</a></p>
<p>Kubernetes环境偶尔出现Statefulset中的Pod被删除,新启动的Pod(还是调度到原有节点)挂载volume失败的问题,如下图,经过一番定位分析,也让我们对于Kubernetes系统复杂程度有了新的认知。</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/2018-09-20-090324.png" alt="image-20180919164047762"></p>
<p>在分析此问题之前,作为相关背景知识,先简单介绍对于Kubernetes存储系统的理解。</p>
<h3 id="存储系统简析"><a href="#存储系统简析" class="headerlink" title="存储系统简析"></a>存储系统简析</h3><p>存储也是Kubernetes中比较重要而复杂的系统,功能比较庞大,涉及到不同组件中,不同控制器的协作,如下图。</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/2018-10-08-035245.png" alt=""></p>
<p>从三个维度分析</p>
<ul>
<li><p>从卷的生命周期来讲,卷被Pod使用或者卷被回收,会依赖顺序严格的几个阶段</p>
<ul>
<li><p>卷被Pod使用</p>
<ul>
<li>provision,卷分配成功</li>
<li>attach,卷挂载在对应worker node</li>
<li>mount,卷挂载为文件系统并且映射给对应Pod</li>
</ul>
<p>卷要成功被Pod使用,需要遵循以上顺序</p>
</li>
<li><p>卷被回收</p>
<ul>
<li>umount,卷已经和对应worker node解除映射,且已经从文件系统umount</li>
<li>detach,卷已经从worker node卸载</li>
<li>recycle,卷被回收</li>
</ul>
<p>卷要成功回收,需要遵循以上顺序</p>
</li>
</ul>
</li>
<li><p>从Kubernetes存储系统来讲,卷生命周期管理的职责,又分散于不同的控制器中</p>
<ul>
<li>pv controller,负责创建和回收卷</li>
<li>attach detach controller,负责挂载和卸载卷</li>
<li>volume manager,负责mount和umount卷</li>
</ul>
</li>
<li><p>controller模式,每个controller负责特定功能,并且不断进行reconcile(对比期望状态与实际状态),然后进行调整</p>
<p>比如attach detach controller和volume manager中,各自都会有desiredStateOfWorld(缓存期望状态)和actualStateOfWorld(缓存实际状态)缓存,并且由各自的syncLoopFunc不断对比两个缓存的差异,并进行调整,下文中会介绍。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> {</span><br><span class="line"> desired := getDesiredState();</span><br><span class="line"> current := getCurrentState();</span><br><span class="line"> makeChanges(desired, current);</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>结合以上三个维度,<strong>Kubernetes需要保证卷的管理功能分布在不同控制器的前提下保证卷生命周期顺序的正确性</strong>。以Pod使用卷为例,看Kubernetes是如何做到这一点?</p>
<h3 id="Pod启动流程"><a href="#Pod启动流程" class="headerlink" title="Pod启动流程"></a>Pod启动流程</h3><p>假设scheduler已经完成worker node选择,确定调度的节点,此时启动Pod前,需要先完成卷映射到Pod路径中,结合前面的分析,整个过程如下</p>
<ol>
<li><p>卷分配,pvc绑定pv,由pv controller负责完成,结合<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/controller/volume/persistentvolume/pv_controller.go#L301" target="_blank" rel="noopener">相关代码</a></p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018002900.png" alt=""></p>
<p>此时pvc绑定pv</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181014142538.png" alt=""></p>
</li>
<li><p>attach detach controlle,如果pod分配到worker node,并且对应卷已经创建,则将卷挂载到对应worker node,并且给worker node资源增加volume已经挂载对应卷的状态信息,结合相关<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator.go#L88" target="_blank" rel="noopener">代码1</a>和<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/controller/volume/attachdetach/reconciler/reconciler.go#L251" target="_blank" rel="noopener">代码2</a></p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018004733.png" alt=""></p>
<p>此时对应node资源状态中增加volume信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">[root@10-10-88-152 ~]# kubectl get nodes 10-10-88-113 -o yaml </span><br><span class="line">apiVersion: v1</span><br><span class="line">kind: Node</span><br><span class="line">....</span><br><span class="line"> volumesAttached:</span><br><span class="line"> - devicePath: csi-add9fc778d9593d01818d65ccde7013e87327d9f675b47df42a34b860c581711</span><br><span class="line"> name: kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-4faa18f5bbbd11e8-1365</span><br><span class="line"> - devicePath: csi-5dd249387138238e8e2209eb471450a072dd6543adde7a6769c8461943c789ca</span><br><span class="line"> name: kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-4fa9b764bbbd11e8-1366</span><br><span class="line"> - devicePath: csi-bc9b81e32d84e8890d17568964c1e01af97b0c175e0b73d4bf30bba54e3f1a1e</span><br><span class="line"> name: kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-4fa94533bbbd11e8-1364</span><br><span class="line"> volumesInUse:</span><br><span class="line"> - kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-4fa94533bbbd11e8-1364</span><br><span class="line"> - kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-4fa9b764bbbd11e8-1366</span><br><span class="line"> - kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-4faa18f5bbbd11e8-1365</span><br></pre></td></tr></table></figure>
</li>
<li><p>volume manager在worker node中负责将卷挂载到对应路径</p>
<ul>
<li><p>pod分配到本worker node后,获取Pod需要的volume,通过对比node状态中的volumesAttached,确认volume是否已经attach到node节点,如果attach到node节点则将自身actualStateOfWorld中的volume状态设置成attached,对应<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go#L152" target="_blank" rel="noopener">代码1</a>、<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/volumemanager/reconciler/reconciler.go#L160" target="_blank" rel="noopener">代码2</a></p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018011611.png" alt=""></p>
</li>
<li><p>如果已经attached成功,则进入到文件系统挂载流程,相关<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/volumemanager/reconciler/reconciler.go#L238" target="_blank" rel="noopener">代码</a></p>
<ul>
<li><p>先挂载到node中全局路径,比如<code>/var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-3ecd68c7b7d211e8/globalmount</code></p>
</li>
<li><p>映射到Pod对应路径,比如<code>/var/lib/kubelet/pods/49a5fede-b811-11e8-844f-fa7378845e00/volumes/kubernetes.io~csi/pvc-3ecd68c7b7d211e8/mount</code></p>
</li>
<li><p>actualStateOfWorld中设置volume为挂载成功状态</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018015029.png" alt=""></p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>pod controller确认卷已经映射成功,启动Pod,此处不详细展开</p>
</li>
</ol>
<h3 id="Pod被删除的过程"><a href="#Pod被删除的过程" class="headerlink" title="Pod被删除的过程"></a>Pod被删除的过程</h3><ol>
<li><p>pod controller watch到pod处于被删除状态,执行killPod操作,删除Pod,此处不详细展开</p>
</li>
<li><p>volume manager获取到Pod被删除的信息,会执行如下几步,相关<a href="https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/volumemanager/reconciler/reconciler.go#L160" target="_blank" rel="noopener">代码</a></p>
<ul>
<li><p>将Pod从desiredStateOfWorld的缓存信息中清除</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018024146.png" alt=""></p>
</li>
<li><p>actualStateOfWorld中已经挂载的卷和desiredStateOfWorld发现Pod不应该挂载,执行UmountVolume操作,将Pod和卷映射关系解除,并将Pod从actualStateOfWorld的卷信息中剔除</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018024451.png" alt=""></p>
</li>
<li><p>此时如果实际状态中卷没有关联任何Pod,则说明卷需要可以完全与节点分离,则先执行UnmountDevice将卷的globalpath umount掉,等到下次reconcile时执行MarkVolumeAsDetached将卷完全从实际状态中删除掉。</p>
<p><img src="https://raw.githubusercontent.com/kindule/img/master/20181018024518.png" alt=""></p>
</li>
</ul>
</li>
<li><p>attach detach controller发现挂载到node节点的volume没有被Pod使用,执行detach操作,将卷从node节点detach,此时卷完全处于集群中未被使用的状态,此处不详细展开。</p>
</li>
</ol>
<p>总结为Kubernetes存储系统的特点</p>
<ul>
<li>不同组件通过资源状态协作,attach detach controller需要PVC绑定PV的状态,volume manager需要node status中volume attached状态。</li>
<li>组件通过reconcile方式达到期望状态,并且状态可能需要多次reconcile中完成,如Pod清除掉后,volume最终和node分离</li>
</ul>
<h3 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h3><p>理解了存储系统的整体过程之后,回到问题,statefulset中Pod被删除会发生什么?</p>
<p>首先,对于statefulset的了解,Pod被删除,statefulset controller应该会很快创建Pod,在我们的场景中,Pod还是调度到先前节点中启动。结合对存储的理解,可能的场景</p>
<p>场景一 delete Pod,感知顺序为volume manager(umount)->statefulset->scheduler->volume manager(mount)</p>
<ol>
<li>volume manager发现Pod被删除,执行umount</li>
<li>statefulset发现Pod被删除,马上创建Pod</li>
<li>scheduler发现Pod进行调度</li>
<li>volume manager发现原有volume需要绑定Pod,执行mount</li>
</ol>
<p>场景二 delete Pod,感知顺序为volume manager(umount)->volume manager(unmountDevice)->volume manager(MarkVolumeAsDelete)->attach detach controller(Detach)->statefulset->scheduler->attach detach controller(Attach)->volume manager</p>
<ol>
<li>volume manager发现Pod被删除,执行umount/unmountDevice/MarkVolumeAsDelete(通过几次reconcile)</li>
<li>attach detach controller发现volume在node节点未被使用,执行detach</li>
<li>scheduler发现Pod进行调度</li>
<li>attach detach controller发现volume需要attach,执行attach</li>
<li>volume manager挂载</li>
</ol>
<p>场景三 delete Pod,感知顺序为statefulset->volume manager(umount/deviceUmount)->scheduler->volume manager(mount)</p>
<ol>
<li>statefulset发现Pod被删除,马上创建Pod</li>
<li>volume manager发现Pod被删除,执行umount/deviceUmount(通过几次reconcile),注意此时devicePath和deviceMountPath都为空</li>
<li>scheduler发现Pod进行调度</li>
<li>volume manager发现原有volume需要绑定Pod,执行mount而此时devicePath和deviceMountPath都为空,<strong>问题出现</strong></li>
</ol>
<p>再结合问题出现日志分析</p>
<figure class="highlight verilog"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span><span class="variable">.174310</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">1168</span>] Controller attach succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"49a5fede-b811-11e8-844f-fa7378845e00"</span>) device path: <span class="string">"csi-eb93736e654600786d95eaffa7cd5d616f11a90bdc109e0df575e8646c250eb2"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span><span class="variable">.273344</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">486</span>] MountVolume<span class="variable">.WaitForAttach</span> entering <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"49a5fede-b811-11e8-844f-fa7378845e00"</span>) DevicePath <span class="string">"csi-eb93736e654600786d95eaffa7cd5d616f11a90bdc109e0df575e8646c250eb2"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span><span class="variable">.318275</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">495</span>] MountVolume<span class="variable">.WaitForAttach</span> succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"49a5fede-b811-11e8-844f-fa7378845e00"</span>) DevicePath <span class="string">"csi-eb93736e654600786d95eaffa7cd5d616f11a90bdc109e0df575e8646c250eb2"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">28</span>:<span class="number">33</span><span class="variable">.319345</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">514</span>] MountVolume<span class="variable">.MountDevice</span> succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"49a5fede-b811-11e8-844f-fa7378845e00"</span>) device mount path <span class="string">"/var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-3ecd68c7b7d211e8/globalmount"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">12</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">12</span><span class="variable">.826916</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">486</span>] MountVolume<span class="variable">.WaitForAttach</span> entering <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"67f223dc-b811-11e8-844f-fa7378845e00"</span>) DevicePath <span class="string">"csi-eb93736e654600786d95eaffa7cd5d616f11a90bdc109e0df575e8646c250eb2"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">14</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">14</span><span class="variable">.465225</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">495</span>] MountVolume<span class="variable">.WaitForAttach</span> succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"67f223dc-b811-11e8-844f-fa7378845e00"</span>) DevicePath <span class="string">"csi-eb93736e654600786d95eaffa7cd5d616f11a90bdc109e0df575e8646c250eb2"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">14</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">14</span><span class="variable">.466483</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">514</span>] MountVolume<span class="variable">.MountDevice</span> succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"67f223dc-b811-11e8-844f-fa7378845e00"</span>) device mount path <span class="string">"/var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-3ecd68c7b7d211e8/globalmount"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">15</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: W0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">15</span><span class="variable">.491424</span> <span class="number">1953</span> csi_mounter<span class="variable">.go</span>:<span class="number">354</span>] kubernetes<span class="variable">.io</span>/csi: skipping mount dir removal, path does <span class="keyword">not</span> exist [/<span class="keyword">var</span>/lib/kubelet/pods/<span class="number">49</span>a5fede-b811-<span class="number">11</span>e8-<span class="number">844</span>f-fa7378845e00/volumes/kubernetes<span class="variable">.io</span>~csi/pvc-<span class="number">3</span>ecd68c7b7d211e8/mount]</span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">15</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">15</span><span class="variable">.491450</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">686</span>] UnmountVolume<span class="variable">.TearDown</span> succeeded <span class="keyword">for</span> volume <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span> (OuterVolumeSpecName: <span class="string">"data"</span>) pod <span class="string">"49a5fede-b811-11e8-844f-fa7378845e00"</span> (UID: <span class="string">"49a5fede-b811-11e8-844f-fa7378845e00"</span>). InnerVolumeSpecName <span class="string">"pvc-3ecd68c7b7d211e8"</span>. PluginName <span class="string">"kubernetes.io/csi"</span>, VolumeGidValue <span class="string">""</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: W0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span><span class="variable">.896387</span> <span class="number">1953</span> csi_mounter<span class="variable">.go</span>:<span class="number">354</span>] kubernetes<span class="variable">.io</span>/csi: skipping mount dir removal, path does <span class="keyword">not</span> exist [/<span class="keyword">var</span>/lib/kubelet/pods/<span class="number">67</span>f223dc-b811-<span class="number">11</span>e8-<span class="number">844</span>f-fa7378845e00/volumes/kubernetes<span class="variable">.io</span>~csi/pvc-<span class="number">3</span>ecd68c7b7d211e8/mount]</span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span><span class="variable">.896403</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">686</span>] UnmountVolume<span class="variable">.TearDown</span> succeeded <span class="keyword">for</span> volume <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span> (OuterVolumeSpecName: <span class="string">"data"</span>) pod <span class="string">"67f223dc-b811-11e8-844f-fa7378845e00"</span> (UID: <span class="string">"67f223dc-b811-11e8-844f-fa7378845e00"</span>). InnerVolumeSpecName <span class="string">"pvc-3ecd68c7b7d211e8"</span>. PluginName <span class="string">"kubernetes.io/csi"</span>, VolumeGidValue <span class="string">""</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span><span class="variable">.917540</span> <span class="number">1953</span> reconciler<span class="variable">.go</span>:<span class="number">278</span>] operationExecutor<span class="variable">.UnmountDevice</span> started <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) on node <span class="string">"10-10-40-16"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: W0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">44</span><span class="variable">.919231</span> <span class="number">1953</span> mount_linux<span class="variable">.go</span>:<span class="number">179</span>] could <span class="keyword">not</span> determine device <span class="keyword">for</span> path: <span class="string">"/var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-3ecd68c7b7d211e8/globalmount"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">45</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">45</span><span class="variable">.609605</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">760</span>] UnmountDevice succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> %!(EXTRA <span class="keyword">string</span>=UnmountDevice succeeded <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) on node <span class="string">"10-10-40-16"</span> )</span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">45</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">45</span><span class="variable">.624963</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">486</span>] MountVolume<span class="variable">.WaitForAttach</span> entering <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"77b8caf7-b811-11e8-844f-fa7378845e00"</span>) DevicePath <span class="string">""</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">46</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: E0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">46</span><span class="variable">.006612</span> <span class="number">1953</span> nestedpendingoperations<span class="variable">.go</span>:<span class="number">267</span>] Operation <span class="keyword">for</span> <span class="string">"\"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338\""</span> failed. No retries permitted <span class="keyword">until</span> <span class="number">2018</span>-<span class="number">09</span>-<span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">46</span><span class="variable">.506583596</span> +<span class="number">0800</span> CST m=+<span class="number">105572</span><span class="variable">.978439381</span> (durationBeforeRetry <span class="number">500</span>ms). Error: <span class="string">"MountVolume.WaitForAttach failed for volume \"pvc-3ecd68c7b7d211e8\" (UniqueName: \"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338\") pod \"yoooo-416ea0-0\" (UID: \"77b8caf7-b811-11e8-844f-fa7378845e00\") : resource name may not be empty"</span></span><br><span class="line">Sep <span class="number">14</span> <span class="number">19</span>:<span class="number">29</span>:<span class="number">46</span> <span class="number">10</span>-<span class="number">10</span>-<span class="number">40</span>-<span class="number">16</span> kubelet: I0914 <span class="number">19</span>:<span class="number">29</span>:<span class="number">46</span><span class="variable">.533962</span> <span class="number">1953</span> operation_generator<span class="variable">.go</span>:<span class="number">486</span>] MountVolume<span class="variable">.WaitForAttach</span> entering <span class="keyword">for</span> volume <span class="string">"pvc-3ecd68c7b7d211e8"</span> (UniqueName: <span class="string">"kubernetes.io/csi/csi-qcfsplugin^csi-qcfs-volume-3ecd68c7b7d211e8-338"</span>) pod <span class="string">"yoooo-416ea0-0"</span> (UID: <span class="string">"77b8caf7-b811-11e8-844f-fa7378845e00"</span>) DevicePath <span class="string">""</span></span><br></pre></td></tr></table></figure>
<p>WaitForAttach有两个阶段</p>
<ul>
<li><code>Sep 14 19:29:14</code>以及之前DevicePath非空</li>
<li><code>Sep 14 19:29:45</code>以及之后DevicePath为空</li>
</ul>
<p>那么在这两个时间点之间发生了什么,怀疑这个时间点时间发生的问题造成卷无法挂载</p>
<p>通过日志发现<code>Sep 14 19:29:14</code>到<code>Sep 14 19:29:45</code>有一段日志信息比较关键,分析如下</p>
<ol>
<li>Sep 14 19:29:14 …… MountVolume.MountDevice ……</li>
<li>Sep 14 19:29:15 ….. UnmountVolume.TearDown ……</li>
<li>Sep 14 19:29:44 …… UnmountVolume.TearDown ……</li>
<li>Sep 14 19:29:44 …… operationExecutor.UnmountDevice ……</li>
<li>Sep 14 19:29:44 …… could not determine device for path ….</li>
</ol>
<p>在步骤4中,有设置相关函数的</p>
<blockquote>
<p>UnmountDevice->GenerateUnmountDeviceFunc->actualStateOfWorld.MarkDeviceAsUnmounted->asw.SetVolumeGloballyMounted</p>
</blockquote>
<p>其中比较关键的函数<code>SetVolumeGloballyMounted</code></p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">asw.SetVolumeGloballyMounted(volumeName, <span class="literal">false</span> <span class="comment">/* globallyMounted */</span>, <span class="comment">/* devicePath */</span><span class="string">""</span>, <span class="comment">/* deviceMountPath */</span><span class="string">""</span>)</span><br></pre></td></tr></table></figure>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p>Kubernetes之所以在当前成为容器编排领域的事实标准,原因很多,但是对我们来讲基于声明式API的编程范式是我们依赖Kubernetes的重要原因,当然在其解决的问题规模下复杂程度也不言而喻,总之,一句话,没有银弹。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://kindule.github.io/2018/09/05/Clean-Architecture读书笔记(一)/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Jin Ge">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Kindule">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/09/05/Clean-Architecture读书笔记(一)/" itemprop="url">
Clean Architecture读书笔记(一)
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2018-09-05 08:20:38" itemprop="dateCreated datePublished" datetime="2018-09-05T08:20:38+08:00">2018-09-05</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2019-02-14 22:46:40" itemprop="dateModified" datetime="2019-02-14T22:46:40+08:00">2019-02-14</time>
</span>
</div>
</header>