8000 feat: a new pod naming rule for instanceset by cjc7373 · Pull Request #9292 · apecloud/kubeblocks · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: a new pod naming rule for instanceset #9292

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

cjc7373
Copy link
Contributor
@cjc7373 cjc7373 commented Apr 23, 2025

Changes related to OpsRequest will be implemented in another PR.

@cjc7373 cjc7373 changed the title feat: a new pod naming rule feat: a new pod naming rule for instanceset Apr 23, 2025
@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Apr 23, 2025
@cjc7373 cjc7373 force-pushed the feature/new-pod-naming-rule branch from 8b49f68 to e7a89c9 Compare April 24, 2025 07:03
@cjc7373 cjc7373 force-pushed the feature/new-pod-naming-rule branch from e7a89c9 to 15893fa Compare May 13, 2025 08:53
@cjc7373 cjc7373 force-pushed the feature/new-pod-naming-rule branch from 15893fa to ff58e24 Compare May 21, 2025 06:47
cjc7373 added 9 commits May 21, 2025 15:55
old behavior

migrate to new api

validation

crd generation

add some tests

cleanup

header

split validation rules for different pod name builder

cleanup

typo

comment

migrate some usage of GenerateAllInstanceNames to new api

wip

manifest
@cjc7373 cjc7373 force-pushed the feature/new-pod-naming-rule branch from ff58e24 to 41c2834 Compare May 21, 2025 08:33
Copy link
codecov bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 63.47942% with 275 lines in your changes missing coverage. Please review.

Project coverage is 60.19%. Comparing base (0e6a994) to head (71d2fae).

Files with missing lines Patch % Lines
...eset/instancetemplate/pod_name_builder_combined.go 71.79% 33 Missing and 11 partials ⚠️
...set/instancetemplate/pod_name_builder_separated.go 72.83% 36 Missing and 8 partials ⚠️
...roller/instanceset/instancetemplate/compression.go 29.09% 37 Missing and 2 partials ⚠️
...g/controller/instanceset/instancetemplate/merge.go 65.27% 20 Missing and 5 partials ⚠️
pkg/controller/component/component.go 20.00% 14 Missing and 2 partials ⚠️
...troller/instanceset/i 8000 nstancetemplate/validation.go 60.52% 10 Missing and 5 partials ⚠️
pkg/controller/instanceset/reconciler_update.go 16.66% 14 Missing and 1 partial ⚠️
pkg/controller/component/available.go 23.52% 13 Missing ⚠️
...ontroller/instanceset/instancetemplate/template.go 73.33% 11 Missing and 1 partial ⚠️
...kg/controller/instanceset/reconciler_validation.go 0.00% 12 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9292      +/-   ##
==========================================
+ Coverage   60.09%   60.19%   +0.10%     
==========================================
  Files         391      399       +8     
  Lines       47616    48034     +418     
==========================================
+ Hits        28613    28916     +303     
- Misses      16203    16302      +99     
- Partials     2800     2816      +16     
Flag Coverage Δ
unittests 60.19% <63.47%> (+0.10%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leon-inf leon-inf added this to the Release 1.1.0 milestone May 21, 2025
@cjc7373 cjc7373 marked this pull request as ready for review May 22, 2025 05:58
@cjc7373 cjc7373 requested a review from a team as a code owner May 22, 2025 05:58
func (t *componentServiceTransformer) podsNameNSuffix(synthesizeComp *component.SynthesizedComponent) (map[string]string, error) {
podNames, err := generatePodNames(synthesizeComp)
func (t *componentServiceTransformer) podsNameNSuffix(synthesizeComp *component.SynthesizedComponent, runningITS *workloadsv1.InstanceSet) (map[string]string, error) {
podNames, err := component.GeneratePodNamesByITS(runningITS)
Copy link
Contributor

Choose a reason for hiding this comment

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

The running ITS should not be used to calculate the expected pods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should use proto its? IMO using running its will eventually converge, just need another reconciliation loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another reconciliation loop can indeed bring all resources to the final state, e.g., (a1, b1, c1) -> (a2, b2, c2). However, in the current reconciliation loop, it will put the resources in an inconsistent state, something like: (a1, b1, c1) -> (a2, b2, c1), and the impact of this inconsistency is uncertain. The difference here lies in the inconsistency rather than the eventual consistency.

@cjc7373 cjc7373 force-pushed the feature/new-pod-naming-rule branch from 43ab64b to 8675be1 Compare May 22, 2025 07:36
return fmt.Errorf("ordinal(%v) must >= 0", item)
}
if ordinalSet.Has(item) {
return fmt.Errorf("duplicate ordinal(%v)", item)
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicates within the same template should be okay.

for _, pod := range pods {
templateName, ok := pod.Labels[TemplateNameLabelKey]
if !ok {
return fmt.Errorf("unknown pod %v", klog.KObj(pod))
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all pods have a template.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pod without a template will get an empty name.

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if the ordinals of two templates were (partially) exchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean the order two templates are changed? Then nothing should happen in theory. Template lists are sorted by template name before the pod name calculation.

Copy link
Contributor

Choose a reason for hiding this comment

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

From: template a -> [0, 1, 2], template b -> [3, 4, 5], to: template a -> [0, 1, 3], template b -> [2, 4, 5].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GenerateTemplateName2OrdinalMap will return the updated ordinal map.

@@ -480,6 +480,10 @@ type ClusterComponentSpec struct {
// +listMapKey=name
Instances []InstanceTemplate `json:"instances,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

// +optional
// +kubebuilder:default=Separated
PodNamingRule PodNamingRule `json:"podNamingRule,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this field defined outside the instance template?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then how does a user test the new naming rule? Use a feature gate?

Copy link
Contributor

Choose a reason for hiding this comment

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

The question is why not defined it within the instance template?

Copy link
Contributor Author
@cjc7373 cjc7373 May 22, 2025

Choose a reason for hiding this comment

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

The naming rule applies to the whole instanceset, not just one instance template.

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
0