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

chore: introduce the v1 version CRDs #7757

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft

chore: introduce the v1 version CRDs #7757

wants to merge 19 commits into from

Conversation

leon-inf
Copy link
Contributor

@leon-inf leon-inf commented Jul 9, 2024

No description provided.

@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Jul 9, 2024
@leon-inf leon-inf marked this pull request as ready for review July 9, 2024 02:42
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.35%. Comparing base (2379471) to head (9447373).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7757      +/-   ##
==========================================
+ Coverage   63.30%   63.35%   +0.05%     
==========================================
  Files         339      339              
  Lines       41438    41438              
==========================================
+ Hits        26234    26255      +21     
+ Misses      12870    12853      -17     
+ Partials     2334     2330       -4     
Flag Coverage Δ
unittests 63.35% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// Cluster by default.
//
// +optional
Namespace string `json:"namespace,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, references a Cluster in a different namespace is forbidden because of the security consideration (referencing a Secret in another ns). so may be we can delete this field

// The name of the credential (SystemAccount) to reference.
//
// +kubebuilder:validation:Required
Name string `json:"name"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems named to serviceAccount is more consistent and self-explanatory

// of the Component providing the service in the referenced Cluster.
//
// +optional
Credential *ServiceRefCredentialSelector `json:"credential,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

credential or account?

Comment on lines +762 to +773
// Extends the ServiceSpec.Selector by allowing the specification of a sharding name, which is defined in
// `cluster.spec.shardingSpecs[*].name`, to be used as a selector for the service.
// Note that this and the `componentSelector` are mutually exclusive and cannot be set simultaneously.
//
// +optional
ShardingSelector string `json:"shardingSelector,omitempty"`

// Extends the ServiceSpec.Selector by allowing the specification of a component, to be used as a selector for the service.
// Note that this and the `shardingSelector` are mutually exclusive and cannot be set simultaneously.
//
// +optional
ComponentSelector string `json:"componentSelector,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these two fields get merged?

for example, there is only a single field componentSelector. if it equals to a name specified in cluster.spec.shardingSpecs[*].name, then it's a sharding selector.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way, if I don't use the sharding feature, I won't need to understand the shardingSelector field.

Comment on lines +860 to +865
// FailedClusterPhase represents all components are in `Failed` phase, indicates that the cluster is unavailable.
FailedClusterPhase ClusterPhase = "Failed"

// AbnormalClusterPhase represents some components are in `Failed` or `Abnormal` phase, indicates that the cluster
// is in a fragile state and troubleshooting is required.
AbnormalClusterPhase ClusterPhase = "Abnormal"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should mark one as deprecated

//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=64
CompDef string `json:"compDef"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add field like:

// +optional
IsSharding bool `json:isSharding,omitempty`

default value is false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MinShardCount int32 `json:minShardCount,omitempty`
MaxShardCount int32 `json:maxShardCount,omitempty`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsAccountSecretShared bool `json:isAccountSecretShared,omitempty`

// The value will be presented in the following format: FQDN1,FQDN2,...
//
// +optional
PodFQDNs *VarOption `json:"podFQDNs,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, except the load balancer IP, the provided addresses (e.g., pod FQDN, service host) are mostly DNS domain names or parts of them.

There should be a way to provide a list of node hostnames, pod IPs, or service IPs that disclose the components' pods reside on. This way, in scenarios like hostNetwork or when there is no service (e.g., Kuaishou), IP addresses can be constructed accordingly.

Node or pod IPs cannot be obtained during the provisioning stage, so dynamic modification and notification for the resolution of vars values need to be supported first.

//
// +kubebuilder:default=false
// +optional
Initialization bool `json:"initialization,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better renamed to isSystemInitializationAccount

// Specifies the statement template used to delete the account.
//
// +optional
Deletion *string `json:"deletion,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO (v1.1 or later)
password mutation sql stmt, for secret rotation

//
// +kubebuilder:default=false
// +optional
Votable bool `json:"votable,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be deleted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is used when memberUpdateStrategy is 'BestEffort'.

Suggest to rename to ParticipatesInQuorum bool, // Indicates if pods with this role participate in forming the quorum.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original name of this field was 'votable', which doesn't seem appropriate.

For example, if we have a leader and two loggers, they are all votable, but we can't stop the leader. Only the leader is in the quorum.

// +kubebuilder:default=false
// +optional
Writable bool `json:"writable,omitempty"`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could add more fields to describe a role's abilities or properties, like:

  • Unique bool, Indicates if there could be only one pod that has such role in the component.
  • Required bool , Indicates whether at least one replica with this role is required for the component to be considered running.
  • UpdatePriority int, Describes the priority for updating pods with this role. When updating, all pods are sorted by this priority and updated accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this way, there is no need to inference which role is leader in controller's code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more field:

  • SwitchoverBeforeUpdate bool, // Indicates if a switchover operation is needed before updating.

// - KB_SERVICE_PORT: The port used by the database service.
// - KB_SERVICE_USER: The username with the necessary permissions to interact with the database service.
// - KB_SERVICE_PASSWORD: The corresponding password for KB_SERVICE_USER to authenticate with the database service.
// - KB_PRIMARY_POD_FQDN: The FQDN of the primary Pod within the replication group.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“KB_PRIMARY_POD_FQDN“ reveals a concept "primary"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds the "primary" pod should be determined by the action itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//
// The container executing this action has access to following environment variables:
//
// - KB_POD_FQDN: The FQDN of the Pod whose role is being assessed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pod name is enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter is unnecessary once action is executed in kb-agent

// - KB_SWITCHOVER_CANDIDATE_FQDN: The FQDN of the new leader candidate's pod, which may not be specified (empty).
// - KB_LEADER_POD_IP: The IP address of the current leader's pod prior to the switchover.
// - KB_LEADER_POD_NAME: The name of the current leader's pod prior to the switchover.
// - KB_LEADER_POD_FQDN: The FQDN of the current leader's pod prior to the switchover.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switchover refers to transferring the current pod's role to another pod candidate with a different role.

The parameters should include the roles of the current pod and the candidate pod(s).

Comment on lines +484 to +489
// Specifies the builtin handler name to use to probe the role of the main container.
// Available handlers include: mysql, postgres, mongodb, redis, etcd, kafka.
// Use CustomHandler to define a custom role probe function if none of the built-in handlers meet the requirement.
//
// +optional
BuiltinHandler *string `json:"builtinHandlerName,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be deleted

Comment on lines +353 to +378
type AddonInstallSpecItem struct {
// Specifies the number of replicas.
//
// +optional
Replicas *int32 `json:"replicas,omitempty"`

// Indicates whether the Persistent Volume is enabled or not.
//
// +optional
PVEnabled *bool `json:"persistentVolumeEnabled,omitempty"`

// Specifies the name of the storage class.
//
// +optional
StorageClass string `json:"storageClass,omitempty"`

// Specifies the tolerations in a JSON array string format.
//
// +optional
Tolerations string `json:"tolerations,omitempty"`

// Specifies the resource requirements.
//
// +optional
Resources ResourceRequirements `json:"resources,omitempty"`
}
Copy link
Contributor

@weicao weicao Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not need these fields any more once Addon is true "addon" (which is a collection of cd, cmpd, cm etc). This will be done in 1.0

Comment on lines +470 to +485
type CliPlugin struct {
// Specifies the name of the plugin.
//
// +kubebuilder:validation:Required
Name string `json:"name"`

// Defines the index repository of the plugin.
//
// +kubebuilder:validation:Required
IndexRepository string `json:"indexRepository"`

// Provides a brief description of the plugin.
//
// +optional
Description string `json:"description,omitempty"`
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no addon is using, can be deleted

@leon-inf leon-inf marked this pull request as draft August 29, 2024 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL Denotes a PR that changes 1000+ lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants