Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Rename all variables to remove "cricontainerd".
Browse files Browse the repository at this point in the history
Signed-off-by: Lantao Liu <[email protected]>
  • Loading branch information
Random-Liu committed Mar 19, 2018
1 parent 9afdd19 commit 387da59
Show file tree
Hide file tree
Showing 54 changed files with 156 additions and 157 deletions.
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var loadCommand = cli.Command{
timeout = context.GlobalDuration("timeout")
cancel gocontext.CancelFunc
)
cl, err := client.NewCRIContainerdClient(address, timeout)
cl, err := client.NewCRIPluginClient(address, timeout)
if err != nil {
return errors.Wrap(err, "failed to create grpc client")
}
Expand Down
2 changes: 1 addition & 1 deletion cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func initCRIService(ic *plugin.InitContext) (interface{}, error) {
return nil, errors.Wrap(err, "failed to create containerd client")
}

s, err := server.NewCRIContainerdService(c, client)
s, err := server.NewCRIService(c, client)
if err != nil {
return nil, errors.Wrap(err, "failed to create CRI service")
}
Expand Down
2 changes: 1 addition & 1 deletion hack/update-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ protoc \

# Update boilerplate for the generated file.
echo "$(cat hack/boilerplate/boilerplate.go.txt ${API_ROOT}/api.pb.go)" > ${API_ROOT}/api.pb.go
sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${API_ROOT}/api.pb.go
sed -i".bak" "s/Copyright YEAR AUTHORS/Copyright $(date '+%Y') The containerd Authors/g" ${API_ROOT}/api.pb.go

gofmt -l -s -w ${API_ROOT}/api.pb.go
2 changes: 1 addition & 1 deletion integration/image_load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestImageLoad(t *testing.T) {
}

t.Logf("load image in cri")
res, err := criContainerdClient.LoadImage(context.Background(), &api.LoadImageRequest{FilePath: tar})
res, err := criPluginClient.LoadImage(context.Background(), &api.LoadImageRequest{FilePath: tar})
require.NoError(t, err)
require.Equal(t, []string{loadedImage}, res.GetImages())

Expand Down
18 changes: 9 additions & 9 deletions integration/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ const (
)

var (
runtimeService cri.RuntimeService
imageService cri.ImageManagerService
containerdClient *containerd.Client
criContainerdClient api.CRIContainerdServiceClient
runtimeService cri.RuntimeService
imageService cri.ImageManagerService
containerdClient *containerd.Client
criPluginClient api.CRIPluginServiceClient
)

var criContainerdEndpoint = flag.String("cri-endpoint", "/run/containerd/containerd.sock", "The endpoint of cri plugin.")
var criContainerdRoot = flag.String("cri-root", "/var/lib/containerd/io.containerd.grpc.v1.cri", "The root directory of cri plugin.")
var criEndpoint = flag.String("cri-endpoint", "/run/containerd/containerd.sock", "The endpoint of cri plugin.")
var criRoot = flag.String("cri-root", "/var/lib/containerd/io.containerd.grpc.v1.cri", "The root directory of cri plugin.")

