@@ -163,6 +163,9 @@ func (c *calcium) doCreateContainerWithCPUPeriod(nodename string, connum int, qu
163
163
continue
164
164
}
165
165
166
+ // after start
167
+ runExec (node .Engine , info , AFTER_START )
168
+
166
169
_ , err = c .store .AddContainer (info .ID , opts .Podname , node .Name , containerName , nil , opts .Memory )
167
170
if err != nil {
168
171
ms [i ].Error = err .Error ()
@@ -435,6 +438,9 @@ func (c *calcium) doCreateContainerWithScheduler(nodename string, cpumap []types
435
438
continue
436
439
}
437
440
441
+ // after start
442
+ runExec (node .Engine , info , AFTER_START )
443
+
438
444
_ , err = c .store .AddContainer (info .ID , opts .Podname , node .Name , containerName , quota , opts .Memory )
439
445
if err != nil {
440
446
ms [i ].Error = err .Error ()
@@ -586,6 +592,10 @@ func (c *calcium) makeContainerOptions(quota map[string]int, specs types.Specs,
586
592
if entry .HealthCheck == "tcp" || entry .HealthCheck == "http" {
587
593
containerLabels ["healthcheck" ] = entry .HealthCheck
588
594
}
595
+ // 要把after_start和before_stop写进去
596
+ containerLabels [AFTER_START ] = entry .AfterStart
597
+ containerLabels [BEFORE_STOP ] = entry .BeforeStop
598
+ // 接下来是meta
589
599
for key , value := range specs .Meta {
590
600
containerLabels [key ] = value
591
601
}
@@ -759,6 +769,9 @@ func (c *calcium) doUpgradeContainer(containers []*types.Container, image string
759
769
// TODO in the future I hope `makeContainerConfig` will make a deep copy of config
760
770
imageToDelete := info .Config .Image
761
771
772
+ // before stop old container
773
+ runExec (engine , info , BEFORE_STOP )
774
+
762
775
// stops the old container
763
776
timeout := 5 * time .Second
764
777
err = engine .ContainerStop (context .Background (), info .ID , & timeout )
@@ -820,6 +833,9 @@ func (c *calcium) doUpgradeContainer(containers []*types.Container, image string
820
833
continue
821
834
}
822
835
836
+ // after start
837
+ runExec (engine , newInfo , AFTER_START )
838
+
823
839
// if so, add a new container in etcd
824
840
_ , err = c .store .AddContainer (newInfo .ID , container .Podname , container .Nodename , containerName , container .CPU , container .Memory )
825
841
if err != nil {
0 commit comments