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

Code Refactoring of Pod under pkg/api #112085

Merged
merged 4 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/api/v1/pod/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func FindPort(pod *v1.Pod, svcPort *v1.ServicePort) (int, error) {
type ContainerType int

const (
// Containers is for normal containers
// Containers are for normal containers
dipankardas011 marked this conversation as resolved.
Show resolved Hide resolved
Containers ContainerType = 1 << iota
// InitContainers is for init containers
InitContainers
Expand All @@ -61,7 +61,7 @@ const (
)

// AllContainers specifies that all containers be visited
const AllContainers ContainerType = (InitContainers | Containers | EphemeralContainers)
const AllContainers ContainerType = InitContainers | Containers | EphemeralContainers

// AllFeatureEnabledContainers returns a ContainerType mask which includes all container
// types except for the ones guarded by feature gate.
Expand Down Expand Up @@ -188,6 +188,7 @@ func VisitPodSecretNames(pod *v1.Pod, visitor Visitor) bool {
return true
}

// visitContainerSecretNames returns true if it finds reference to Secret in the container, otherwise false
dipankardas011 marked this conversation as resolved.
Show resolved Hide resolved
func visitContainerSecretNames(container *v1.Container, visitor Visitor) bool {
for _, env := range container.EnvFrom {
if env.SecretRef != nil {
Expand Down Expand Up @@ -236,6 +237,7 @@ func VisitPodConfigmapNames(pod *v1.Pod, visitor Visitor) bool {
return true
}

// visitContainerConfigmapNames returns true if it finds reference to ConfigMap in the container, otherwise false
dipankardas011 marked this conversation as resolved.
Show resolved Hide resolved
func visitContainerConfigmapNames(container *v1.Container, visitor Visitor) bool {
for _, env := range container.EnvFrom {
if env.ConfigMapRef != nil {
Expand Down Expand Up @@ -300,7 +302,7 @@ func IsPodTerminal(pod *v1.Pod) bool {
return IsPodPhaseTerminal(pod.Status.Phase)
}

// IsPhaseTerminal returns true if the pod's phase is terminal.
// IsPodPhaseTerminal returns true if the pod's phase is terminal.
func IsPodPhaseTerminal(phase v1.PodPhase) bool {
return phase == v1.PodFailed || phase == v1.PodSucceeded
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1/resource/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func MergeContainerResourceLimits(container *v1.Container,
if container.Resources.Limits == nil {
container.Resources.Limits = make(v1.ResourceList)
}
// NOTE: we exclude hugepages-* resources because hugepages are never overcommitted.
// NOTE: we exclude hugepages-* resources because hugepages are never over-committed.
dipankardas011 marked this conversation as resolved.
Show resolved Hide resolved
// This means that the container always has a limit specified.
for _, resource := range []v1.ResourceName{v1.ResourceCPU, v1.ResourceMemory, v1.ResourceEphemeralStorage} {
if quantity, exists := container.Resources.Limits[resource]; !exists || quantity.IsZero() {
Expand Down