-
Notifications
You must be signed in to change notification settings - Fork 382
Add RoleSet and StormService detail spec #1226
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
Merged
Jeffwan
merged 1 commit into
vllm-project:main
from
Jeffwan:jiaxin/storm-service-api-impl
Jun 25, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
Copyright 2025 The Aibrix Team. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// A ConditionType represents a condition a resource could be in. | ||
type ConditionType string | ||
|
||
// A Condition that may apply to a resource. | ||
type Condition struct { | ||
// Type of this condition. At most one of each condition type may apply to a resource at any point in time. | ||
Type ConditionType `json:"type"` | ||
|
||
// Status of this condition; is it currently True, False, or Unknown? | ||
Status corev1.ConditionStatus `json:"status"` | ||
|
||
// LastTransitionTime is the last time this condition transitioned from one status to another. | ||
// +optional | ||
LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` | ||
|
||
// LastUpdateTime is the last time this condition was updated. | ||
// +optional | ||
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` | ||
|
||
// LastUpdateMicroTime is the last time with microsecond level precision this condition was updated. | ||
// +optional | ||
LastUpdateMicroTime *metav1.MicroTime `json:"lastUpdateMicroTime,omitempty"` | ||
|
||
// The Reason for the condition's last transition. | ||
Reason string `json:"reason,omitempty"` | ||
|
||
// A Message containing details about this condition's last transition from one status to another, if any. | ||
// +optional | ||
Message string `json:"message,omitempty"` | ||
} | ||
|
||
func NewCondition(ct ConditionType, status corev1.ConditionStatus, msg string) Condition { | ||
return Condition{ | ||
Type: ct, | ||
Status: status, | ||
Message: msg, | ||
} | ||
} | ||
|
||
// Conditions reflects the observed status of a resource. Only | ||
// one condition of each type may exist. | ||
type Conditions []Condition | ||
|
||
// GetCondition returns the condition for the given ConditionType if exists, | ||
// otherwise returns nil | ||
func (s Conditions) GetCondition(ct ConditionType) Condition { | ||
for _, c := range s { | ||
if c.Type == ct { | ||
return c | ||
} | ||
} | ||
|
||
return Condition{Type: ct, Status: corev1.ConditionUnknown} | ||
} | ||
|
||
// SetConditions sets the supplied conditions, replacing any existing conditions | ||
// of the same type. This is a no-op if all supplied conditions are identical, | ||
// ignoring the last transition time, to those already set. | ||
func (s *Conditions) SetConditions(conditions ...Condition) { | ||
for _, c := range conditions { | ||
found := false | ||
for i := range *s { | ||
ref := &(*s)[i] | ||
if ref.Type != c.Type { | ||
continue | ||
} | ||
|
||
found = true | ||
|
||
if ref.Equal(&c) { | ||
if !c.LastUpdateTime.Equal(ref.LastUpdateTime) { | ||
ref.LastUpdateTime = c.LastUpdateTime | ||
} | ||
if !c.LastUpdateMicroTime.Equal(ref.LastUpdateMicroTime) { | ||
ref.LastUpdateMicroTime = c.LastUpdateMicroTime | ||
} | ||
continue | ||
} | ||
if ref.Status != c.Status { | ||
now := metav1.Now() | ||
c.LastTransitionTime = &now | ||
} | ||
*ref = c | ||
} | ||
if !found { | ||
now := metav1.Now() | ||
c.LastTransitionTime = &now | ||
*s = append(*s, c) | ||
} | ||
} | ||
} | ||
|
||
// Equal used to judge weather two condition is equal. | ||
// LastTransitionTime, LastUpdateTime and LastUpdateMicroTime is ignored. | ||
func (c *Condition) Equal(candidate *Condition) bool { | ||
return c.Message == candidate.Message && | ||
c.Type == candidate.Type && | ||
c.Status == candidate.Status | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,25 +17,111 @@ limitations under the License. | |
package v1alpha1 | ||
|
||
import ( | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
// let's temporarily use godel scheduler's definition, consider to switch to community definitions | ||
schedv1alpha1 "github.com/kubewharf/godel-scheduler-api/pkg/apis/scheduling/v1alpha1" | ||
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
|
||
// RoleSetSpec defines the desired state of RoleSet | ||
type RoleSetSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
Roles []RoleSpec `json:"roles,omitempty"` | ||
|
||
// +optional | ||
UpdateStrategy RoleSetUpdateStrategyType `json:"updateStrategy,omitempty"` | ||
|
||
// +optional | ||
SchedulingStrategy SchedulingStrategy `json:"schedulingStrategy,omitempty"` | ||
} | ||
|
||
// Foo is an example field of RoleSet. Edit roleset_types.go to remove/update | ||
Foo string `json:"foo,omitempty"` | ||
// +enum | ||
type SchedulingStrategy struct { | ||
PodGroup *schedv1alpha1.PodGroupSpec `json:"podGroup,omitempty"` | ||
} | ||
|
||
// +enum | ||
type RoleSetUpdateStrategyType string | ||
|
||
const ( | ||
// ParallelRoleSetUpdateStrategyType update all roles in parallel | ||
ParallelRoleSetUpdateStrategyType RoleSetUpdateStrategyType = "Parallel" | ||
// SequentialRoleSetStrategyType update all roles in sequential | ||
SequentialRoleSetStrategyType RoleSetUpdateStrategyType = "Sequential" | ||
// InterleaveRoleSetStrategyType update all roles in interleave, follow the rolling step defined in roles | ||
InterleaveRoleSetStrategyType RoleSetUpdateStrategyType = "Interleave" | ||
) | ||
|
||
type DisruptionTolerance struct { | ||
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"` | ||
} | ||
|
||
type RoleSpec struct { | ||
Name string `json:"name,omitempty"` | ||
|
||
// Replicas is the number of desired replicas. | ||
// +optional | ||
Replicas *int32 `json:"replicas,omitempty"` | ||
|
||
// +optional | ||
// +patchStrategy=retainKeys | ||
UpdateStrategy RoleUpdateStrategy `json:"updateStrategy,omitempty"` | ||
|
||
// +optional | ||
Stateful bool `json:"stateful,omitempty"` | ||
|
||
// +optional | ||
Template v1.PodTemplateSpec `json:"template,omitempty"` | ||
|
||
// DisruptionTolerance indicates how many pods can be unavailable during the preemption/eviction. | ||
// +optional | ||
DisruptionTolerance DisruptionTolerance `json:"disruptionTolerance,omitempty"` | ||
} | ||
|
||
// +enum | ||
type RoleUpdateStrategy struct { | ||
// +optional | ||
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"` | ||
|
||
// +optional | ||
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"` | ||
} | ||
|
||
// RoleSetStatus defines the observed state of RoleSet | ||
type RoleSetStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
Roles []RoleStatus `json:"roles,omitempty"` | ||
// +optional | ||
// +patchMergeKey=type | ||
// +patchStrategy=merge | ||
Conditions Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
} | ||
|
||
// These are valid conditions of roleSet. | ||
const ( | ||
// RoleSetReady means the roleSet meeting the minimal requirements for the roleSet to be considered ready. | ||
RoleSetReady ConditionType = "Ready" | ||
RoleSetReplicaFailure ConditionType = "ReplicaFailure" | ||
RoleSetProgressing ConditionType = "Progressing" | ||
) | ||
|
||
type RoleStatus struct { | ||
Name string `json:"name,omitempty"` | ||
|
||
// Replicas is the most recently oberved number of replicas. | ||
Replicas int32 `json:"replicas"` | ||
|
||
// +optional | ||
ReadyReplicas int32 `json:"readyReplicas,omitempty"` | ||
|
||
// +optional | ||
NotReadyReplicas int32 `json:"notReadyReplicas,omitempty"` | ||
|
||
// +optional | ||
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"` | ||
|
||
// +optional | ||
UpdatedReadyReplicas int32 `json:"updatedReadyReplicas,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment explaining what this function does and the meaning of its parameters.