Skip to content

Commit

Permalink
Add Sidekick Status Phase and BackOffLimit Api support
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <[email protected]>
  • Loading branch information
souravbiswassanto committed Oct 29, 2024
1 parent 87bd860 commit d192071
Show file tree
Hide file tree
Showing 19 changed files with 297 additions and 36 deletions.
1 change: 1 addition & 0 deletions .config/api-rules/violation_exceptions.list
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ API rule violation: names_match,k8s.io/apimachinery/pkg/util/intstr,IntOrString,
API rule violation: names_match,kmodules.xyz/client-go/api/v1,CertificateSpec,URIs
API rule violation: names_match,kmodules.xyz/client-go/api/v1,TimeOfDay,Time
API rule violation: names_match,kubeops.dev/sidekick/apis/apps/v1alpha1,SidekickSpec,DeprecatedServiceAccount
API rule violation: names_match,kubeops.dev/sidekick/apis/apps/v1alpha1,SidekickStatus,ContainerRestartCountsPerPod
1 change: 1 addition & 0 deletions apis/apps/fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package fuzzer

import (

Check failure on line 20 in apis/apps/fuzzer/fuzzer.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gofmt`-ed with `-s` (gofmt)
"kubeops.dev/sidekick/apis/apps/v1alpha1"

fuzz "github.com/google/gofuzz"
Expand Down
1 change: 1 addition & 0 deletions apis/apps/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package install

import (

Check failure on line 20 in apis/apps/install/install.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gofmt`-ed with `-s` (gofmt)
"kubeops.dev/sidekick/apis/apps/v1alpha1"

"k8s.io/apimachinery/pkg/runtime"
Expand Down
6 changes: 6 additions & 0 deletions apis/apps/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ package apps
const (
GroupName = "apps.k8s.appscode.com"
)

Check failure on line 22 in apis/apps/register.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gofmt`-ed with `-s` (gofmt)





30 changes: 30 additions & 0 deletions apis/apps/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion apis/apps/v1alpha1/sidekick_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ const (
PodSelectionPolicyLast LeaderSelectionPolicy = "Last"
)

// +kubebuilder:validation:Enum=Pending;Current;Failed;Succeeded
type SideKickPhase string

const (
SideKickPhaseCurrent SideKickPhase = "Current"
SideKickPhaseFailed SideKickPhase = "Failed"
SidekickPhaseSucceeded SideKickPhase = "Succeeded"
SideKickPhasePending SideKickPhase = "Pending"
)

type LeaderSpec struct {
Name string `json:"name,omitempty"`

Expand Down Expand Up @@ -102,6 +112,10 @@ type SidekickSpec struct {
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
// +optional
RestartPolicy core.RestartPolicy `json:"restartPolicy,omitempty"`
// Specifies the number of retries before marking this job failed.
// +optional
BackoffLimit *int32 `json:"backoffLimit,omitempty"`

// Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
// Value must be non-negative integer. The value zero indicates stop immediately via
// the kill signal (no opportunity to shut down).
Expand Down Expand Up @@ -529,14 +543,18 @@ type SidekickStatus struct {

// Specifies the current phase of the sidekick CR
// +optional
Phase string `json:"phase,omitempty"`
Phase SideKickPhase `json:"phase,omitempty"`
// observedGeneration is the most recent generation observed for this resource. It corresponds to the
// resource's generation, which is updated on mutation by the API Server.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Conditions applied to the database, such as approval or denial.
// +optional
Conditions []kmapi.Condition `json:"conditions,omitempty"`
// ContainerRestartCountsPerPod stores the sum of all container restart counts of a pod
ContainerRestartCountsPerPod map[string]int32 `json:"containerRestartCountPerPod,omitempty"`
// FailuerCount tracks the total number of failed pods
FailureCount *int32 `json:"failureCount,omitempty"`
}

// +genclient
Expand Down
17 changes: 17 additions & 0 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions client/clientset/versioned/typed/apps/v1alpha1/sidekick.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions crds/apps.k8s.appscode.com_sidekicks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,11 @@ spec:
description: AutomountServiceAccountToken indicates whether a service
account token should be automatically mounted.
type: boolean
backoffLimit:
description: Specifies the number of retries before marking this job
failed.
format: int32
type: integer
containers:
description: List of containers belonging to the pod. Containers cannot
currently be added or removed. There must be at least one container
Expand Down Expand Up @@ -7659,6 +7664,17 @@ spec:
- type
type: object
type: array
containerRestartCountPerPod:
additionalProperties:
format: int32
type: integer
description: ContainerRestartCountsPerPod stores the sum of all container
restart counts of a pod
type: object
failureCount:
description: FailuerCount tracks the total number of failed pods
format: int32
type: integer
leader:
properties:
name:
Expand All @@ -7674,6 +7690,11 @@ spec:
type: integer
phase:
description: Specifies the current phase of the sidekick CR
enum:
- Pending
- Current
- Failed
- Succeeded
type: string
pod:
description: PodPhase is a label for the condition of a pod at the
Expand Down
Loading

0 comments on commit d192071

Please sign in to comment.