Skip to content

Commit 99f7547

Browse files
committed
refacotr xcollaset to collaset
1 parent 76e44c8 commit 99f7547

29 files changed

+130
-136
lines changed

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: coldsteelrail/kusion-kuperator
7+
newName: kusionstack/kuperator
88
newTag: test

pkg/controllers/add_collaset.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ limitations under the License.
1616

1717
package controllers
1818

19-
import (
20-
"kusionstack.io/kuperator/pkg/controllers/xcollaset"
21-
)
19+
import "kusionstack.io/kuperator/pkg/controllers/collaset"
2220

2321
func init() {
24-
AddToManagerFuncs = append(AddToManagerFuncs, xcollaset.Add)
22+
AddToManagerFuncs = append(AddToManagerFuncs, collaset.Add)
2523
}

pkg/controllers/xcollaset/collaset_controller.go renamed to pkg/controllers/collaset/collaset_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package xcollaset
17+
package collaset
1818

1919
import (
2020
"context"
@@ -30,8 +30,8 @@ import (
3030
"sigs.k8s.io/controller-runtime/pkg/client"
3131
"sigs.k8s.io/controller-runtime/pkg/manager"
3232

33+
"kusionstack.io/kuperator/pkg/controllers/collaset/utils"
3334
controllerutils "kusionstack.io/kuperator/pkg/controllers/utils"
34-
"kusionstack.io/kuperator/pkg/controllers/xcollaset/utils"
3535
)
3636

3737
const (
@@ -120,6 +120,7 @@ func (s *XSetOperation) GetXSetSpec(xset xsetapi.XSetObject) *xsetapi.XSetSpec {
120120
}
121121
xSetSpec.UpdateStrategy.RollingUpdate = &rollingUpdate
122122
}
123+
xSetSpec.UpdateStrategy.OperationDelaySeconds = set.Spec.UpdateStrategy.OperationDelaySeconds
123124
// scale strategy
124125
xSetSpec.ScaleStrategy.TargetToDelete = set.Spec.ScaleStrategy.PodToDelete
125126
xSetSpec.ScaleStrategy.TargetToExclude = set.Spec.ScaleStrategy.PodToExclude

pkg/controllers/xcollaset/collaset_controller_test.go renamed to pkg/controllers/collaset/collaset_controller_test.go

Lines changed: 49 additions & 45 deletions
Large diffs are not rendered by default.

pkg/controllers/xcollaset/decoration_adapter.go renamed to pkg/controllers/collaset/decoration_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package xcollaset
17+
package collaset
1818

1919
import (
2020
"context"

pkg/controllers/xcollaset/utils/legacy_lifecycle_adapter.go renamed to pkg/controllers/collaset/legacy/lifecycle_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package utils
17+
package legacy
1818

1919
import (
2020
appsv1alpha1 "kusionstack.io/kube-api/apps/v1alpha1"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2025 The KusionStack Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package legacy
18+
19+
const (
20+
OwnerContextKey = "Owner"
21+
RevisionContextDataKey = "Revision"
22+
PodDecorationRevisionKey = "PodDecorationRevisions"
23+
JustCreateContextDataKey = "PodJustCreate"
24+
RecreateUpdateContextDataKey = "PodRecreateUpdate"
25+
ScaleInContextDataKey = "ScaleIn"
26+
ReplaceNewPodIDContextDataKey = "ReplaceNewPodID"
27+
ReplaceOriginPodIDContextDataKey = "ReplaceOriginPodID"
28+
)

pkg/controllers/xcollaset/utils/pvc_control.go renamed to pkg/controllers/collaset/legacy/pvc_control.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package utils
17+
package legacy
1818

1919
import (
2020
"context"
@@ -29,6 +29,7 @@ import (
2929
kubeutilsexpectations "kusionstack.io/kube-utils/controller/expectations"
3030
"sigs.k8s.io/controller-runtime/pkg/client"
3131

32+
"kusionstack.io/kuperator/pkg/controllers/collaset/utils"
3233
refmanagerutil "kusionstack.io/kuperator/pkg/controllers/utils/refmanager"
3334
"kusionstack.io/kuperator/pkg/utils/inject"
3435
)
@@ -124,15 +125,15 @@ func (pc *RealPvcControl) provisionUpdatedPvc(c client.Client, ctx context.Conte
124125
}
125126

126127
// create new pvc
127-
claim, err := BuildPvcWithHash(cls, &pvcTmp, id)
128+
claim, err := utils.BuildPvcWithHash(cls, &pvcTmp, id)
128129
if err != nil {
129130
return nil, err
130131
}
131132

132133
if err := c.Create(ctx, claim); err != nil {
133134
return nil, fmt.Errorf("fail to create pvc for id %s: %w", id, err)
134135
} else {
135-
if err = pc.cacheExpectations.ExpectCreation(kubeutilsclient.ObjectKeyString(cls), PVCGVK, claim.Namespace, claim.Name); err != nil {
136+
if err = pc.cacheExpectations.ExpectCreation(kubeutilsclient.ObjectKeyString(cls), utils.PVCGVK, claim.Namespace, claim.Name); err != nil {
136137
return nil, err
137138
}
138139
}
@@ -158,7 +159,7 @@ func (pc *RealPvcControl) DeletePodPvcs(ctx context.Context, cls *appsv1alpha1.C
158159
// delete pvcs labeled same id with pod
159160
if err := pc.client.Delete(ctx, pvc); err != nil {
160161
return err
161-
} else if err := pc.cacheExpectations.ExpectDeletion(kubeutilsclient.ObjectKeyString(cls), PVCGVK, pvc.Namespace, pvc.Name); err != nil {
162+
} else if err := pc.cacheExpectations.ExpectDeletion(kubeutilsclient.ObjectKeyString(cls), utils.PVCGVK, pvc.Namespace, pvc.Name); err != nil {
162163
return err
163164
}
164165
}
@@ -192,7 +193,7 @@ func (pc *RealPvcControl) DeletePodUnusedPvcs(ctx context.Context, cls *appsv1al
192193
}
193194

194195
// delete old pvc if new pvc is provisioned and WhenScaled is "Delete"
195-
if PvcPolicyWhenScaled(cls) == appsv1alpha1.DeletePersistentVolumeClaimRetentionPolicyType {
196+
if utils.PvcPolicyWhenScaled(cls) == appsv1alpha1.DeletePersistentVolumeClaimRetentionPolicyType {
196197
return pc.deleteOldPvcs(pc.client, ctx, cls, newPvcs, oldPvcs)
197198
}
198199
return nil
@@ -236,7 +237,7 @@ func (pc *RealPvcControl) AdoptPvc(cls *appsv1alpha1.CollaSet, pvc *corev1.Persi
236237
func classifyPodPvcs(cls *appsv1alpha1.CollaSet, id string, existingPvcs []*corev1.PersistentVolumeClaim) (*map[string]*corev1.PersistentVolumeClaim, *map[string]*corev1.PersistentVolumeClaim, error) {
237238
newPvcs := map[string]*corev1.PersistentVolumeClaim{}
238239
oldPvcs := map[string]*corev1.PersistentVolumeClaim{}
239-
newTmpHash, err := PvcTmpHashMapping(cls.Spec.VolumeClaimTemplates)
240+
newTmpHash, err := utils.PvcTmpHashMapping(cls.Spec.VolumeClaimTemplates)
240241
if err != nil {
241242
return &newPvcs, &oldPvcs, err
242243
}
@@ -260,7 +261,7 @@ func classifyPodPvcs(cls *appsv1alpha1.CollaSet, id string, existingPvcs []*core
260261
continue
261262
}
262263
hash := pvc.Labels[appsv1alpha1.PvcTemplateHashLabelKey]
263-
pvcTmpName, err := ExtractPvcTmpName(cls, pvc)
264+
pvcTmpName, err := utils.ExtractPvcTmpName(cls, pvc)
264265
if err != nil {
265266
return nil, nil, err
266267
}
@@ -278,7 +279,7 @@ func classifyPodPvcs(cls *appsv1alpha1.CollaSet, id string, existingPvcs []*core
278279

279280
func IsPodPvcTmpChanged(cls *appsv1alpha1.CollaSet, pod *corev1.Pod, existingPvcs []*corev1.PersistentVolumeClaim) (bool, error) {
280281
// get pvc template hash values
281-
newHashMapping, err := PvcTmpHashMapping(cls.Spec.VolumeClaimTemplates)
282+
newHashMapping, err := utils.PvcTmpHashMapping(cls.Spec.VolumeClaimTemplates)
282283
if err != nil {
283284
return false, err
284285
}
@@ -328,7 +329,7 @@ func (pc *RealPvcControl) deleteUnclaimedPvcs(c client.Client, ctx context.Conte
328329
}
329330
if err := c.Delete(ctx, pvc); err != nil {
330331
return err
331-
} else if err := pc.cacheExpectations.ExpectDeletion(kubeutilsclient.ObjectKeyString(cls), PVCGVK, pvc.Namespace, pvc.Name); err != nil {
332+
} else if err := pc.cacheExpectations.ExpectDeletion(kubeutilsclient.ObjectKeyString(cls), utils.PVCGVK, pvc.Namespace, pvc.Name); err != nil {
332333
return err
333334
}
334335
}
@@ -342,7 +343,7 @@ func (pc *RealPvcControl) deleteOldPvcs(c client.Client, ctx context.Context, cl
342343
}
343344
if err := c.Delete(ctx, pvc); err != nil {
344345
return err
345-
} else if err := pc.cacheExpectations.ExpectDeletion(kubeutilsclient.ObjectKeyString(cls), PVCGVK, pvc.Namespace, pvc.Name); err != nil {
346+
} else if err := pc.cacheExpectations.ExpectDeletion(kubeutilsclient.ObjectKeyString(cls), utils.PVCGVK, pvc.Namespace, pvc.Name); err != nil {
346347
return err
347348
}
348349
}

pkg/controllers/xcollaset/lifecycle_adapter.go renamed to pkg/controllers/collaset/lifecycle_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package xcollaset
17+
package collaset
1818

1919
import (
2020
appsv1alpha1 "kusionstack.io/kube-api/apps/v1alpha1"

pkg/controllers/xcollaset/pod_updater.go renamed to pkg/controllers/collaset/pod_updater.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package xcollaset
17+
package collaset
1818

1919
import (
2020
"context"
@@ -32,7 +32,7 @@ import (
3232
"kusionstack.io/kube-xset/synccontrols"
3333
"sigs.k8s.io/controller-runtime/pkg/client"
3434

35-
"kusionstack.io/kuperator/pkg/controllers/xcollaset/utils"
35+
"kusionstack.io/kuperator/pkg/controllers/collaset/utils"
3636
)
3737

3838
var _ synccontrols.TargetUpdater = &inPlaceIfPossibleUpdater{}

0 commit comments

Comments
 (0)