Skip to content

feat: add instanceset controller codes#83

Merged
Syspretor merged 1 commit intosgl-project:mainfrom
veophi:feat/instanceset-controller
Nov 5, 2025
Merged

feat: add instanceset controller codes#83
Syspretor merged 1 commit intosgl-project:mainfrom
veophi:feat/instanceset-controller

Conversation

@veophi
Copy link
Copy Markdown
Contributor

@veophi veophi commented Nov 4, 2025

Ⅰ. Motivation

Support in-place update and multi-node deployment using a new workload -- InstanceSet.

Ⅱ. Modifications

  • modify instanceset api
  • add instanceset controller codes

Ⅲ. Does this pull request fix one issue?

fixes #45

Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Ⅴ. Describe how to verify it

VI. Special notes for reviews

Checklist

  • Format your code make fmt.
  • Add unit tests or integration tests.
  • Update the documentation related to the change.

@RongGu RongGu requested a review from Copilot November 4, 2025 09:20
@veophi veophi changed the title [WIP]feat: add instanceset controller codes feat: add instanceset controller codes Nov 4, 2025
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new InstanceSet controller for managing Instance resources with features including scaling, in-place updates, lifecycle hooks, and revision management. The implementation follows a similar pattern to Kubernetes StatefulSet but adapted for Instance custom resources.

Key Changes:

  • Added InstanceSet CRD with scaling and update strategies, lifecycle hooks, and revision management
  • Implemented reconciler logic for instance scaling, updating, and status management
  • Added utility functions for instance sorting, revision management, and reference management
  • Integrated lifecycle hooks for pre-delete and in-place update operations

Reviewed Changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
api/workloads/v1alpha1/instanceset_types.go Added lifecycle hooks, constants, and fixed resource path to plural form
api/workloads/v1alpha1/constant.go Added SetInstanceOwnerLabelKey for InstanceSet ownership
pkg/reconciler/instanceset/* Core reconciler implementation with sync, scale, update, and revision control logic
pkg/inplace/instance/lifecycle/lifecycle_utils.go Lifecycle management utilities for instance state transitions
deploy/helm/rbgs/crds/* CRD definitions with lifecycle hook specifications
config/crd/bases/* Fixed CRD name from singular to plural form
examples/instanceset/* Example YAML files for InstanceSet and Instance resources
cmd/rbgs/main.go Registered InstanceSet controller and added scheme

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +84 to +85
description: InPlaceUpdate is the hook before Pod to update and
after Pod has been updated.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The description incorrectly refers to 'Pod' but should refer to 'Instance' since this CRD is for InstanceSet managing Instance resources, not Pods.

Suggested change
description: InPlaceUpdate is the hook before Pod to update and
after Pod has been updated.
description: InPlaceUpdate is the hook before Instance to update and
after Instance has been updated.

Copilot uses AI. Check for mistakes.
Comment on lines +95 to +98
markPodNotReady:
description: |-
MarkNotReady = true means:
- Pod will be set to 'NotReady' at preparingDelete/preparingUpdate state.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The description incorrectly refers to 'Pod' but should refer to 'Instance' since this is managing Instance readiness state.

Copilot uses AI. Check for mistakes.
type: boolean
type: object
preDelete:
description: PreDelete is the hook before Pod to be deleted.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The description incorrectly refers to 'Pod' but should refer to 'Instance'.

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +115
markPodNotReady:
description: |-
MarkNotReady = true means:
- Pod will be set to 'NotReady' at preparingDelete/preparingUpdate state.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The description incorrectly refers to 'Pod' but should refer to 'Instance'.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,260 @@
/*
Copyright 2019 The Beirut Authors.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'Beirut' to 'Kruise' to match the standard copyright header pattern used in other files.

Suggested change
Copyright 2019 The Beirut Authors.
Copyright 2019 The Kruise Authors.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please fix the standard copyright header pattern.

@veophi veophi force-pushed the feat/instanceset-controller branch from 0b19c3e to ca6341f Compare November 4, 2025 09:40
@RongGu RongGu requested a review from Copilot November 4, 2025 09:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

config/crd/bases/workloads.x-k8s.io_instancesets.yaml:95

  • The field name 'markPodNotReady' should be 'markNotReady' to be consistent with the struct field and avoid confusion. This field applies to Instances, not Pods.
    deploy/helm/rbgs/crds/workloads.x-k8s.io_instancesets.yaml:95
  • The field name 'markPodNotReady' should be 'markNotReady' to be consistent with the struct field and avoid confusion. This field applies to Instances, not Pods.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

// RefManager provides the method to
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Incomplete comment. Should be 'RefManager provides the methods to manage owner references for resources.'

Suggested change
// RefManager provides the method to
// RefManager provides the methods to manage owner references for resources.

Copilot uses AI. Check for mistakes.
}

// NewRefManager returns a RefManager that exposes
// methods to manage the controllerRef of pods.
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Comment refers to 'pods' but should refer to 'objects' or 'resources' since RefManager is generic and manages any metav1.Object, not specifically pods.

Suggested change
// methods to manage the controllerRef of pods.
// methods to manage the controllerRef of objects.

Copilot uses AI. Check for mistakes.
)

const (
// LengthOfInstanceID is the length of instanceutil-id
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Corrected 'instanceutil-id' to 'instance-id' in comment for clarity.

Suggested change
// LengthOfInstanceID is the length of instanceutil-id
// LengthOfInstanceID is the length of instance-id

Copilot uses AI. Check for mistakes.
klog.V(3).Infof("InstanceSet %s begin to scale out %d instances including %d (current rev)",
controllerKey, expectedCreations, expectedCurrentCreations)

// available instanceutil-id come from free pvc
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Corrected 'instanceutil-id' to 'instance-id' and changed 'come' to 'comes' for grammatical correctness.

Suggested change
// available instanceutil-id come from free pvc
// available instance-id comes from free pvc

Copilot uses AI. Check for mistakes.
@Syspretor Syspretor self-requested a review November 4, 2025 13:16
@Syspretor
Copy link
Copy Markdown
Collaborator

/lgtm

@Syspretor Syspretor merged commit d376300 into sgl-project:main Nov 5, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Development Roadmap (v0.5.0)

5 participants