Merge pull request #7349 from thaJeztah/gofmt_119
clean-up "nolint" comments, remove unused ones, update golangci-lint
This commit is contained in:
commit
3ce301ddee
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -41,7 +41,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: golangci/golangci-lint-action@v3
|
- uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.48.0
|
version: v1.49.0
|
||||||
skip-cache: true
|
skip-cache: true
|
||||||
args: --timeout=8m
|
args: --timeout=8m
|
||||||
|
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- structcheck
|
- exportloopref # Checks for pointers to enclosing loop variables
|
||||||
- varcheck
|
|
||||||
- staticcheck
|
|
||||||
- unconvert
|
|
||||||
- gofmt
|
- gofmt
|
||||||
- goimports
|
- goimports
|
||||||
- revive
|
|
||||||
- ineffassign
|
|
||||||
- vet
|
|
||||||
- unused
|
|
||||||
- misspell
|
|
||||||
- gosec
|
- gosec
|
||||||
- exportloopref # Checks for pointers to enclosing loop variables
|
- ineffassign
|
||||||
|
- misspell
|
||||||
|
- nolintlint
|
||||||
|
- revive
|
||||||
|
- staticcheck
|
||||||
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
|
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
|
||||||
|
- unconvert
|
||||||
|
- unused
|
||||||
|
- vet
|
||||||
disable:
|
disable:
|
||||||
- errcheck
|
- errcheck
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, fi os.FileInfo) err
|
|||||||
return errors.New("unsupported stat type")
|
return errors.New("unsupported stat type")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rdev is int32 on darwin/bsd, int64 on linux/solaris
|
rdev := uint64(s.Rdev) //nolint:nolintlint,unconvert // rdev is int32 on darwin/bsd, int64 on linux/solaris
|
||||||
rdev := uint64(s.Rdev) // nolint: unconvert
|
|
||||||
|
|
||||||
// Currently go does not fill in the major/minors
|
// Currently go does not fill in the major/minors
|
||||||
if s.Mode&syscall.S_IFBLK != 0 ||
|
if s.Mode&syscall.S_IFBLK != 0 ||
|
||||||
|
@ -235,7 +235,12 @@ func (c config) newClient() (*containerd.Client, error) {
|
|||||||
|
|
||||||
func serve(c config) error {
|
func serve(c config) error {
|
||||||
go func() {
|
go func() {
|
||||||
if err := http.ListenAndServe(c.Metrics, metrics.Handler()); err != nil {
|
srv := &http.Server{
|
||||||
|
Addr: c.Metrics,
|
||||||
|
Handler: metrics.Handler(),
|
||||||
|
ReadHeaderTimeout: 5 * time.Minute, // "G112: Potential Slowloris Attack (gosec)"; not a real concern for our use, so setting a long timeout.
|
||||||
|
}
|
||||||
|
if err := srv.ListenAndServe(); err != nil {
|
||||||
logrus.WithError(err).Error("listen and serve")
|
logrus.WithError(err).Error("listen and serve")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// nolint: golint
|
//nolint:golint
|
||||||
package fuzz
|
package fuzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -40,8 +40,7 @@ import (
|
|||||||
exec "golang.org/x/sys/execabs"
|
exec "golang.org/x/sys/execabs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// the following nolint is for shutting up gometalinter on non-linux.
|
//nolint:unused // Ignore on non-Linux
|
||||||
// nolint: unused
|
|
||||||
func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, func()) {
|
func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, func()) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
|
@ -210,7 +210,7 @@ func PodSandboxConfigWithCleanup(t *testing.T, name, ns string, opts ...PodSandb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set Windows HostProcess on the pod.
|
// Set Windows HostProcess on the pod.
|
||||||
func WithWindowsHostProcessPod(p *runtime.PodSandboxConfig) { //nolint:unused
|
func WithWindowsHostProcessPod(p *runtime.PodSandboxConfig) {
|
||||||
if p.Windows == nil {
|
if p.Windows == nil {
|
||||||
p.Windows = &runtime.WindowsPodSandboxConfig{}
|
p.Windows = &runtime.WindowsPodSandboxConfig{}
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ func WithTestAnnotations() ContainerOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add container resource limits.
|
// Add container resource limits.
|
||||||
func WithResources(r *runtime.LinuxContainerResources) ContainerOpts { //nolint:unused
|
func WithResources(r *runtime.LinuxContainerResources) ContainerOpts {
|
||||||
return func(c *runtime.ContainerConfig) {
|
return func(c *runtime.ContainerConfig) {
|
||||||
if c.Linux == nil {
|
if c.Linux == nil {
|
||||||
c.Linux = &runtime.LinuxContainerConfig{}
|
c.Linux = &runtime.LinuxContainerConfig{}
|
||||||
@ -247,7 +247,7 @@ func WithResources(r *runtime.LinuxContainerResources) ContainerOpts { //nolint:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adds Windows container resource limits.
|
// Adds Windows container resource limits.
|
||||||
func WithWindowsResources(r *runtime.WindowsContainerResources) ContainerOpts { //nolint:unused
|
func WithWindowsResources(r *runtime.WindowsContainerResources) ContainerOpts {
|
||||||
return func(c *runtime.ContainerConfig) {
|
return func(c *runtime.ContainerConfig) {
|
||||||
if c.Windows == nil {
|
if c.Windows == nil {
|
||||||
c.Windows = &runtime.WindowsContainerConfig{}
|
c.Windows = &runtime.WindowsContainerConfig{}
|
||||||
@ -265,7 +265,7 @@ func WithVolumeMount(hostPath, containerPath string) ContainerOpts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithWindowsUsername(username string) ContainerOpts { //nolint:unused
|
func WithWindowsUsername(username string) ContainerOpts {
|
||||||
return func(c *runtime.ContainerConfig) {
|
return func(c *runtime.ContainerConfig) {
|
||||||
if c.Windows == nil {
|
if c.Windows == nil {
|
||||||
c.Windows = &runtime.WindowsContainerConfig{}
|
c.Windows = &runtime.WindowsContainerConfig{}
|
||||||
@ -277,7 +277,7 @@ func WithWindowsUsername(username string) ContainerOpts { //nolint:unused
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithWindowsHostProcessContainer() ContainerOpts { //nolint:unused
|
func WithWindowsHostProcessContainer() ContainerOpts {
|
||||||
return func(c *runtime.ContainerConfig) {
|
return func(c *runtime.ContainerConfig) {
|
||||||
if c.Windows == nil {
|
if c.Windows == nil {
|
||||||
c.Windows = &runtime.WindowsContainerConfig{}
|
c.Windows = &runtime.WindowsContainerConfig{}
|
||||||
@ -322,7 +322,7 @@ func WithLogPath(path string) ContainerOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithSupplementalGroups adds supplemental groups.
|
// WithSupplementalGroups adds supplemental groups.
|
||||||
func WithSupplementalGroups(gids []int64) ContainerOpts { //nolint:unused
|
func WithSupplementalGroups(gids []int64) ContainerOpts {
|
||||||
return func(c *runtime.ContainerConfig) {
|
return func(c *runtime.ContainerConfig) {
|
||||||
if c.Linux == nil {
|
if c.Linux == nil {
|
||||||
c.Linux = &runtime.LinuxContainerConfig{}
|
c.Linux = &runtime.LinuxContainerConfig{}
|
||||||
@ -335,7 +335,7 @@ func WithSupplementalGroups(gids []int64) ContainerOpts { //nolint:unused
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithDevice adds a device mount.
|
// WithDevice adds a device mount.
|
||||||
func WithDevice(containerPath, hostPath, permissions string) ContainerOpts { //nolint:unused
|
func WithDevice(containerPath, hostPath, permissions string) ContainerOpts {
|
||||||
return func(c *runtime.ContainerConfig) {
|
return func(c *runtime.ContainerConfig) {
|
||||||
c.Devices = append(c.Devices, &runtime.Device{
|
c.Devices = append(c.Devices, &runtime.Device{
|
||||||
ContainerPath: containerPath, HostPath: hostPath, Permissions: permissions,
|
ContainerPath: containerPath, HostPath: hostPath, Permissions: permissions,
|
||||||
@ -558,7 +558,7 @@ func CRIConfig() (*criconfig.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SandboxInfo gets sandbox info.
|
// SandboxInfo gets sandbox info.
|
||||||
func SandboxInfo(id string) (*runtime.PodSandboxStatus, *server.SandboxInfo, error) { //nolint:unused
|
func SandboxInfo(id string) (*runtime.PodSandboxStatus, *server.SandboxInfo, error) {
|
||||||
client, err := RawRuntimeClient()
|
client, err := RawRuntimeClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err)
|
return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err)
|
||||||
|
@ -76,7 +76,6 @@ func setLinux(s *Spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint
|
|
||||||
func setResources(s *Spec) {
|
func setResources(s *Spec) {
|
||||||
if s.Linux != nil {
|
if s.Linux != nil {
|
||||||
if s.Linux.Resources == nil {
|
if s.Linux.Resources == nil {
|
||||||
@ -85,7 +84,7 @@ func setResources(s *Spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint
|
//nolint:nolintlint,unused // not used on all platforms
|
||||||
func setResourcesWindows(s *Spec) {
|
func setResourcesWindows(s *Spec) {
|
||||||
if s.Windows != nil {
|
if s.Windows != nil {
|
||||||
if s.Windows.Resources == nil {
|
if s.Windows.Resources == nil {
|
||||||
@ -94,7 +93,7 @@ func setResourcesWindows(s *Spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint
|
//nolint:nolintlint,unused // not used on all platforms
|
||||||
func setCPU(s *Spec) {
|
func setCPU(s *Spec) {
|
||||||
setResources(s)
|
setResources(s)
|
||||||
if s.Linux != nil {
|
if s.Linux != nil {
|
||||||
@ -104,7 +103,7 @@ func setCPU(s *Spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint
|
//nolint:nolintlint,unused // not used on all platforms
|
||||||
func setCPUWindows(s *Spec) {
|
func setCPUWindows(s *Spec) {
|
||||||
setResourcesWindows(s)
|
setResourcesWindows(s)
|
||||||
if s.Windows != nil {
|
if s.Windows != nil {
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint:gosec
|
//nolint:gosec
|
||||||
func TestWithUserID(t *testing.T) {
|
func TestWithUserID(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gosec
|
//nolint:gosec
|
||||||
func TestWithUsername(t *testing.T) {
|
func TestWithUsername(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gosec
|
//nolint:gosec
|
||||||
func TestWithAdditionalGIDs(t *testing.T) {
|
func TestWithAdditionalGIDs(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
expectedPasswd := `root:x:0:0:root:/root:/bin/ash
|
expectedPasswd := `root:x:0:0:root:/root:/bin/ash
|
||||||
|
@ -28,19 +28,16 @@ import (
|
|||||||
|
|
||||||
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
|
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
|
||||||
// The capability set may differ from WithAllKnownCapabilities when running in a container.
|
// The capability set may differ from WithAllKnownCapabilities when running in a container.
|
||||||
// nolint: deadcode, unused
|
|
||||||
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||||
return WithCapabilities(nil)(ctx, client, c, s)
|
return WithCapabilities(nil)(ctx, client, c, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithAllKnownCapabilities sets all the known linux capabilities for the container process
|
// WithAllKnownCapabilities sets all the known linux capabilities for the container process
|
||||||
// nolint: deadcode, unused
|
|
||||||
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||||
return WithCapabilities(nil)(ctx, client, c, s)
|
return WithCapabilities(nil)(ctx, client, c, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithBlockIO sets the container's blkio parameters
|
// WithBlockIO sets the container's blkio parameters
|
||||||
// nolint: deadcode, unused
|
|
||||||
func WithBlockIO(blockio interface{}) SpecOpts {
|
func WithBlockIO(blockio interface{}) SpecOpts {
|
||||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||||
return errors.New("blkio not supported")
|
return errors.New("blkio not supported")
|
||||||
@ -48,7 +45,6 @@ func WithBlockIO(blockio interface{}) SpecOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithCPUShares sets the container's cpu shares
|
// WithCPUShares sets the container's cpu shares
|
||||||
// nolint: deadcode, unused
|
|
||||||
func WithCPUShares(shares uint64) SpecOpts {
|
func WithCPUShares(shares uint64) SpecOpts {
|
||||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -127,7 +127,7 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
|
|||||||
|
|
||||||
// TODO consider adding these consts to the OCI runtime-spec.
|
// TODO consider adding these consts to the OCI runtime-spec.
|
||||||
const (
|
const (
|
||||||
wildcardDevice = "a" //nolint // currently unused, but should be included when upstreaming to OCI runtime-spec.
|
wildcardDevice = "a" //nolint:nolintlint,unused,varcheck // currently unused, but should be included when upstreaming to OCI runtime-spec.
|
||||||
blockDevice = "b"
|
blockDevice = "b"
|
||||||
charDevice = "c" // or "u"
|
charDevice = "c" // or "u"
|
||||||
fifoDevice = "p"
|
fifoDevice = "p"
|
||||||
@ -148,7 +148,7 @@ func DeviceFromPath(path string) (*specs.LinuxDevice, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
devNumber = uint64(stat.Rdev) //nolint: unconvert // the type is 32bit on mips.
|
devNumber = uint64(stat.Rdev) //nolint:nolintlint,unconvert // the type is 32bit on mips.
|
||||||
major = unix.Major(devNumber)
|
major = unix.Major(devNumber)
|
||||||
minor = unix.Minor(devNumber)
|
minor = unix.Minor(devNumber)
|
||||||
)
|
)
|
||||||
|
@ -83,7 +83,7 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
|
|||||||
// if it fails but not RM snapshot data.
|
// if it fails but not RM snapshot data.
|
||||||
// refer to https://github.com/containerd/containerd/pull/1868
|
// refer to https://github.com/containerd/containerd/pull/1868
|
||||||
// https://github.com/containerd/containerd/pull/1785
|
// https://github.com/containerd/containerd/pull/1785
|
||||||
defer os.Remove(root) // nolint: errcheck
|
defer os.Remove(root)
|
||||||
|
|
||||||
unmounter := func(mountPath string) {
|
unmounter := func(mountPath string) {
|
||||||
if uerr := mount.Unmount(mountPath, 0); uerr != nil {
|
if uerr := mount.Unmount(mountPath, 0); uerr != nil {
|
||||||
|
@ -41,7 +41,7 @@ func (c *criService) ContainerStats(ctx context.Context, in *runtime.ContainerSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
|
cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (stats unimplemented)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
|
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
|
||||||
}
|
}
|
||||||
return &runtime.ContainerStatsResponse{Stats: cs}, nil
|
return &runtime.ContainerStatsResponse{Stats: cs}, nil
|
||||||
|
@ -58,7 +58,7 @@ func (c *criService) toCRIContainerStats(
|
|||||||
containerStats := new(runtime.ListContainerStatsResponse)
|
containerStats := new(runtime.ListContainerStatsResponse)
|
||||||
for _, cntr := range containers {
|
for _, cntr := range containers {
|
||||||
cs, err := c.containerMetrics(cntr.Metadata, statsMap[cntr.ID])
|
cs, err := c.containerMetrics(cntr.Metadata, statsMap[cntr.ID])
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (metrics unimplemented)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
|
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
|
||||||
}
|
}
|
||||||
containerStats.Stats = append(containerStats.Stats, cs)
|
containerStats.Stats = append(containerStats.Stats, cs)
|
||||||
|
@ -318,7 +318,7 @@ func (c *criService) getTLSConfig(registryTLSConfig criconfig.TLSConfig) (*tls.C
|
|||||||
if len(cert.Certificate) != 0 {
|
if len(cert.Certificate) != 0 {
|
||||||
tlsConfig.Certificates = []tls.Certificate{cert}
|
tlsConfig.Certificates = []tls.Certificate{cert}
|
||||||
}
|
}
|
||||||
tlsConfig.BuildNameToCertificate() // nolint:staticcheck
|
tlsConfig.BuildNameToCertificate() //nolint:staticcheck // TODO(thaJeztah): verify if we should ignore the deprecation; see https://github.com/containerd/containerd/pull/7349/files#r990644833
|
||||||
}
|
}
|
||||||
|
|
||||||
if registryTLSConfig.CAFile != "" {
|
if registryTLSConfig.CAFile != "" {
|
||||||
|
@ -34,12 +34,12 @@ func (c *criService) PodSandboxStats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
metrics, err := metricsForSandbox(sandbox)
|
metrics, err := metricsForSandbox(sandbox)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed getting metrics for sandbox %s: %w", r.GetPodSandboxId(), err)
|
return nil, fmt.Errorf("failed getting metrics for sandbox %s: %w", r.GetPodSandboxId(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
podSandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
podSandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode pod sandbox metrics %s: %w", r.GetPodSandboxId(), err)
|
return nil, fmt.Errorf("failed to decode pod sandbox metrics %s: %w", r.GetPodSandboxId(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,12 @@ func (c *criService) ListPodSandboxStats(
|
|||||||
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
|
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
|
||||||
for _, sandbox := range sandboxes {
|
for _, sandbox := range sandboxes {
|
||||||
metrics, err := metricsForSandbox(sandbox)
|
metrics, err := metricsForSandbox(sandbox)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to obtain metrics for sandbox %q: %w", sandbox.ID, err)
|
return nil, fmt.Errorf("failed to obtain metrics for sandbox %q: %w", sandbox.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
sandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err)
|
return nil, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err)
|
||||||
}
|
}
|
||||||
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
|
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
|
||||||
|
@ -117,7 +117,7 @@ type criService struct {
|
|||||||
baseOCISpecs map[string]*oci.Spec
|
baseOCISpecs map[string]*oci.Spec
|
||||||
// allCaps is the list of the capabilities.
|
// allCaps is the list of the capabilities.
|
||||||
// When nil, parsed from CapEff of /proc/self/status.
|
// When nil, parsed from CapEff of /proc/self/status.
|
||||||
allCaps []string // nolint
|
allCaps []string //nolint:nolintlint,unused // Ignore on non-Linux
|
||||||
// unpackDuplicationSuppressor is used to make sure that there is only
|
// unpackDuplicationSuppressor is used to make sure that there is only
|
||||||
// one in-flight fetch request or unpack handler for a given descriptor's
|
// one in-flight fetch request or unpack handler for a given descriptor's
|
||||||
// or chain ID.
|
// or chain ID.
|
||||||
|
@ -41,7 +41,7 @@ func (c *criService) ContainerStats(ctx context.Context, in *runtime.ContainerSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
|
cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (stats unimplemented)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
|
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
|
||||||
}
|
}
|
||||||
return &runtime.ContainerStatsResponse{Stats: cs}, nil
|
return &runtime.ContainerStatsResponse{Stats: cs}, nil
|
||||||
|
@ -61,7 +61,7 @@ func (c *criService) toCRIContainerStats(
|
|||||||
containerStats := new(runtime.ListContainerStatsResponse)
|
containerStats := new(runtime.ListContainerStatsResponse)
|
||||||
for _, cntr := range containers {
|
for _, cntr := range containers {
|
||||||
cs, err := c.containerMetrics(cntr.Metadata, statsMap[cntr.ID])
|
cs, err := c.containerMetrics(cntr.Metadata, statsMap[cntr.ID])
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (metrics unimplemented)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
|
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ func (c *criService) getTLSConfig(registryTLSConfig criconfig.TLSConfig) (*tls.C
|
|||||||
if len(cert.Certificate) != 0 {
|
if len(cert.Certificate) != 0 {
|
||||||
tlsConfig.Certificates = []tls.Certificate{cert}
|
tlsConfig.Certificates = []tls.Certificate{cert}
|
||||||
}
|
}
|
||||||
tlsConfig.BuildNameToCertificate() // nolint:staticcheck
|
tlsConfig.BuildNameToCertificate() //nolint:staticcheck // TODO(thaJeztah): verify if we should ignore the deprecation; see https://github.com/containerd/containerd/pull/7349/files#r990644833
|
||||||
}
|
}
|
||||||
|
|
||||||
if registryTLSConfig.CAFile != "" {
|
if registryTLSConfig.CAFile != "" {
|
||||||
|
@ -34,12 +34,12 @@ func (c *criService) PodSandboxStats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
metrics, err := metricsForSandbox(sandbox)
|
metrics, err := metricsForSandbox(sandbox)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed getting metrics for sandbox %s: %w", r.GetPodSandboxId(), err)
|
return nil, fmt.Errorf("failed getting metrics for sandbox %s: %w", r.GetPodSandboxId(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
podSandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
podSandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode pod sandbox metrics %s: %w", r.GetPodSandboxId(), err)
|
return nil, fmt.Errorf("failed to decode pod sandbox metrics %s: %w", r.GetPodSandboxId(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,12 @@ func (c *criService) ListPodSandboxStats(
|
|||||||
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
|
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
|
||||||
for _, sandbox := range sandboxes {
|
for _, sandbox := range sandboxes {
|
||||||
metrics, err := metricsForSandbox(sandbox)
|
metrics, err := metricsForSandbox(sandbox)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to obtain metrics for sandbox %q: %w", sandbox.ID, err)
|
return nil, fmt.Errorf("failed to obtain metrics for sandbox %q: %w", sandbox.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
sandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
|
||||||
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err)
|
return nil, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err)
|
||||||
}
|
}
|
||||||
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
|
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
|
||||||
|
@ -113,7 +113,7 @@ type criService struct {
|
|||||||
baseOCISpecs map[string]*oci.Spec
|
baseOCISpecs map[string]*oci.Spec
|
||||||
// allCaps is the list of the capabilities.
|
// allCaps is the list of the capabilities.
|
||||||
// When nil, parsed from CapEff of /proc/self/status.
|
// When nil, parsed from CapEff of /proc/self/status.
|
||||||
allCaps []string // nolint
|
allCaps []string //nolint:nolintlint,unused // Ignore on non-Linux
|
||||||
// unpackDuplicationSuppressor is used to make sure that there is only
|
// unpackDuplicationSuppressor is used to make sure that there is only
|
||||||
// one in-flight fetch request or unpack handler for a given descriptor's
|
// one in-flight fetch request or unpack handler for a given descriptor's
|
||||||
// or chain ID.
|
// or chain ID.
|
||||||
|
@ -208,6 +208,6 @@ func (s *Store) Delete(id string) {
|
|||||||
c.IO.Close()
|
c.IO.Close()
|
||||||
}
|
}
|
||||||
s.labels.Release(c.ProcessLabel)
|
s.labels.Release(c.ProcessLabel)
|
||||||
s.idIndex.Delete(id) // nolint: errcheck
|
s.idIndex.Delete(id)
|
||||||
delete(s.containers, id)
|
delete(s.containers, id)
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,9 @@ import (
|
|||||||
// 2) Metadata is checkpointed as containerd container label.
|
// 2) Metadata is checkpointed as containerd container label.
|
||||||
|
|
||||||
// metadataVersion is current version of container metadata.
|
// metadataVersion is current version of container metadata.
|
||||||
const metadataVersion = "v1" // nolint
|
const metadataVersion = "v1"
|
||||||
|
|
||||||
// versionedMetadata is the internal versioned container metadata.
|
// versionedMetadata is the internal versioned container metadata.
|
||||||
// nolint
|
|
||||||
type versionedMetadata struct {
|
type versionedMetadata struct {
|
||||||
// Version indicates the version of the versioned container metadata.
|
// Version indicates the version of the versioned container metadata.
|
||||||
Version string
|
Version string
|
||||||
|
@ -61,10 +61,9 @@ import (
|
|||||||
// DELETED
|
// DELETED
|
||||||
|
|
||||||
// statusVersion is current version of container status.
|
// statusVersion is current version of container status.
|
||||||
const statusVersion = "v1" // nolint
|
const statusVersion = "v1"
|
||||||
|
|
||||||
// versionedStatus is the internal used versioned container status.
|
// versionedStatus is the internal used versioned container status.
|
||||||
// nolint
|
|
||||||
type versionedStatus struct {
|
type versionedStatus struct {
|
||||||
// Version indicates the version of the versioned container status.
|
// Version indicates the version of the versioned container status.
|
||||||
Version string
|
Version string
|
||||||
|
@ -246,6 +246,6 @@ func (s *store) delete(id, ref string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Remove the image if it is not referenced any more.
|
// Remove the image if it is not referenced any more.
|
||||||
s.digestSet.Remove(digest) // nolint: errcheck
|
s.digestSet.Remove(digest)
|
||||||
delete(s.images, digest.String())
|
delete(s.images, digest.String())
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,9 @@ import (
|
|||||||
// 2) Metadata is checkpointed as containerd container label.
|
// 2) Metadata is checkpointed as containerd container label.
|
||||||
|
|
||||||
// metadataVersion is current version of sandbox metadata.
|
// metadataVersion is current version of sandbox metadata.
|
||||||
const metadataVersion = "v1" // nolint
|
const metadataVersion = "v1"
|
||||||
|
|
||||||
// versionedMetadata is the internal versioned sandbox metadata.
|
// versionedMetadata is the internal versioned sandbox metadata.
|
||||||
// nolint
|
|
||||||
type versionedMetadata struct {
|
type versionedMetadata struct {
|
||||||
// Version indicates the version of the versioned sandbox metadata.
|
// Version indicates the version of the versioned sandbox metadata.
|
||||||
Version string
|
Version string
|
||||||
|
@ -160,6 +160,6 @@ func (s *Store) Delete(id string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.labels.Release(s.sandboxes[id].ProcessLabel)
|
s.labels.Release(s.sandboxes[id].ProcessLabel)
|
||||||
s.idIndex.Delete(id) // nolint: errcheck
|
s.idIndex.Delete(id)
|
||||||
delete(s.sandboxes, id)
|
delete(s.sandboxes, id)
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func newNS(baseDir string) (nsPath string, err error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// Ensure the mount point is cleaned up on errors
|
// Ensure the mount point is cleaned up on errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(nsPath) // nolint: errcheck
|
os.RemoveAll(nsPath)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ func newNS(baseDir string) (nsPath string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Put this thread back to the orig ns, since it might get reused (pre go1.10)
|
// Put this thread back to the orig ns, since it might get reused (pre go1.10)
|
||||||
defer origNS.Set() // nolint: errcheck
|
defer origNS.Set()
|
||||||
|
|
||||||
// bind mount the netns from the current thread (from /proc) onto the
|
// bind mount the netns from the current thread (from /proc) onto the
|
||||||
// mount point. This causes the namespace to persist, even when there
|
// mount point. This causes the namespace to persist, even when there
|
||||||
@ -214,6 +214,6 @@ func (n *NetNS) Do(f func(cnins.NetNS) error) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get netns fd: %w", err)
|
return fmt.Errorf("get netns fd: %w", err)
|
||||||
}
|
}
|
||||||
defer ns.Close() // nolint: errcheck
|
defer ns.Close()
|
||||||
return ns.Do(f)
|
return ns.Do(f)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,6 @@ package progress
|
|||||||
const (
|
const (
|
||||||
escape = "\x1b"
|
escape = "\x1b"
|
||||||
reset = escape + "[0m"
|
reset = escape + "[0m"
|
||||||
red = escape + "[31m" // nolint: deadcode, varcheck, unused
|
red = escape + "[31m" //nolint:nolintlint,unused,varcheck
|
||||||
green = escape + "[32m"
|
green = escape + "[32m"
|
||||||
)
|
)
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package runtimeoptions_v1 //nolint
|
package runtimeoptions_v1 //nolint:revive // Ignore var-naming: don't use an underscore in package name (revive)
|
||||||
|
@ -24,7 +24,7 @@ set -eu -o pipefail
|
|||||||
go install github.com/containerd/protobuild@v0.2.0
|
go install github.com/containerd/protobuild@v0.2.0
|
||||||
go install github.com/containerd/protobuild/cmd/go-fix-acronym@v0.2.0
|
go install github.com/containerd/protobuild/cmd/go-fix-acronym@v0.2.0
|
||||||
go install github.com/cpuguy83/go-md2man/v2@v2.0.1
|
go install github.com/cpuguy83/go-md2man/v2@v2.0.1
|
||||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
|
||||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
||||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
||||||
go install github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@944ef4a40df3446714a823207972b7d9858ffac5
|
go install github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@944ef4a40df3446714a823207972b7d9858ffac5
|
||||||
|
@ -317,7 +317,11 @@ func (s *Server) ServeTTRPC(l net.Listener) error {
|
|||||||
func (s *Server) ServeMetrics(l net.Listener) error {
|
func (s *Server) ServeMetrics(l net.Listener) error {
|
||||||
m := http.NewServeMux()
|
m := http.NewServeMux()
|
||||||
m.Handle("/v1/metrics", metrics.Handler())
|
m.Handle("/v1/metrics", metrics.Handler())
|
||||||
return trapClosedConnErr(http.Serve(l, m))
|
srv := &http.Server{
|
||||||
|
Handler: m,
|
||||||
|
ReadHeaderTimeout: 5 * time.Minute, // "G112: Potential Slowloris Attack (gosec)"; not a real concern for our use, so setting a long timeout.
|
||||||
|
}
|
||||||
|
return trapClosedConnErr(srv.Serve(l))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeTCP allows services to serve over tcp
|
// ServeTCP allows services to serve over tcp
|
||||||
@ -337,7 +341,11 @@ func (s *Server) ServeDebug(l net.Listener) error {
|
|||||||
m.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
m.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||||
m.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
m.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||||
m.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
m.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||||
return trapClosedConnErr(http.Serve(l, m))
|
srv := &http.Server{
|
||||||
|
Handler: m,
|
||||||
|
ReadHeaderTimeout: 5 * time.Minute, // "G112: Potential Slowloris Attack (gosec)"; not a real concern for our use, so setting a long timeout.
|
||||||
|
}
|
||||||
|
return trapClosedConnErr(srv.Serve(l))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the containerd server canceling any open connections
|
// Stop the containerd server canceling any open connections
|
||||||
|
Loading…
Reference in New Issue
Block a user