Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import github.com/containerd/containerd/api/runtime/v2/task #8850

Closed
yoheiueda opened this issue Jul 20, 2023 · 3 comments
Closed

Cannot import github.com/containerd/containerd/api/runtime/v2/task #8850

yoheiueda opened this issue Jul 20, 2023 · 3 comments
Labels

Comments

@yoheiueda
Copy link
Contributor

yoheiueda commented Jul 20, 2023

Description

When I import "github.com/containerd/containerd/api/runtime/v2/task" from my local go program, I encounter the following build error.

main.go:6:2: no required module provides package github.com/containerd/containerd/api/runtime/v2/task; to add it:
	go get github.com/containerd/containerd/api/runtime/v2/task

Then, go get github.com/containerd/containerd/api/runtime/v2/task shows the following error.

go: module github.com/containerd/containerd/api@upgrade found (v1.6.0-beta.3), but does not contain package github.com/containerd/containerd/api/runtime/v2/task

go mod tidy also shows a similar error as described later.

The api package was a Go module at v1.6.0-beta.3, and the resository has a git tag api/v1.6.0-beta.3, but the api package is not a Go module at v1.7.2, since go.mod has been remove from the api directory.

I guess that go get command first tries to find the latest version of api module, and finds the git tag api/v1.6.0-beta.3, but the old api module does not include the task directory, which was introduced in the later version.

Steps to reproduce the issue

  1. Prepare go.mod
go mod init
go get github.com/containerd/containerd/[email protected]
  1. Create a main.go as follows in an empty directory.
package main

import (
	"fmt"

	task "github.com/containerd/containerd/api/runtime/v2"
)

func main() {
	var t task.TaskService
	fmt.Println(t)
}
  1. Update go.mod
go mod tidy

Go Playground: https://go.dev/play/p/bGaR1VvTlT1

Describe the results you received and expected

received result

go mod tidy returns the following error.

go: finding module for package github.com/containerd/containerd/api/runtime/v2/task
test imports
	github.com/containerd/containerd/api/runtime/v2/task: module github.com/containerd/containerd/api@latest found (v1.6.0-beta.3), but does not contain package github.com/containerd/containerd/api/runtime/v2/task

Expected result

go mod tidy update go.mod successfully.

What version of containerd are you using?

v1.7.2

Any other relevant information

Go version: go1.20.3 darwin/arm64

Show configuration if it is related to CRI plugin.

No response

@Iceber
Copy link
Member

Iceber commented Jul 21, 2023

t := &task.Task{}

There is no Task structure in github.com/containerd/containerd/api/runtime/v2/task. Use a structure that exists to make the go mod tidy work.
->

t := &task.StartRequest{}
// or
var t task.TaskService

@yoheiueda
Copy link
Contributor Author

@Iceber Thank you for pointing it out. I updated my comment to correct it.

The problem still persists even after I corrected the code.

@yoheiueda
Copy link
Contributor Author

@Iceber Sorry, I used a wrong import path.

After I fixed the import path, the problem disappeared.

	task "github.com/containerd/containerd/api/runtime/task/v2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants