Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Zhang committed Sep 24, 2024
1 parent 19ed98c commit 3094ebe
Show file tree
Hide file tree
Showing 18 changed files with 1,433 additions and 325 deletions.
10 changes: 10 additions & 0 deletions apis/placement/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ const (

// ResourceOverrideSnapshotKind is the kind of the ResourceOverrideSnapshotKind.
ResourceOverrideSnapshotKind = "ResourceOverrideSnapshot"

// StagedUpdateRunFinalizer is used by the staged update run controller to make sure that the stagedUpdateRun
// object is not deleted until all its dependent resources are deleted.
StagedUpdateRunFinalizer = fleetPrefix + "stagedupdaterun-finalizer"

// TargetUpdateRunLabel is the label that indicates the target update run of a staged update run.
TargetUpdateRunLabel = fleetPrefix + "targetupdaterun"

// The name of delete stage in the staged update run
UpdateRunDeleteStageName = fleetPrefix + "deleteStage"
)
17 changes: 12 additions & 5 deletions apis/placement/v1alpha1/stagedupdate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,25 @@ type StagedUpdateRunStatus struct {
// +kubebuilder:validation:Optional
PolicySnapshotIndexUsed string `json:"policySnapshotIndexUsed,omitempty"`

// PolicyObservedCRPGeneration is the generation of the CRP which the scheduler uses to perform the scheduling.
// It is computed at the beginning of the update run from the policy snapshot object. If the CRP is updated
// during the update run in a way that causes the policy snapshot condition to change, the update run is abandoned.
// +kubebuilder:validation:Optional
PolicyObservedNodeCount int `json:"policyObservedNodeCount,omitempty"`

// ApplyStrategy is the apply strategy that the stagedUpdateRun is using.
// It is the same as the apply strategy in the CRP when the staged update run starts.
// The apply strategy is not updated during the update run even if it changes in the CRP.
// +kubebuilder:validation:Optional
ApplyStrategy v1beta1.ApplyStrategy `json:"appliedStrategy,omitempty"`
ApplyStrategy *v1beta1.ApplyStrategy `json:"appliedStrategy,omitempty"`

// StagedUpdateStrategySnapshot is the snapshot of the StagedUpdateStrategy used for the update run.
// The snapshot is immutable during the update run.
// The strategy is applied to the list of clusters scheduled by the CRP according to the current policy.
// The update run fails to initialize if the strategy fails to produce a valid list of stages where each selected
// cluster is included in exactly one stage.
// +kubebuilder:validation:Optional
StagedUpdateStrategySnapshot StagedUpdateStrategySpec `json:"stagedUpdateStrategySnapshot,omitempty"`
StagedUpdateStrategySnapshot *StagedUpdateStrategySpec `json:"stagedUpdateStrategySnapshot,omitempty"`

// StagesStatus lists the current updating status of each stage.
// The list is empty if the update run is not started or failed to initialize.
Expand All @@ -180,7 +186,7 @@ type StagedUpdateRunStatus struct {
// removes all the resources from the clusters that are not selected by the
// current policy after all the update stages are completed.
// +kubebuilder:validation:Optional
DeletionStageStatus StageUpdatingStatus `json:"deletionStageStatus,omitempty"`
DeletionStageStatus *StageUpdatingStatus `json:"deletionStageStatus,omitempty"`

// +patchMergeKey=type
// +patchStrategy=merge
Expand All @@ -201,8 +207,9 @@ const (
// StagedUpdateRunConditionInitialized indicates whether the staged update run is initialized, meaning it
// has computed all the stages according to the referenced strategy and is ready to start the update.
// Its condition status can be one of the following:
// - "True": The staged update run is initialized.
// - "False": The staged update run encountered an error during initialization.
// - "True": The staged update run is initialized successfully.
// - "False": The staged update run encountered an error during initialization and aborted.
// - "Unknown": The staged update run initialization has started.
StagedUpdateRunConditionInitialized StagedUpdateRunConditionType = "Initialized"

// StagedUpdateRunConditionProgressing indicates whether the staged update run is making progress.
Expand Down
18 changes: 15 additions & 3 deletions apis/placement/v1alpha1/zz_generated.deepcopy.go

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

53 changes: 29 additions & 24 deletions apis/placement/v1beta1/commons.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ Licensed under the MIT license.
package v1beta1

const (
ClusterResourcePlacementKind = "ClusterResourcePlacement"
ClusterResourcePlacementResource = "clusterresourceplacements"
ClusterResourceBindingKind = "ClusterResourceBinding"
ClusterResourceSnapshotKind = "ClusterResourceSnapshot"
// ClusterResourcePlacementKind represents the kind of ClusterResourcePlacement.
ClusterResourcePlacementKind = "ClusterResourcePlacement"
// ClusterResourcePlacementResource represents the resource name for ClusterResourcePlacement.
ClusterResourcePlacementResource = "clusterresourceplacements"
// ClusterResourceBindingKind represents the kind of ClusterResourceBinding.
ClusterResourceBindingKind = "ClusterResourceBinding"
// ClusterResourceSnapshotKind represents the kind of ClusterResourceSnapshot.
ClusterResourceSnapshotKind = "ClusterResourceSnapshot"
// ClusterSchedulingPolicySnapshotKind represents the kind of ClusterSchedulingPolicySnapshot.
ClusterSchedulingPolicySnapshotKind = "ClusterSchedulingPolicySnapshot"
WorkKind = "Work"
AppliedWorkKind = "AppliedWork"
// WorkKind represents the kind of Work.
WorkKind = "Work"
// AppliedWorkKind represents the kind of AppliedWork.
AppliedWorkKind = "AppliedWork"
)

const (
// Unprefixed labels/annotations are reserved for end-users
// we will add a kubernetes-fleet.io to designate these labels/annotations as official fleet labels/annotations.
// fleetPrefix is the prefix used for official fleet labels/annotations.
// Unprefixed labels/annotations are reserved for end-users.
// See https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#label-selector-and-annotation-conventions
fleetPrefix = "kubernetes-fleet.io/"

Expand All @@ -29,25 +36,25 @@ const (
// cluster.
WorkFinalizer = fleetPrefix + "work-cleanup"

// CRPTrackingLabel is the label that points to the cluster resource policy that creates a resource binding.
// CRPTrackingLabel points to the cluster resource policy that creates this resource binding.
CRPTrackingLabel = fleetPrefix + "parent-CRP"

// IsLatestSnapshotLabel tells if the snapshot is the latest one.
// IsLatestSnapshotLabel indicates if the snapshot is the latest one.
IsLatestSnapshotLabel = fleetPrefix + "is-latest-snapshot"

// FleetResourceLabelKey is that label that indicates the resource is a fleet resource.
// FleetResourceLabelKey indicates that the resource is a fleet resource.
FleetResourceLabelKey = fleetPrefix + "is-fleet-resource"

// FirstWorkNameFmt is the format of the name of the work generated with first resource snapshot .
// FirstWorkNameFmt is the format of the name of the work generated with the first resource snapshot.
// The name of the first work is {crpName}-work.
FirstWorkNameFmt = "%s-work"

// WorkNameWithSubindexFmt is the format of the name of a work generated with resource snapshot with subindex.
// The name of the first work is {crpName}-{subindex}.
// WorkNameWithSubindexFmt is the format of the name of a work generated with a resource snapshot with a subindex.
// The name of the work is {crpName}-{subindex}.
WorkNameWithSubindexFmt = "%s-%d"

// WorkNameWithConfigEnvelopeFmt is the format of the name of a work generated with config envelop.
// The format is {workPrefix}-configMap-uuid
// WorkNameWithConfigEnvelopeFmt is the format of the name of a work generated with a config envelope.
// The format is {workPrefix}-configMap-uuid.
WorkNameWithConfigEnvelopeFmt = "%s-configmap-%s"

// ParentResourceSnapshotIndexLabel is the label applied to work that contains the index of the resource snapshot that generates the work.
Expand All @@ -56,25 +63,23 @@ const (
// ParentBindingLabel is the label applied to work that contains the name of the binding that generates the work.
ParentBindingLabel = fleetPrefix + "parent-resource-binding"

// CRPGenerationAnnotation is the annotation that indicates the generation of the CRP from
// which an object is derived or last updated.
// CRPGenerationAnnotation indicates the generation of the CRP from which an object is derived or last updated.
CRPGenerationAnnotation = fleetPrefix + "CRP-generation"

// EnvelopeConfigMapAnnotation is the annotation that indicates the configmap is an envelope configmap that contains resources
// we need to apply to the member cluster instead of the configMap itself.
// EnvelopeConfigMapAnnotation indicates that the configmap is an envelope configmap containing resources to be applied to the member cluster instead of the configMap itself.
EnvelopeConfigMapAnnotation = fleetPrefix + "envelope-configmap"

// EnvelopeTypeLabel is the label that marks the work object as generated from an envelope object.
// EnvelopeTypeLabel marks the work object as generated from an envelope object.
// The value of the annotation is the type of the envelope object.
EnvelopeTypeLabel = fleetPrefix + "envelope-work"

// EnvelopeNamespaceLabel is the label that contains the namespace of the envelope object that the work is generated from.
// EnvelopeNamespaceLabel contains the namespace of the envelope object that the work is generated from.
EnvelopeNamespaceLabel = fleetPrefix + "envelope-namespace"

// EnvelopeNameLabel is the label that contains the name of the envelope object that the work is generated from.
// EnvelopeNameLabel contains the name of the envelope object that the work is generated from.
EnvelopeNameLabel = fleetPrefix + "envelope-name"

// PreviousBindingStateAnnotation is the annotation that records the previous state of a binding.
// PreviousBindingStateAnnotation records the previous state of a binding.
// This is used to remember if an "unscheduled" binding was moved from a "bound" state or a "scheduled" state.
PreviousBindingStateAnnotation = fleetPrefix + "previous-binding-state"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ spec:
schema:
openAPIV3Schema:
description: |-
ApprovalRequest defines a request for the approval from the user.
ApprovalRequest defines a request for user approval.
The request object MUST have the following labels:
- `TargetUpdateRun` which points to the update run that this approval request is for.
- `TargetStage` which is the name of the stage that this approval request is for.
- `IsLatestUpdateRunApproval` which indicates whether this approval request is the latest one related to this update run.
- `TargetUpdateRun`: Points to the update run that this approval request is for.
- `TargetStage`: The name of the stage that this approval request is for.
- `IsLatestUpdateRunApproval`: Indicates whether this approval request is the latest one related to this update run.
properties:
apiVersion:
description: |-
Expand Down Expand Up @@ -63,12 +63,12 @@ spec:
- message: The spec field is immutable
rule: self == oldSelf
status:
description: The desired state of ApprovalRequest.
description: The observed state of ApprovalRequest.
properties:
conditions:
description: |-
Conditions is an array of current observed conditions for the specific type of post update task.
Known conditions are "Approved", and "ApprovalAccepted".
Conditions is an array of current observed conditions for the specific type of post-update task.
Known conditions are "Approved" and "ApprovalAccepted".
items:
description: "Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
Expand Down
Loading

0 comments on commit 3094ebe

Please sign in to comment.