func init() {
flag.Parse()
Expand All @@ -64,11 +64,11 @@ func init() {
// ConnectDaemons connect cri plugin and containerd, and initialize the clients.
func ConnectDaemons() error {
var err error
runtimeService, err = remote.NewRemoteRuntimeService(*criContainerdEndpoint, timeout)
runtimeService, err = remote.NewRemoteRuntimeService(*criEndpoint, timeout)
if err != nil {
return errors.Wrap(err, "failed to create runtime service")
}
imageService, err = remote.NewRemoteImageService(*criContainerdEndpoint, timeout)
imageService, err = remote.NewRemoteImageService(*criEndpoint, timeout)
if err != nil {
return errors.Wrap(err, "failed to create image service")
}
Expand All @@ -87,7 +87,7 @@ func ConnectDaemons() error {
if err != nil {
return errors.Wrap(err, "failed to connect containerd")
}
criContainerdClient, err = client.NewCRIContainerdClient(*criContainerdEndpoint, timeout)
criPluginClient, err = client.NewCRIPluginClient(*criEndpoint, timeout)
if err != nil {
return errors.Wrap(err, "failed to connect cri plugin")
}
Expand Down
2 changes: 1 addition & 1 deletion integration/volume_copy_up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestVolumeCopyUp(t *testing.T) {
assert.Equal(t, "test_content\n", string(stdout))

t.Logf("Check host path of the volume")
hostCmd := fmt.Sprintf("ls %s/containers/%s/volumes/*/test_file | xargs cat", *criContainerdRoot, cn)
hostCmd := fmt.Sprintf("ls %s/containers/%s/volumes/*/test_file | xargs cat", *criRoot, cn)
output, err := exec.Command("sh", "-c", hostCmd).CombinedOutput()
require.NoError(t, err)
assert.Equal(t, "test_content\n", string(output))
Expand Down
57 changes: 28 additions & 29 deletions pkg/api/v1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/api/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_unrecognized_all) = false;

// CRIContainerdService defines non-CRI APIs for cri-containerd.
service CRIContainerdService{
// CRIPluginService defines non-CRI APIs for cri plugin.
service CRIPluginService{
// LoadImage loads a image into containerd.
rpc LoadImage(LoadImageRequest) returns (LoadImageResponse) {}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
api "github.com/containerd/cri/pkg/api/v1"
)

// NewCRIContainerdClient creates grpc client of cri-containerd
// NewCRIPluginClient creates grpc client of cri plugin
// TODO(random-liu): Wrap grpc functions.
func NewCRIContainerdClient(endpoint string, timeout time.Duration) (api.CRIContainerdServiceClient, error) {
func NewCRIPluginClient(endpoint string, timeout time.Duration) (api.CRIPluginServiceClient, error) {
addr, dialer, err := util.GetAddressAndDialer(endpoint)
if err != nil {
return nil, errors.Wrap(err, "failed to get dialer")
Expand All @@ -43,5 +43,5 @@ func NewCRIContainerdClient(endpoint string, timeout time.Duration) (api.CRICont
if err != nil {
return nil, errors.Wrap(err, "failed to dial")
}
return api.NewCRIContainerdServiceClient(conn), nil
return api.NewCRIPluginServiceClient(conn), nil
}
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type Config struct {
ContainerdRootDir string `json:"containerdRootDir,omitempty"`
// ContainerdEndpoint is the containerd endpoint path.
ContainerdEndpoint string `json:"containerdEndpoint,omitempty"`
// RootDir is the root directory path for managing cri-containerd files
// RootDir is the root directory path for managing cri plugin files
// (metadata checkpoint etc.)
RootDir string `json:"rootDir,omitempty"`
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/container_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
func (c *criContainerdService) Attach(ctx context.Context, r *runtime.AttachRequest) (*runtime.AttachResponse, error) {
func (c *criService) Attach(ctx context.Context, r *runtime.AttachRequest) (*runtime.AttachResponse, error) {
cntr, err := c.containerStore.Get(r.GetContainerId())
if err != nil {
return nil, errors.Wrap(err, "failed to find container in store")
Expand All @@ -42,7 +42,7 @@ func (c *criContainerdService) Attach(ctx context.Context, r *runtime.AttachRequ
return c.streamServer.GetAttach(r)
}

func (c *criContainerdService) attachContainer(ctx context.Context, id string, stdin io.Reader, stdout, stderr io.WriteCloser,
func (c *criService) attachContainer(ctx context.Context, id string, stdin io.Reader, stdout, stderr io.WriteCloser,
tty bool, resize <-chan remotecommand.TerminalSize) error {
// Get container from our container store.
cntr, err := c.containerStore.Get(id)
Expand Down
12 changes: 6 additions & 6 deletions pkg/server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func init() {
}

// CreateContainer creates a new container in the given PodSandbox.
func (c *criContainerdService) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (_ *runtime.CreateContainerResponse, retErr error) {
func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (_ *runtime.CreateContainerResponse, retErr error) {
config := r.GetConfig()
sandboxConfig := r.GetSandboxConfig()
sandbox, err := c.sandboxStore.Get(r.GetPodSandboxId())
Expand Down Expand Up @@ -274,7 +274,7 @@ func (c *criContainerdService) CreateContainer(ctx context.Context, r *runtime.C
return &runtime.CreateContainerResponse{ContainerId: id}, nil
}

func (c *criContainerdService) generateContainerSpec(id string, sandboxID string, sandboxPid uint32, config *runtime.ContainerConfig,
func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxPid uint32, config *runtime.ContainerConfig,
sandboxConfig *runtime.PodSandboxConfig, imageConfig *imagespec.ImageConfig, extraMounts []*runtime.Mount) (*runtimespec.Spec, error) {
// Creates a spec Generator with the default spec.
spec, err := defaultRuntimeSpec(id)
Expand Down Expand Up @@ -377,7 +377,7 @@ func (c *criContainerdService) generateContainerSpec(id string, sandboxID string
// generateVolumeMounts sets up image volumes for container. Rely on the removal of container
// root directory to do cleanup. Note that image volume will be skipped, if there is criMounts
// specified with the same destination.
func (c *criContainerdService) generateVolumeMounts(containerRootDir string, criMounts []*runtime.Mount, config *imagespec.ImageConfig) []*runtime.Mount {
func (c *criService) generateVolumeMounts(containerRootDir string, criMounts []*runtime.Mount, config *imagespec.ImageConfig) []*runtime.Mount {
if len(config.Volumes) == 0 {
return nil
}
Expand Down Expand Up @@ -405,7 +405,7 @@ func (c *criContainerdService) generateVolumeMounts(containerRootDir string, cri

// generateContainerMounts sets up necessary container mounts including /dev/shm, /etc/hosts
// and /etc/resolv.conf.
func (c *criContainerdService) generateContainerMounts(sandboxRootDir string, config *runtime.ContainerConfig) []*runtime.Mount {
func (c *criService) generateContainerMounts(sandboxRootDir string, config *runtime.ContainerConfig) []*runtime.Mount {
var mounts []*runtime.Mount
securityContext := config.GetLinux().GetSecurityContext()
if !isInCRIMounts(etcHosts, config.GetMounts()) {
Expand Down Expand Up @@ -496,7 +496,7 @@ func clearReadOnly(m *runtimespec.Mount) {
}

// addDevices set device mapping without privilege.
func (c *criContainerdService) addOCIDevices(g *generate.Generator, devs []*runtime.Device) error {
func (c *criService) addOCIDevices(g *generate.Generator, devs []*runtime.Device) error {
spec := g.Spec()
for _, device := range devs {
path, err := c.os.ResolveSymbolicLink(device.HostPath)
Expand Down Expand Up @@ -559,7 +559,7 @@ func setOCIDevicesPrivileged(g *generate.Generator) error {
}

// addOCIBindMounts adds bind mounts.
func (c *criContainerdService) addOCIBindMounts(g *generate.Generator, mounts []*runtime.Mount, mountLabel string) error {
func (c *criService) addOCIBindMounts(g *generate.Generator, mounts []*runtime.Mount, mountLabel string) error {
// Mount cgroup into the container as readonly, which inherits docker's behavior.
g.AddCgroupsMount("ro") // nolint: errcheck
for _, mount := range mounts {
Expand Down
Loading

0 comments on commit 387da59

Please sign in to comment.