Skip to content

Commit

Permalink
Add logic for PartitionSet reconciliation
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Giloux <fgiloux@redhat.com>
  • Loading branch information
fgiloux committed Jan 25, 2023
1 parent 32503be commit b8ead47
Show file tree
Hide file tree
Showing 14 changed files with 1,393 additions and 16 deletions.
52 changes: 49 additions & 3 deletions config/crds/topology.kcp.io_partitionsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ spec:
items:
type: string
type: array
selector:
description: selector (optional) is a label selector that filters
shard targets.
shardSelector:
description: ShardSelector (optional) specifies filtering for shard
targets.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
Expand Down Expand Up @@ -101,6 +101,52 @@ spec:
status:
description: status holds information about the current status
properties:
conditions:
description: conditions is a list of conditions that apply to the
APIExportEndpointSlice.
items:
description: Condition defines an observation of a object operational
state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
count:
description: count is the total number of partitions.
type: integer
Expand Down
2 changes: 1 addition & 1 deletion config/root-phase0/apiexport-topology.kcp.io.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ metadata:
spec:
latestResourceSchemas:
- v221115-9b370eb8.partitions.topology.kcp.io
- v221118-9364e75c.partitionsets.topology.kcp.io
- v230125-c991948b.partitionsets.topology.kcp.io
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
kind: APIResourceSchema
metadata:
creationTimestamp: null
name: v221118-9364e75c.partitionsets.topology.kcp.io
name: v230125-c991948b.partitionsets.topology.kcp.io
spec:
group: topology.kcp.io
names:
Expand Down Expand Up @@ -47,8 +47,8 @@ spec:
items:
type: string
type: array
selector:
description: selector (optional) is a label selector that filters shard
shardSelector:
description: ShardSelector (optional) specifies filtering for shard
targets.
properties:
matchExpressions:
Expand Down Expand Up @@ -96,6 +96,50 @@ spec:
status:
description: status holds information about the current status
properties:
conditions:
description: conditions is a list of conditions that apply to the APIExportEndpointSlice.
items:
description: Condition defines an observation of a object operational
state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition in
CamelCase. The specific API may choose whether or not this field
is considered a guaranteed API. This field may not be empty.
type: string
severity:
description: Severity provides an explicit classification of Reason
code, so the users or machines can immediately understand the
current situation and act accordingly. The Severity field MUST
be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
count:
description: count is the total number of partitions.
type: integer
Expand Down
35 changes: 32 additions & 3 deletions pkg/apis/topology/v1alpha1/types_partitionset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

conditionsv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/third_party/conditions/apis/conditions/v1alpha1"
)

// +crd
Expand Down Expand Up @@ -58,16 +60,43 @@ type PartitionSetSpec struct {

// +optional

// selector (optional) is a label selector that filters shard targets.
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// ShardSelector (optional) specifies filtering for shard targets.
ShardSelector *metav1.LabelSelector `json:"shardSelector,omitempty"`
}

// PartitionSetStaus records the status of the PartitionSet.
// PartitionSetStatus records the status of the PartitionSet.
type PartitionSetStatus struct {
// count is the total number of partitions.
Count uint16 `json:"count,omitempty"`

// +optional

// conditions is a list of conditions that apply to the APIExportEndpointSlice.
Conditions conditionsv1alpha1.Conditions `json:"conditions,omitempty"`
}

func (in *PartitionSet) GetConditions() conditionsv1alpha1.Conditions {
return in.Status.Conditions
}

func (in *PartitionSet) SetConditions(conditions conditionsv1alpha1.Conditions) {
in.Status.Conditions = conditions
}

// These are valid conditions of PartitionSet.
const (
// PartitionSetValid reflects the validity of the PartitionSet spec.
PartitionSetValid conditionsv1alpha1.ConditionType = "PartitionSetValid"
// PartitionsReady indicates whether matching partitions could be created.
PartitionsReady conditionsv1alpha1.ConditionType = "PartitionsReady"

// PartitionSetInvalidSelectorReason indicates that the specified selector could not be
// marshalled into a valid one.
PartitionSetInvalidSelectorReason = "InvalidSelector"
// ErrorGeneratingPartitionsReason indicates that the partitions could not be generated
ErrorGeneratingPartitionsReason = "ErrorGeneratingPartitions"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// PartitionSetList is a list of PartitionSet resources
Expand Down
15 changes: 12 additions & 3 deletions pkg/apis/topology/v1alpha1/zz_generated.deepcopy.go

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

22 changes: 19 additions & 3 deletions pkg/openapi/zz_generated.openapi.go

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

Loading

0 comments on commit b8ead47

Please sign in to comment.