forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
32,649 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package cri | ||
|
||
import ( | ||
criv1alpha1 "github.com/alibaba/pouch/cri/v1alpha1" | ||
servicev1alpha1 "github.com/alibaba/pouch/cri/v1alpha1/service" | ||
criv1alpha2 "github.com/alibaba/pouch/cri/v1alpha2" | ||
servicev1alpha2 "github.com/alibaba/pouch/cri/v1alpha2/service" | ||
"github.com/alibaba/pouch/daemon/config" | ||
"github.com/alibaba/pouch/daemon/mgr" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// RunCriService start cri service if pouchd is specified with --enable-cri. | ||
func RunCriService(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, imageMgr mgr.ImageMgr, stopCh chan error) { | ||
var err error | ||
|
||
defer func() { | ||
stopCh <- err | ||
close(stopCh) | ||
}() | ||
if !daemonconfig.IsCriEnabled { | ||
return | ||
} | ||
switch daemonconfig.CriConfig.CriVersion { | ||
case "v1alpha1": | ||
runv1alpha1(daemonconfig, containerMgr, imageMgr) | ||
case "v1alpha2": | ||
runv1alpha2(daemonconfig, containerMgr, imageMgr) | ||
} | ||
return | ||
} | ||
|
||
func runv1alpha1(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, imageMgr mgr.ImageMgr) { | ||
criMgr, err := criv1alpha1.NewCriManager(daemonconfig, containerMgr, imageMgr) | ||
if err != nil { | ||
return | ||
} | ||
|
||
service, err := servicev1alpha1.NewService(daemonconfig, criMgr) | ||
if err != nil { | ||
return | ||
} | ||
|
||
grpcServerCloseCh := make(chan struct{}) | ||
go func() { | ||
if err := service.Serve(); err != nil { | ||
logrus.Errorf("failed to start grpc server: %v", err) | ||
} | ||
close(grpcServerCloseCh) | ||
}() | ||
|
||
streamServerCloseCh := make(chan struct{}) | ||
go func() { | ||
if err := criMgr.StreamServerStart(); err != nil { | ||
logrus.Errorf("failed to start stream server: %v", err) | ||
} | ||
close(streamServerCloseCh) | ||
}() | ||
|
||
<-streamServerCloseCh | ||
logrus.Infof("CRI Stream server stopped") | ||
<-grpcServerCloseCh | ||
logrus.Infof("CRI GRPC server stopped") | ||
|
||
logrus.Infof("CRI service stopped") | ||
return | ||
} | ||
|
||
func runv1alpha2(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, imageMgr mgr.ImageMgr) { | ||
criMgr, err := criv1alpha2.NewCriManager(daemonconfig, containerMgr, imageMgr) | ||
if err != nil { | ||
return | ||
} | ||
|
||
service, err := servicev1alpha2.NewService(daemonconfig, criMgr) | ||
if err != nil { | ||
return | ||
} | ||
|
||
grpcServerCloseCh := make(chan struct{}) | ||
go func() { | ||
if err := service.Serve(); err != nil { | ||
logrus.Errorf("failed to start grpc server: %v", err) | ||
} | ||
close(grpcServerCloseCh) | ||
}() | ||
|
||
streamServerCloseCh := make(chan struct{}) | ||
go func() { | ||
if err := criMgr.StreamServerStart(); err != nil { | ||
logrus.Errorf("failed to start stream server: %v", err) | ||
} | ||
close(streamServerCloseCh) | ||
}() | ||
|
||
<-streamServerCloseCh | ||
logrus.Infof("CRI Stream server stopped") | ||
<-grpcServerCloseCh | ||
logrus.Infof("CRI GRPC server stopped") | ||
|
||
logrus.Infof("CRI service stopped") | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package src | ||
package v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package src | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package src | ||
package v1alpha1 | ||
|
||
import ( | ||
"github.com/sirupsen/logrus" | ||
|
Oops, something went wrong.