@@ -2,12 +2,9 @@ package controllers
2
2
3
3
import (
4
4
"context"
5
+ templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/templates"
5
6
"reflect"
6
- "sigs.k8s.io/controller-runtime/pkg/client"
7
7
"strconv"
8
- "time"
9
-
10
- templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/templates"
11
8
12
9
trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/v1alpha1"
13
10
appsv1 "k8s.io/api/apps/v1"
@@ -210,58 +207,3 @@ func (r *TrustyAIServiceReconciler) checkDeploymentReady(ctx context.Context, in
210
207
211
208
return false , nil
212
209
}
213
-
214
- func (r * TrustyAIServiceReconciler ) scaleDeployment (ctx context.Context , instance * trustyaiopendatahubiov1alpha1.TrustyAIService , replicas int32 ) error {
215
- deployment := & appsv1.Deployment {}
216
- err := r .Get (ctx , types.NamespacedName {Name : instance .Name , Namespace : instance .Namespace }, deployment )
217
- if err != nil {
218
- return err
219
- }
220
- deployment .Spec .Replicas = & replicas
221
- return r .Update (ctx , deployment )
222
- }
223
-
224
- func (r * TrustyAIServiceReconciler ) waitForTermination (ctx context.Context , instance * trustyaiopendatahubiov1alpha1.TrustyAIService ) error {
225
- for {
226
- select {
227
- case <- ctx .Done ():
228
- return ctx .Err ()
229
- default :
230
- podList := & corev1.PodList {}
231
- opts := []client.ListOption {
232
- client .InNamespace (instance .Name ),
233
- client.MatchingLabels {"app" : instance .Name },
234
- }
235
- err := r .List (ctx , podList , opts ... )
236
- if err != nil {
237
- return err
238
- }
239
- if len (podList .Items ) == 0 {
240
- return nil
241
- }
242
- time .Sleep (2 * time .Second )
243
- }
244
- }
245
- }
246
-
247
- func (r * TrustyAIServiceReconciler ) redeployForMigration (ctx context.Context , instance * trustyaiopendatahubiov1alpha1.TrustyAIService ) error {
248
- log .FromContext (ctx ).Info ("Scaling down to zero replicas" )
249
- err := r .scaleDeployment (ctx , instance , 0 )
250
- if err != nil {
251
- return err
252
- }
253
-
254
- log .FromContext (ctx ).Info ("Waiting for deployment to scale down to zero replicas" )
255
- err = r .waitForTermination (ctx , instance )
256
- if err != nil {
257
- return err
258
- }
259
-
260
- log .FromContext (ctx ).Info ("Scaling up" )
261
- err = r .scaleDeployment (ctx , instance , 1 )
262
- if err != nil {
263
- return err
264
- }
265
-
266
- return nil
267
- }
0 commit comments