Merge pull request #5180 from dmcgowan/lint-enforce-comments

Fix exported comments enforcer in CI
This commit is contained in:
Phil Estes 2021-03-15 10:50:06 -04:00 committed by GitHub
commit a1138182d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 148 additions and 46 deletions

View File

@ -14,6 +14,10 @@ linters:
disable: disable:
- errcheck - errcheck
issues:
include:
- EXC0002
run: run:
timeout: 3m timeout: 3m
skip-dirs: skip-dirs:

View File

@ -720,10 +720,12 @@ func (c *Client) Version(ctx context.Context) (Version, error) {
}, nil }, nil
} }
// ServerInfo represents the introspected server information
type ServerInfo struct { type ServerInfo struct {
UUID string UUID string
} }
// Server returns server information from the introspection service
func (c *Client) Server(ctx context.Context) (ServerInfo, error) { func (c *Client) Server(ctx context.Context) (ServerInfo, error) {
c.connMu.Lock() c.connMu.Lock()
if c.conn == nil { if c.conn == nil {
@ -789,6 +791,8 @@ func CheckRuntime(current, expected string) bool {
return true return true
} }
// GetSnapshotterSupportedPlatforms returns a platform matchers which represents the
// supported platforms for the given snapshotters
func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshotterName string) (platforms.MatchComparer, error) { func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshotterName string) (platforms.MatchComparer, error) {
filters := []string{fmt.Sprintf("type==%s, id==%s", plugin.SnapshotPlugin, snapshotterName)} filters := []string{fmt.Sprintf("type==%s, id==%s", plugin.SnapshotPlugin, snapshotterName)}
in := c.IntrospectionService() in := c.IntrospectionService()

View File

@ -198,6 +198,8 @@ func Fetch(ctx context.Context, client *containerd.Client, ref string, config *F
return img, nil return img, nil
} }
// ShowProgress continuously updates the output with job progress
// by checking status in the content store.
func ShowProgress(ctx context.Context, ongoing *Jobs, cs content.Store, out io.Writer) { func ShowProgress(ctx context.Context, ongoing *Jobs, cs content.Store, out io.Writer) {
var ( var (
ticker = time.NewTicker(100 * time.Millisecond) ticker = time.NewTicker(100 * time.Millisecond)
@ -328,6 +330,7 @@ type Jobs struct {
resolved bool resolved bool
} }
// NewJobs creates a new instance of the job status tracker
func NewJobs(name string) *Jobs { func NewJobs(name string) *Jobs {
return &Jobs{ return &Jobs{
name: name, name: name,
@ -335,6 +338,7 @@ func NewJobs(name string) *Jobs {
} }
} }
// Add adds a descriptor to be tracked
func (j *Jobs) Add(desc ocispec.Descriptor) { func (j *Jobs) Add(desc ocispec.Descriptor) {
j.mu.Lock() j.mu.Lock()
defer j.mu.Unlock() defer j.mu.Unlock()
@ -347,6 +351,7 @@ func (j *Jobs) Add(desc ocispec.Descriptor) {
j.added[desc.Digest] = struct{}{} j.added[desc.Digest] = struct{}{}
} }
// Jobs returns a list of all tracked descriptors
func (j *Jobs) Jobs() []ocispec.Descriptor { func (j *Jobs) Jobs() []ocispec.Descriptor {
j.mu.Lock() j.mu.Lock()
defer j.mu.Unlock() defer j.mu.Unlock()
@ -355,6 +360,7 @@ func (j *Jobs) Jobs() []ocispec.Descriptor {
return append(descs, j.descs...) return append(descs, j.descs...)
} }
// IsResolved checks whether a descriptor has been resolved
func (j *Jobs) IsResolved() bool { func (j *Jobs) IsResolved() bool {
j.mu.Lock() j.mu.Lock()
defer j.mu.Unlock() defer j.mu.Unlock()

View File

@ -25,6 +25,7 @@ import (
"github.com/containerd/containerd/oci" "github.com/containerd/containerd/oci"
) )
// Command is the parent for all OCI related tools under 'oci'
var Command = cli.Command{ var Command = cli.Command{
Name: "oci", Name: "oci",
Usage: "OCI tools", Usage: "OCI tools",

View File

@ -22,7 +22,7 @@ import (
"github.com/containerd/containerd/filters" "github.com/containerd/containerd/filters"
) )
// AdoptInfo returns `filters.Adaptor` that handles `content.Info`. // AdaptInfo returns `filters.Adaptor` that handles `content.Info`.
func AdaptInfo(info Info) filters.Adaptor { func AdaptInfo(info Info) filters.Adaptor {
return filters.AdapterFunc(func(fieldpath []string) (string, bool) { return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
if len(fieldpath) == 0 { if len(fieldpath) == 0 {

View File

@ -81,7 +81,7 @@ func LoadDefaultProfile(name string) error {
return nil return nil
} }
// DumpDefaultProfiles dumps the default profile with the given name. // DumpDefaultProfile dumps the default profile with the given name.
func DumpDefaultProfile(name string) (string, error) { func DumpDefaultProfile(name string) (string, error) {
p, err := loadData(name) p, err := loadData(name)
if err != nil { if err != nil {

View File

@ -168,6 +168,10 @@ func (c *compressedProcessor) Close() error {
return c.rc.Close() return c.rc.Close()
} }
// BinaryHandler creates a new stream processor handler which calls out to the given binary.
// The id is used to identify the stream processor and allows the caller to send
// payloads specific for that stream processor (i.e. decryption keys for decrypt stream processor).
// The binary will be called for the provided mediaTypes and return the given media type.
func BinaryHandler(id, returnsMediaType string, mediaTypes []string, path string, args, env []string) Handler { func BinaryHandler(id, returnsMediaType string, mediaTypes []string, path string, args, env []string) Handler {
set := make(map[string]struct{}, len(mediaTypes)) set := make(map[string]struct{}, len(mediaTypes))
for _, m := range mediaTypes { for _, m := range mediaTypes {

View File

@ -348,6 +348,7 @@ func clearDockerV1DummyID(cfg DualConfig) (bool, error) {
return modified, nil return modified, nil
} }
// ObjectWithMediaType represents an object with a MediaType field
type ObjectWithMediaType struct { type ObjectWithMediaType struct {
// MediaType appears on Docker manifests and manifest lists. // MediaType appears on Docker manifests and manifest lists.
// MediaType does not appear on OCI manifests and index // MediaType does not appear on OCI manifests and index

View File

@ -91,6 +91,8 @@ func LayerConvertFunc(ctx context.Context, cs content.Store, desc ocispec.Descri
return &newDesc, nil return &newDesc, nil
} }
// IsUncompressedType returns whether the provided media type is considered
// an uncompressed layer type
func IsUncompressedType(mt string) bool { func IsUncompressedType(mt string) bool {
switch mt { switch mt {
case case

View File

@ -551,6 +551,7 @@ func (r *RuntimeService) ContainerStats(containerID string) (*runtimeapi.Contain
return resp.GetStats(), nil return resp.GetStats(), nil
} }
// ListContainerStats lists all container stats given the provided filter
func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) { func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) {
klog.V(10).Infof("[RuntimeService] ListContainerStats (filter=%v)", filter) klog.V(10).Infof("[RuntimeService] ListContainerStats (filter=%v)", filter)
// Do not set timeout, because writable layer stats collection takes time. // Do not set timeout, because writable layer stats collection takes time.
@ -570,6 +571,7 @@ func (r *RuntimeService) ListContainerStats(filter *runtimeapi.ContainerStatsFil
return resp.GetStats(), nil return resp.GetStats(), nil
} }
// ReopenContainerLog reopens the container log for the given container ID
func (r *RuntimeService) ReopenContainerLog(containerID string) error { func (r *RuntimeService) ReopenContainerLog(containerID string) error {
klog.V(10).Infof("[RuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)", containerID, r.timeout) klog.V(10).Infof("[RuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)", containerID, r.timeout)
ctx, cancel := getContextWithTimeout(r.timeout) ctx, cancel := getContextWithTimeout(r.timeout)

View File

@ -186,7 +186,7 @@ func removeLoop(loopdev string) error {
return err return err
} }
// Attach a specified backing file to a loop device // AttachLoopDevice attaches a specified backing file to a loop device
func AttachLoopDevice(backingFile string) (string, error) { func AttachLoopDevice(backingFile string) (string, error) {
file, err := setupLoop(backingFile, LoopParams{}) file, err := setupLoop(backingFile, LoopParams{})
if err != nil { if err != nil {
@ -196,7 +196,7 @@ func AttachLoopDevice(backingFile string) (string, error) {
return file.Name(), nil return file.Name(), nil
} }
// Detach a loop device // DetachLoopDevice detaches the provided loop devices
func DetachLoopDevice(devices ...string) error { func DetachLoopDevice(devices ...string) error {
for _, dev := range devices { for _, dev := range devices {
if err := removeLoop(dev); err != nil { if err := removeLoop(dev); err != nil {

View File

@ -1172,8 +1172,6 @@ func WithLinuxDevices(devices []specs.LinuxDevice) SpecOpts {
} }
} }
var ErrNotADevice = errors.New("not a device node")
// WithLinuxDevice adds the device specified by path to the spec // WithLinuxDevice adds the device specified by path to the spec
func WithLinuxDevice(path, permissions string) SpecOpts { func WithLinuxDevice(path, permissions string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error { return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {

View File

@ -27,6 +27,7 @@ import (
"github.com/containerd/containerd/containers" "github.com/containerd/containerd/containers"
"github.com/containerd/containerd/pkg/cap" "github.com/containerd/containerd/pkg/cap"
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -42,6 +43,8 @@ func WithHostDevices(_ context.Context, _ Client, _ *containers.Container, s *Sp
return nil return nil
} }
var errNotADevice = errors.New("not a device node")
func getDevices(path string) ([]specs.LinuxDevice, error) { func getDevices(path string) ([]specs.LinuxDevice, error) {
files, err := ioutil.ReadDir(path) files, err := ioutil.ReadDir(path)
if err != nil { if err != nil {
@ -70,7 +73,7 @@ func getDevices(path string) ([]specs.LinuxDevice, error) {
} }
device, err := deviceFromPath(filepath.Join(path, f.Name()), "rwm") device, err := deviceFromPath(filepath.Join(path, f.Name()), "rwm")
if err != nil { if err != nil {
if err == ErrNotADevice { if err == errNotADevice {
continue continue
} }
if os.IsNotExist(err) { if os.IsNotExist(err) {
@ -96,7 +99,7 @@ func deviceFromPath(path, permissions string) (*specs.LinuxDevice, error) {
minor = unix.Minor(devNumber) minor = unix.Minor(devNumber)
) )
if major == 0 { if major == 0 {
return nil, ErrNotADevice return nil, errNotADevice
} }
var ( var (

View File

@ -26,6 +26,7 @@ import (
"github.com/containerd/containerd/containers" "github.com/containerd/containerd/containers"
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -41,6 +42,8 @@ func WithHostDevices(_ context.Context, _ Client, _ *containers.Container, s *Sp
return nil return nil
} }
var errNotADevice = errors.New("not a device node")
func getDevices(path string) ([]specs.LinuxDevice, error) { func getDevices(path string) ([]specs.LinuxDevice, error) {
files, err := ioutil.ReadDir(path) files, err := ioutil.ReadDir(path)
if err != nil { if err != nil {
@ -69,7 +72,7 @@ func getDevices(path string) ([]specs.LinuxDevice, error) {
} }
device, err := deviceFromPath(filepath.Join(path, f.Name()), "rwm") device, err := deviceFromPath(filepath.Join(path, f.Name()), "rwm")
if err != nil { if err != nil {
if err == ErrNotADevice { if err == errNotADevice {
continue continue
} }
if os.IsNotExist(err) { if os.IsNotExist(err) {
@ -94,7 +97,7 @@ func deviceFromPath(path, permissions string) (*specs.LinuxDevice, error) {
minor = unix.Minor(devNumber) minor = unix.Minor(devNumber)
) )
if major == 0 { if major == 0 {
return nil, ErrNotADevice return nil, errNotADevice
} }
var ( var (

View File

@ -1,5 +1,3 @@
// +build linux
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.
@ -18,31 +16,12 @@
package apparmor package apparmor
import ( // HostSupports returns true if apparmor is enabled for the host, // On non-Linux returns false
"io/ioutil" // On Linux returns true if apparmor_parser is enabled, and if we
"os" // are not running docker-in-docker.
"sync"
)
var (
appArmorSupported bool
checkAppArmor sync.Once
)
// HostSupports returns true if apparmor is enabled for the host, if
// apparmor_parser is enabled, and if we are not running docker-in-docker.
// //
// It is a modified version of libcontainer/apparmor.IsEnabled(), which does not // It is a modified version of libcontainer/apparmor.IsEnabled(), which does not
// check for apparmor_parser to be present, or if we're running docker-in-docker. // check for apparmor_parser to be present, or if we're running docker-in-docker.
func HostSupports() bool { func HostSupports() bool {
checkAppArmor.Do(func() { return hostSupports()
// see https://github.com/docker/docker/commit/de191e86321f7d3136ff42ff75826b8107399497
if _, err := os.Stat("/sys/kernel/security/apparmor"); err == nil && os.Getenv("container") == "" {
if _, err = os.Stat("/sbin/apparmor_parser"); err == nil {
buf, err := ioutil.ReadFile("/sys/module/apparmor/parameters/enabled")
appArmorSupported = err == nil && len(buf) > 1 && buf[0] == 'Y'
}
}
})
return appArmorSupported
} }

View File

@ -0,0 +1,48 @@
// +build linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package apparmor
import (
"io/ioutil"
"os"
"sync"
)
var (
appArmorSupported bool
checkAppArmor sync.Once
)
// hostSupports returns true if apparmor is enabled for the host, if
// apparmor_parser is enabled, and if we are not running docker-in-docker.
//
// It is a modified version of libcontainer/apparmor.IsEnabled(), which does not
// check for apparmor_parser to be present, or if we're running docker-in-docker.
func hostSupports() bool {
checkAppArmor.Do(func() {
// see https://github.com/docker/docker/commit/de191e86321f7d3136ff42ff75826b8107399497
if _, err := os.Stat("/sys/kernel/security/apparmor"); err == nil && os.Getenv("container") == "" {
if _, err = os.Stat("/sbin/apparmor_parser"); err == nil {
buf, err := ioutil.ReadFile("/sys/module/apparmor/parameters/enabled")
appArmorSupported = err == nil && len(buf) > 1 && buf[0] == 'Y'
}
}
})
return appArmorSupported
}

View File

@ -18,7 +18,6 @@
package apparmor package apparmor
//nolint: deadcode, unused func hostSupports() bool {
func HostSupports() bool {
return false return false
} }

View File

@ -65,7 +65,7 @@ type Type int
const ( const (
// Effective is CapEff // Effective is CapEff
Effective Type = 1 << iota Effective Type = 1 << iota
// Effective is CapPrm // Permitted is CapPrm
Permitted Permitted
// Inheritable is CapInh // Inheritable is CapInh
Inheritable Inheritable

View File

@ -22,6 +22,7 @@ import (
"github.com/opencontainers/selinux/go-selinux" "github.com/opencontainers/selinux/go-selinux"
) )
// Store is used to store SELinux process labels
type Store struct { type Store struct {
sync.Mutex sync.Mutex
levels map[string]int levels map[string]int
@ -29,6 +30,7 @@ type Store struct {
Reserver func(string) Reserver func(string)
} }
// NewStore creates a new SELinux process label store
func NewStore() *Store { func NewStore() *Store {
return &Store{ return &Store{
levels: map[string]int{}, levels: map[string]int{},
@ -37,6 +39,8 @@ func NewStore() *Store {
} }
} }
// Reserve reserves the MLS/MCS level component of the specified label
// and prevents multiple reserves for the same level
func (s *Store) Reserve(label string) error { func (s *Store) Reserve(label string) error {
s.Lock() s.Lock()
defer s.Unlock() defer s.Unlock()
@ -60,6 +64,9 @@ func (s *Store) Reserve(label string) error {
return nil return nil
} }
// Release un-reserves the MLS/MCS level component of the specified label,
// allowing it to be used by another process once labels with the same
// level have been released.
func (s *Store) Release(label string) { func (s *Store) Release(label string) {
s.Lock() s.Lock()
defer s.Unlock() defer s.Unlock()

25
pkg/seccomp/seccomp.go Normal file
View File

@ -0,0 +1,25 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package seccomp
// IsEnabled returns whether seccomp support is enabled
// On Linux returns if the kernel has been configured to support seccomp.
// From https://github.com/opencontainers/runc/blob/v1.0.0-rc91/libcontainer/seccomp/seccomp_linux.go#L86-L102
// On non-Linux returns false
func IsEnabled() bool {
return isEnabled()
}

View File

@ -40,9 +40,9 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
// IsEnabled returns if the kernel has been configured to support seccomp. // isEnabled returns if the kernel has been configured to support seccomp.
// From https://github.com/opencontainers/runc/blob/v1.0.0-rc91/libcontainer/seccomp/seccomp_linux.go#L86-L102 // From https://github.com/opencontainers/runc/blob/v1.0.0-rc91/libcontainer/seccomp/seccomp_linux.go#L86-L102
func IsEnabled() bool { func isEnabled() bool {
// Try to read from /proc/self/status for kernels > 3.8 // Try to read from /proc/self/status for kernels > 3.8
s, err := parseStatusFile("/proc/self/status") s, err := parseStatusFile("/proc/self/status")
if err != nil { if err != nil {

View File

@ -18,6 +18,6 @@
package seccomp package seccomp
func IsEnabled() bool { func isEnabled() bool {
return false return false
} }

View File

@ -14,7 +14,7 @@
limitations under the License. limitations under the License.
*/ */
// config package containers utilities for helping configure the Docker resolver // Package config contains utilities for helping configure the Docker resolver
package config package config
import ( import (

View File

@ -56,6 +56,7 @@ const (
// Reserved for future capabilities (i.e. search, catalog, remove) // Reserved for future capabilities (i.e. search, catalog, remove)
) )
// Has checks whether the capabilities list has the provide capability
func (c HostCapabilities) Has(t HostCapabilities) bool { func (c HostCapabilities) Has(t HostCapabilities) bool {
return c&t == t return c&t == t
} }

View File

@ -41,6 +41,7 @@ type item struct {
count int count int
} }
// NewPublisher creates a new remote events publisher
func NewPublisher(address string) (*RemoteEventsPublisher, error) { func NewPublisher(address string) (*RemoteEventsPublisher, error) {
client, err := ttrpcutil.NewClient(address) client, err := ttrpcutil.NewClient(address)
if err != nil { if err != nil {
@ -57,6 +58,7 @@ func NewPublisher(address string) (*RemoteEventsPublisher, error) {
return l, nil return l, nil
} }
// RemoteEventsPublisher forwards events to a ttrpc server
type RemoteEventsPublisher struct { type RemoteEventsPublisher struct {
client *ttrpcutil.Client client *ttrpcutil.Client
closed chan struct{} closed chan struct{}
@ -64,10 +66,12 @@ type RemoteEventsPublisher struct {
requeue chan *item requeue chan *item
} }
// Done returns a channel which closes when done
func (l *RemoteEventsPublisher) Done() <-chan struct{} { func (l *RemoteEventsPublisher) Done() <-chan struct{} {
return l.closed return l.closed
} }
// Close closes the remote connection and closes the done channel
func (l *RemoteEventsPublisher) Close() (err error) { func (l *RemoteEventsPublisher) Close() (err error) {
err = l.client.Close() err = l.client.Close()
l.closer.Do(func() { l.closer.Do(func() {
@ -100,6 +104,7 @@ func (l *RemoteEventsPublisher) queue(i *item) {
}() }()
} }
// Publish publishes the event by forwarding it to the configured ttrpc server
func (l *RemoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error { func (l *RemoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error {
ns, err := namespaces.NamespaceRequired(ctx) ns, err := namespaces.NamespaceRequired(ctx)
if err != nil { if err != nil {

View File

@ -87,6 +87,7 @@ func AnonDialer(address string, timeout time.Duration) (net.Conn, error) {
return dialer.Dialer(socket(address).path(), timeout) return dialer.Dialer(socket(address).path(), timeout)
} }
// AnonReconnectDialer returns a dialer for an existing socket on reconnection
func AnonReconnectDialer(address string, timeout time.Duration) (net.Conn, error) { func AnonReconnectDialer(address string, timeout time.Duration) (net.Conn, error) {
return AnonDialer(address, timeout) return AnonDialer(address, timeout)
} }

View File

@ -34,4 +34,4 @@ GO111MODULE=off go get -d github.com/gogo/googleapis || true
GO111MODULE=off go get -d github.com/gogo/protobuf || true GO111MODULE=off go get -d github.com/gogo/protobuf || true
GO111MODULE=on go get github.com/cpuguy83/go-md2man/v2@v2.0.0 GO111MODULE=on go get github.com/cpuguy83/go-md2man/v2@v2.0.0
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.8 GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.38.0

View File

@ -25,6 +25,7 @@ import (
ptypes "github.com/gogo/protobuf/types" ptypes "github.com/gogo/protobuf/types"
) )
// Service defines the instrospection service interface
type Service interface { type Service interface {
Plugins(context.Context, []string) (*api.PluginsResponse, error) Plugins(context.Context, []string) (*api.PluginsResponse, error)
Server(context.Context, *ptypes.Empty) (*api.ServerResponse, error) Server(context.Context, *ptypes.Empty) (*api.ServerResponse, error)
@ -36,6 +37,7 @@ type introspectionRemote struct {
var _ = (Service)(&introspectionRemote{}) var _ = (Service)(&introspectionRemote{})
// NewIntrospectionServiceFromClient creates a new introspection service from an API client
func NewIntrospectionServiceFromClient(c api.IntrospectionClient) Service { func NewIntrospectionServiceFromClient(c api.IntrospectionClient) Service {
return &introspectionRemote{client: c} return &introspectionRemote{client: c}
} }

View File

@ -54,6 +54,7 @@ func init() {
}) })
} }
// Local is a local implementation of the introspection service
type Local struct { type Local struct {
mu sync.Mutex mu sync.Mutex
plugins []api.Plugin plugins []api.Plugin
@ -62,6 +63,7 @@ type Local struct {
var _ = (api.IntrospectionClient)(&Local{}) var _ = (api.IntrospectionClient)(&Local{})
// UpdateLocal updates the local introspection service
func (l *Local) UpdateLocal(root string, plugins []api.Plugin) { func (l *Local) UpdateLocal(root string, plugins []api.Plugin) {
l.mu.Lock() l.mu.Lock()
defer l.mu.Unlock() defer l.mu.Unlock()
@ -69,6 +71,7 @@ func (l *Local) UpdateLocal(root string, plugins []api.Plugin) {
l.plugins = plugins l.plugins = plugins
} }
// Plugins returns the locally defined plugins
func (l *Local) Plugins(ctx context.Context, req *api.PluginsRequest, _ ...grpc.CallOption) (*api.PluginsResponse, error) { func (l *Local) Plugins(ctx context.Context, req *api.PluginsRequest, _ ...grpc.CallOption) (*api.PluginsResponse, error) {
filter, err := filters.ParseAll(req.Filters...) filter, err := filters.ParseAll(req.Filters...)
if err != nil { if err != nil {
@ -96,6 +99,7 @@ func (l *Local) getPlugins() []api.Plugin {
return l.plugins return l.plugins
} }
// Server returns the local server information
func (l *Local) Server(ctx context.Context, _ *ptypes.Empty, _ ...grpc.CallOption) (*api.ServerResponse, error) { func (l *Local) Server(ctx context.Context, _ *ptypes.Empty, _ ...grpc.CallOption) (*api.ServerResponse, error) {
u, err := l.getUUID() u, err := l.getUUID()
if err != nil { if err != nil {

View File

@ -395,6 +395,7 @@ func (p *PoolDevice) SuspendDevice(ctx context.Context, deviceName string) error
return nil return nil
} }
// ResumeDevice resumes IO for the given device
func (p *PoolDevice) ResumeDevice(ctx context.Context, deviceName string) error { func (p *PoolDevice) ResumeDevice(ctx context.Context, deviceName string) error {
if err := p.transition(ctx, deviceName, Resuming, Resumed, func() error { if err := p.transition(ctx, deviceName, Resuming, Resumed, func() error {
return dmsetup.ResumeDevice(deviceName) return dmsetup.ResumeDevice(deviceName)

View File

@ -482,6 +482,7 @@ func (s *Snapshotter) withTransaction(ctx context.Context, writable bool, fn fun
return nil return nil
} }
// Cleanup cleans up all removed and unused resources
func (s *Snapshotter) Cleanup(ctx context.Context) error { func (s *Snapshotter) Cleanup(ctx context.Context) error {
var removedDevices []*DeviceInfo var removedDevices []*DeviceInfo

View File

@ -28,7 +28,8 @@ import (
const ( const (
// UnpackKeyPrefix is the beginning of the key format used for snapshots that will have // UnpackKeyPrefix is the beginning of the key format used for snapshots that will have
// image content unpacked into them. // image content unpacked into them.
UnpackKeyPrefix = "extract" UnpackKeyPrefix = "extract"
// UnpackKeyFormat is the format for the snapshotter keys used for extraction
UnpackKeyFormat = UnpackKeyPrefix + "-%s %s" UnpackKeyFormat = UnpackKeyPrefix + "-%s %s"
inheritedLabelsPrefix = "containerd.io/snapshot/" inheritedLabelsPrefix = "containerd.io/snapshot/"
labelSnapshotRef = "containerd.io/snapshot.ref" labelSnapshotRef = "containerd.io/snapshot.ref"