44 "fmt"
55
66 "github.com/alibaba/pouch/cri/stream"
7- criv1alpha1 "github.com/alibaba/pouch/cri/v1alpha1"
8- servicev1alpha1 "github.com/alibaba/pouch/cri/v1alpha1/service"
97 criv1alpha2 "github.com/alibaba/pouch/cri/v1alpha2"
108 "github.com/alibaba/pouch/daemon/config"
119 "github.com/alibaba/pouch/daemon/mgr"
@@ -29,67 +27,15 @@ func RunCriService(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, i
2927 return
3028 }
3129 switch daemonconfig .CriConfig .CriVersion {
32- case "v1alpha1" :
33- err = runv1alpha1 (daemonconfig , containerMgr , imageMgr , streamRouterCh , readyCh )
3430 case "v1alpha2" :
3531 err = runv1alpha2 (daemonconfig , containerMgr , imageMgr , volumeMgr , criPlugin , streamRouterCh , readyCh )
3632 default :
3733 streamRouterCh <- nil
3834 readyCh <- false
39- err = fmt .Errorf ("failed to start CRI service: invalid CRI version %s, expected to be v1alpha1 or v1alpha2" , daemonconfig .CriConfig .CriVersion )
35+ err = fmt .Errorf ("failed to start CRI service: invalid CRI version %s, expected to be v1alpha2" , daemonconfig .CriConfig .CriVersion )
4036 }
4137}
4238
43- // Start CRI service with CRI version: v1alpha1
44- func runv1alpha1 (daemonconfig * config.Config , containerMgr mgr.ContainerMgr , imageMgr mgr.ImageMgr , streamRouterCh chan stream.Router , readyCh chan bool ) error {
45- logrus .Infof ("Start CRI service with CRI version: v1alpha1" )
46- criMgr , err := criv1alpha1 .NewCriManager (daemonconfig , containerMgr , imageMgr )
47- if err != nil {
48- streamRouterCh <- nil
49- readyCh <- false
50- return fmt .Errorf ("failed to get CriManager with error: %v" , err )
51- }
52-
53- service , err := servicev1alpha1 .NewService (daemonconfig , criMgr )
54- if err != nil {
55- streamRouterCh <- nil
56- readyCh <- false
57- return fmt .Errorf ("failed to start CRI service with error: %v" , err )
58- }
59-
60- errChan := make (chan error , 2 )
61- // If the cri stream server share the port with pouchd,
62- // export the its router. Otherwise launch it.
63- if daemonconfig .CriConfig .StreamServerReusePort {
64- errChan = make (chan error , 1 )
65- streamRouterCh <- criMgr .StreamRouter ()
66- } else {
67- go func () {
68- errChan <- criMgr .StreamServerStart ()
69- logrus .Infof ("CRI Stream server stopped" )
70- }()
71- streamRouterCh <- nil
72- }
73-
74- go func () {
75- errChan <- service .Serve ()
76- logrus .Infof ("CRI GRPC server stopped" )
77- }()
78-
79- // the criservice has set up, send Ready
80- readyCh <- true
81-
82- // Check for error
83- for i := 0 ; i < cap (errChan ); i ++ {
84- if err := <- errChan ; err != nil {
85- return err
86- }
87- }
88-
89- logrus .Infof ("CRI service stopped" )
90- return nil
91- }
92-
9339// Start CRI service with CRI version: v1alpha2
9440func runv1alpha2 (daemonconfig * config.Config , containerMgr mgr.ContainerMgr , imageMgr mgr.ImageMgr , volumeMgr mgr.VolumeMgr , criPlugin hookplugins.CriPlugin , streamRouterCh chan stream.Router , readyCh chan bool ) error {
9541 logrus .Infof ("Start CRI service with CRI version: v1alpha2" )
0 commit comments