Skip to content

chore: introduce the instance crd #9546

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 32 commits into
base: main
Choose a base branch
from
Open

chore: introduce the instance crd #9546

wants to merge 32 commits into from

Conversation

leon-inf
Copy link
Contributor

No description provided.

@leon-inf leon-inf added this to the Release 1.1.0 milestone Jul 17, 2025
@apecloud-bot
Copy link
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.0

@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Jul 17, 2025
@leon-inf
Copy link
Contributor Author

/nopick

@apecloud-bot apecloud-bot added the nopick Not auto cherry-pick when PR merged label Jul 17, 2025
@leon-inf leon-inf force-pushed the support/instance-crd branch from 0f9f3f1 to d169a30 Compare July 17, 2025 08:37
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

❌ Patch coverage is 54.61821% with 1361 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.62%. Comparing base (f8afb5a) to head (532f11a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...controller/instance/reconciler_assistant_object.go 6.75% 136 Missing and 2 partials ⚠️
pkg/controller/builder/builder_instance.go 0.00% 117 Missing ⚠️
.../controller/instanceset2/assistant_object_utils.go 6.61% 112 Missing and 1 partial ⚠️
pkg/controller/instance/in_place_update_utils.go 52.13% 88 Missing and 24 partials ⚠️
pkg/controller/instanceset2/instance_util.go 57.25% 92 Missing and 17 partials ⚠️
pkg/controller/instance/utils.go 60.16% 81 Missing and 15 partials ⚠️
pkg/controller/instanceset2/update_plan.go 43.57% 76 Missing and 3 partials ⚠️
pkg/controller/instanceset2/reconciler_status.go 74.43% 51 Missing and 17 partials ⚠️
pkg/controller/instance/reconciler_update.go 60.86% 45 Missing and 18 partials ⚠️
pkg/controller/instance/pod_role_event_handler.go 10.44% 60 Missing ⚠️
... and 25 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9546      +/-   ##
==========================================
- Coverage   59.94%   59.62%   -0.32%     
==========================================
  Files         518      551      +33     
  Lines       56636    59931    +3295     
==========================================
+ Hits        33948    35734    +1786     
- Misses      19636    20936    +1300     
- Partials     3052     3261     +209     
Flag Coverage Δ
unittests 59.62% <54.61%> (-0.32%) ⬇️

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 force-pushed the support/instance-crd branch from d169a30 to 688d714 Compare July 17, 2025 08:56
@leon-inf leon-inf force-pushed the support/instance-crd branch 11 times, most recently from 6154703 to f9cfcae Compare July 22, 2025 05:57
@leon-inf leon-inf force-pushed the support/instance-crd branch 4 times, most recently from 428a60d to 611875e Compare August 8, 2025 09:21
@leon-inf leon-inf marked this pull request as ready for review August 8, 2025 09:23
@leon-inf leon-inf requested a review from a team as a code owner August 8, 2025 09:23
@leon-inf leon-inf force-pushed the support/instance-crd branch from 611875e to 784684f Compare August 8, 2025 10:01
@leon-inf leon-inf force-pushed the support/instance-crd branch from 784684f to 3f2d28d Compare August 8, 2025 10:08
@cjc7373
Copy link
Contributor

cjc7373 commented Aug 13, 2025

What's the main advantage of introducing the new instance api?

snapshotVersion := strconv.FormatInt(event.EventTime.UnixMicro(), 10)
lastSnapshotVersion, ok := pod.Annotations[constant.LastRoleSnapshotVersionAnnotationKey]
if ok {
if snapshotVersion <= lastSnapshotVersion && !strings.Contains(lastSnapshotVersion, ":") {
Copy link
Contributor

Choose a reason for hiding this comment

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

A bug related to time comparison will be introduced here. It will be triggered in about 200 years, although we'll all be gone by then. :) It's recommended to also compare the lengths of the two strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

func (r *revisionUpdateReconciler) Reconcile(tree *kubebuilderx.ObjectTree) (kubebuilderx.Result, error) {
its, _ := tree.GetRoot().(*workloads.InstanceSet)

updatedReplicas, err := r.calculateUpdatedReplicas(its, tree.List(&workloads.Instance{}))
Copy link
Contributor

Choose a reason for hiding this comment

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

err is always nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

}
}

// TODO: ???
Copy link
Contributor

Choose a reason for hiding this comment

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

The code was introduced by #8151. I think it's still useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not supported within the instance API.

// merge pvcs
for i := range newInst.Spec.VolumeClaimTemplates {
newPVC := &newInst.Spec.VolumeClaimTemplates[i]
oldPVC := &targetInst.Spec.VolumeClaimTemplates[i]
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential out-of-bound error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.


copyNMergeAssistantObjects := func() {
for i := range newInst.Spec.InstanceAssistantObjects {
oldObj := &targetInst.Spec.InstanceAssistantObjects[i]
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

}
return true
case []corev1.Toleration:
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are tolerations ignored?

return false, err
}
if err != nil || robj == nil {
labels := obj.GetLabels()
Copy link
Contributor

Choose a reason for hiding this comment

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

labels can be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

for _, object := range oldPodList {
oldNameSet.Insert(object.GetName())
}
deleteNameSet := oldNameSet.Difference(newNameSet)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the newNameSet only contains inst.name, in what case will oldNameSet contain another value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-implemented it.

meta.RemoveStatusCondition(&inst.Status.Conditions, string(workloads.InstanceUpdateRestricted))
}
if needRetry {
return kubebuilderx.RetryAfter(time.Second * time.Duration(inst.Spec.MinReadySeconds)), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

inst.Spec.MinReadySeconds can be zero. Maybe sleep for at least a few seconds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That needRetry is true indicates that the minReadySeconds is not 0.

var (
codecs = serializer.NewCodecFactory(model.GetScheme())
patchCodec = codecs.LegacyCodec(workloads.SchemeGroupVersion)
controllerKind = appsv1.SchemeGroupVersion.WithKind("StatefulSet")
Copy link
Contributor

Choose a reason for hiding this comment

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

"InstanceSet"? Although it affects nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

ConfigMap *corev1.ConfigMap `json:"configMap,omitempty"`
Secret *corev1.Secret `json:"secret,omitempty"`
ServiceAccount *corev1.ServiceAccount `json:"serviceAccount,omitempty"`
Role *rbacv1.Role `json:"clusterRole,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

clusterRole => role

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@leon-inf leon-inf force-pushed the support/instance-crd branch 3 times, most recently from edd75f5 to 532f11a Compare August 22, 2025 07:37
@leon-inf leon-inf force-pushed the support/instance-crd branch from 532f11a to a0aeedb Compare August 22, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nopick Not auto cherry-pick when PR merged size/XXL Denotes a PR that changes 1000+ lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants