Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ linters-settings:
- unnamedResult
- unnecessaryBlock
gocyclo:
min-complexity: 127
min-complexity: 140
nakedret:
max-func-lines: 15
2 changes: 1 addition & 1 deletion internal/config/cgmgr/cgmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

"github.com/containers/podman/v3/pkg/cgroups"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/server/cri/types"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/config/cgmgr/cgroupfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/server/cri/types"
libctr "github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/fs"
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
Expand All @@ -21,6 +20,7 @@ import (
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// CgroupfsManager defines functionality whrn **** TODO: Update this
Expand Down
14 changes: 7 additions & 7 deletions internal/config/cgmgr/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

"github.com/containers/podman/v3/pkg/cgroups"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/server/cri/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

func populateSandboxCgroupStatsFromPath(cgroupPath string, stats *types.PodSandboxStats) error {
Expand All @@ -22,9 +22,9 @@ func populateSandboxCgroupStatsFromPath(cgroupPath string, stats *types.PodSandb
return err
}
systemNano := time.Now().UnixNano()
stats.CPU = createCPUStats(systemNano, cgroupStats)
stats.Process = createProcessUsage(systemNano, cgroupStats)
stats.Memory, err = createMemoryStats(systemNano, cgroupStats, cgroupPath)
stats.Linux.Cpu = createCPUStats(systemNano, cgroupStats)
stats.Linux.Process = createProcessUsage(systemNano, cgroupStats)
stats.Linux.Memory, err = createMemoryStats(systemNano, cgroupStats, cgroupPath)
return err
}

Expand All @@ -35,7 +35,7 @@ func populateContainerCgroupStatsFromPath(cgroupPath string, stats *types.Contai
return err
}
systemNano := time.Now().UnixNano()
stats.CPU = createCPUStats(systemNano, cgroupStats)
stats.Cpu = createCPUStats(systemNano, cgroupStats)
stats.Memory, err = createMemoryStats(systemNano, cgroupStats, cgroupPath)
return err
}
Expand All @@ -49,8 +49,8 @@ func cgroupStatsFromPath(cgroupPath string) (*cgroups.Metrics, error) {
return cg.Stat()
}

func createCPUStats(systemNano int64, cgroupStats *cgroups.Metrics) *types.CPUUsage {
return &types.CPUUsage{
func createCPUStats(systemNano int64, cgroupStats *cgroups.Metrics) *types.CpuUsage {
return &types.CpuUsage{
Timestamp: systemNano,
UsageCoreNanoSeconds: &types.UInt64Value{Value: cgroupStats.CPU.Usage.Total},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/cgmgr/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"io/ioutil"

"github.com/cri-o/cri-o/internal/config/cgmgr"
"github.com/cri-o/cri-o/server/cri/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// The actual test suite
Expand Down
2 changes: 1 addition & 1 deletion internal/config/cgmgr/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/internal/dbusmgr"
"github.com/cri-o/cri-o/server/cri/types"
"github.com/cri-o/cri-o/utils"
"github.com/godbus/dbus/v5"
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

const defaultSystemdParent = "system.slice"
Expand Down
10 changes: 5 additions & 5 deletions internal/config/seccomp/seccomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"github.com/containers/common/pkg/seccomp"
"github.com/cri-o/cri-o/internal/log"
"github.com/cri-o/cri-o/server/cri/types"
json "github.com/json-iterator/go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
k8sV1 "k8s.io/api/core/v1"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// Config is the global seccomp configuration type
Expand Down Expand Up @@ -194,10 +194,10 @@ func (c *Config) setupFromField(
log.Debugf(ctx, "Setup seccomp from profile field: %+v", profileField)

if c.IsDisabled() {
if profileField.ProfileType != types.SecurityProfileTypeUnconfined &&
if profileField.ProfileType != types.SecurityProfile_Unconfined &&
// Kubernetes sandboxes run per default with `SecurityProfileTypeRuntimeDefault`:
// https://github.com/kubernetes/kubernetes/blob/629d5ab/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go#L155-L162
profileField.ProfileType != types.SecurityProfileTypeRuntimeDefault {
profileField.ProfileType != types.SecurityProfile_RuntimeDefault {
return errors.Errorf(
"seccomp is not enabled, cannot run with custom profile",
)
Expand All @@ -207,13 +207,13 @@ func (c *Config) setupFromField(
return nil
}

if profileField.ProfileType == types.SecurityProfileTypeUnconfined {
if profileField.ProfileType == types.SecurityProfile_Unconfined {
// running w/o seccomp, aka unconfined
specGenerator.Config.Linux.Seccomp = nil
return nil
}

if profileField.ProfileType == types.SecurityProfileTypeRuntimeDefault {
if profileField.ProfileType == types.SecurityProfile_RuntimeDefault {
linuxSpecs, err := seccomp.LoadProfileFromConfig(
c.Profile(), specGenerator.Config,
)
Expand Down
8 changes: 4 additions & 4 deletions internal/config/seccomp/seccomp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

containers_seccomp "github.com/containers/common/pkg/seccomp"
"github.com/cri-o/cri-o/internal/config/seccomp"
"github.com/cri-o/cri-o/server/cri/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opencontainers/runtime-tools/generate"
k8sV1 "k8s.io/api/core/v1"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// The actual test suite
Expand Down Expand Up @@ -149,7 +149,7 @@ var _ = t.Describe("Config", func() {
generator, err := generate.New("linux")
Expect(err).To(BeNil())
field := &types.SecurityProfile{
ProfileType: types.SecurityProfileTypeRuntimeDefault,
ProfileType: types.SecurityProfile_RuntimeDefault,
}

// When
Expand All @@ -170,7 +170,7 @@ var _ = t.Describe("Config", func() {
Expect(err).To(BeNil())
file := writeProfileFile()
field := &types.SecurityProfile{
ProfileType: types.SecurityProfileTypeLocalhost,
ProfileType: types.SecurityProfile_Localhost,
LocalhostRef: file,
}

Expand All @@ -191,7 +191,7 @@ var _ = t.Describe("Config", func() {
generator, err := generate.New("linux")
Expect(err).To(BeNil())
field := &types.SecurityProfile{
ProfileType: types.SecurityProfileTypeLocalhost,
ProfileType: types.SecurityProfile_Localhost,
LocalhostRef: "not-existing",
}

Expand Down
2 changes: 1 addition & 1 deletion internal/lib/container_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
"github.com/cri-o/cri-o/internal/storage"
crioann "github.com/cri-o/cri-o/pkg/annotations"
libconfig "github.com/cri-o/cri-o/pkg/config"
"github.com/cri-o/cri-o/server/cri/types"
json "github.com/json-iterator/go"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// ContainerManagerCRIO specifies an annotation value which indicates that the
Expand Down
2 changes: 1 addition & 1 deletion internal/lib/container_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/cri-o/cri-o/internal/lib"
"github.com/cri-o/cri-o/internal/oci"
libconfig "github.com/cri-o/cri-o/pkg/config"
"github.com/cri-o/cri-o/server/cri/types"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// The actual test suite
Expand Down
2 changes: 1 addition & 1 deletion internal/lib/sandbox/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/cri-o/cri-o/internal/hostport"
"github.com/cri-o/cri-o/internal/lib/sandbox"
"github.com/cri-o/cri-o/server/cri/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// The actual test suite
Expand Down
2 changes: 1 addition & 1 deletion internal/lib/sandbox/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (

"github.com/cri-o/cri-o/internal/config/nsmgr"
"github.com/cri-o/cri-o/internal/oci"
"github.com/cri-o/cri-o/server/cri/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
specs "github.com/opencontainers/runtime-spec/specs-go"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

const numNamespaces = 4
Expand Down
12 changes: 6 additions & 6 deletions internal/lib/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/cri-o/cri-o/internal/config/nsmgr"
"github.com/cri-o/cri-o/internal/hostport"
"github.com/cri-o/cri-o/internal/oci"
"github.com/cri-o/cri-o/server/cri/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
"k8s.io/apimachinery/pkg/fields"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// DevShmPath is the default system wide shared memory path
Expand Down Expand Up @@ -76,7 +76,7 @@ func New(id, namespace, name, kubeName, logDir string, labels, annotations map[s
sb := new(Sandbox)

sb.criSandbox = &types.PodSandbox{
ID: id,
Id: id,
CreatedAt: createdAt.UnixNano(),
Labels: labels,
Annotations: annotations,
Expand Down Expand Up @@ -147,7 +147,7 @@ func (s *Sandbox) IPs() []string {

// ID returns the id of the sandbox
func (s *Sandbox) ID() string {
return s.criSandbox.ID
return s.criSandbox.Id
}

// UsernsMode returns the mode for setting the user namespace, if any.
Expand Down Expand Up @@ -423,9 +423,9 @@ func (s *Sandbox) Created() bool {

func (s *Sandbox) State() types.PodSandboxState {
if s.Ready(false) {
return types.PodSandboxStateSandboxReady
return types.PodSandboxState_SANDBOX_READY
}
return types.PodSandboxStateSandboxNotReady
return types.PodSandboxState_SANDBOX_NOTREADY
}

// Ready returns whether the sandbox should be marked as ready to the kubelet
Expand Down Expand Up @@ -474,5 +474,5 @@ func (s *Sandbox) UnmountShm() error {
// If the server manages the namespace lifecycles, and the Pid option on the sandbox
// is node or container level, the infra container is not needed
func (s *Sandbox) NeedsInfra(serverDropsInfra bool) bool {
return !serverDropsInfra || s.nsOpts.Pid == types.NamespaceModePOD
return !serverDropsInfra || s.nsOpts.Pid == types.NamespaceMode_POD
}
10 changes: 5 additions & 5 deletions internal/lib/sandbox/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/cri-o/cri-o/internal/hostport"
"github.com/cri-o/cri-o/internal/lib/sandbox"
"github.com/cri-o/cri-o/internal/oci"
"github.com/cri-o/cri-o/server/cri/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// The actual test suite
Expand Down Expand Up @@ -274,7 +274,7 @@ var _ = t.Describe("Sandbox", func() {
// Given
manageNS := true
newNamespaceOption := &types.NamespaceOption{
Pid: types.NamespaceModeNODE,
Pid: types.NamespaceMode_NODE,
}

// When
Expand All @@ -288,7 +288,7 @@ var _ = t.Describe("Sandbox", func() {
// Given
manageNS := true
newNamespaceOption := &types.NamespaceOption{
Pid: types.NamespaceModeCONTAINER,
Pid: types.NamespaceMode_CONTAINER,
}

// When
Expand All @@ -302,7 +302,7 @@ var _ = t.Describe("Sandbox", func() {
// Given
manageNS := false
newNamespaceOption := &types.NamespaceOption{
Pid: types.NamespaceModePOD,
Pid: types.NamespaceMode_POD,
}

// When
Expand All @@ -316,7 +316,7 @@ var _ = t.Describe("Sandbox", func() {
// Given
manageNS := true
newNamespaceOption := &types.NamespaceOption{
Pid: types.NamespaceModeCONTAINER,
Pid: types.NamespaceMode_CONTAINER,
}

// When
Expand Down
2 changes: 1 addition & 1 deletion internal/lib/sandbox/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/cri-o/cri-o/internal/hostport"
"github.com/cri-o/cri-o/internal/lib/sandbox"
"github.com/cri-o/cri-o/server/cri/types"
. "github.com/cri-o/cri-o/test/framework"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
types "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// TestSandbox runs the created specs
Expand Down
Loading