Skip to content

Commit

Permalink
feat: Add count-based checkpoint retention policies
Browse files Browse the repository at this point in the history
- Introduced global, container, pod, and namespace-level
  policies for checkpoint retention, all based on count limits.
- Updated CRD definitions to store the newly added policies.
- Added a flag `applyPoliciesImmediately` to enable immediate
  application of policies upon their update or creation.
- Implemented logic to prioritize container, pod, and
  namespace-specific policies over global policies.

Signed-off-by: Parthiba-Hazra <[email protected]>
  • Loading branch information
Parthiba-Hazra committed Jun 24, 2024
1 parent b58ffc3 commit e668f80
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 65 deletions.
32 changes: 30 additions & 2 deletions api/v1/checkpointrestoreoperator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,36 @@ import (
// CheckpointRestoreOperatorSpec defines the desired state of CheckpointRestoreOperator
type CheckpointRestoreOperatorSpec struct {
// Important: Run "make" to regenerate code after modifying this file
CheckpointDirectory string `json:"checkpointDirectory,omitempty"`
MaxCheckpointsPerContainer *int `json:"maxCheckpointsPerContainer,omitempty"`
CheckpointDirectory string `json:"checkpointDirectory,omitempty"`
ApplyPoliciesImmediately bool `json:"applyPoliciesImmediately,omitempty"`
GlobalPolicies GlobalPolicySpec `json:"globalPolicy,omitempty"`
ContainerPolicies []ContainerPolicySpec `json:"containerPolicies,omitempty"`
PodPolicies []PodPolicySpec `json:"podPolicies,omitempty"`
NamespacePolicies []NamespacePolicySpec `json:"namespacePolicies,omitempty"`
}

type GlobalPolicySpec struct {
MaxCheckpointsPerNamespaces *int `json:"maxCheckpointsPerNamespace,omitempty"`
MaxCheckpointsPerPod *int `json:"maxCheckpointsPerPod,omitempty"`
MaxCheckpointsPerContainer *int `json:"maxCheckpointsPerContainer,omitempty"`
}

type ContainerPolicySpec struct {
Namespace string `json:"namespace,omitempty"`
Pod string `json:"pod,omitempty"`
Container string `json:"container,omitempty"`
MaxCheckpoints *int64 `json:"maxCheckpoints,omitempty"`
}

type PodPolicySpec struct {
Namespace string `json:"namespace,omitempty"`
Pod string `json:"pod,omitempty"`
MaxCheckpoints *int64 `json:"maxCheckpoints,omitempty"`
}

type NamespacePolicySpec struct {
Namespace string `json:"namespace,omitempty"`
MaxCheckpoints *int64 `json:"maxCheckpoints,omitempty"`
}

// CheckpointRestoreOperatorStatus defines the observed state of CheckpointRestoreOperator
Expand Down
115 changes: 111 additions & 4 deletions api/v1/zz_generated.deepcopy.go

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

49 changes: 47 additions & 2 deletions config/crd/bases/criu.org_checkpointrestoreoperators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,57 @@ spec:
description: CheckpointRestoreOperatorSpec defines the desired state of
CheckpointRestoreOperator
properties:
applyPoliciesImmediately:
type: boolean
checkpointDirectory:
description: 'Important: Run "make" to regenerate code after modifying
this file'
type: string
maxCheckpointsPerContainer:
type: integer
containerPolicies:
items:
properties:
container:
type: string
maxCheckpoints:
format: int64
type: integer
namespace:
type: string
pod:
type: string
type: object
type: array
globalPolicy:
properties:
maxCheckpointsPerContainer:
type: integer
maxCheckpointsPerNamespace:
type: integer
maxCheckpointsPerPod:
type: integer
type: object
namespacePolicies:
items:
properties:
maxCheckpoints:
format: int64
type: integer
namespace:
type: string
type: object
type: array
podPolicies:
items:
properties:
maxCheckpoints:
format: int64
type: integer
namespace:
type: string
pod:
type: string
type: object
type: array
type: object
status:
description: CheckpointRestoreOperatorStatus defines the observed state
Expand Down
11 changes: 10 additions & 1 deletion config/samples/_v1_checkpointrestoreoperator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ metadata:
app.kubernetes.io/created-by: checkpoint-restore-operator
name: checkpointrestoreoperator-sample
spec:
maxCheckpointsPerContainer: 5
checkpointDirectory: /var/lib/kubelet/checkpoints
applyPoliciesImmediately: false
globalPolicy:
maxCheckpointsPerNamespace: 50
maxCheckpointsPerPod: 30
maxCheckpointsPerContainer: 10
containerPolicies:
- namespace: namespace-name
pod: pod-name
container: container-name
maxCheckpoints: 5
Loading

0 comments on commit e668f80

Please sign in to comment.