@@ -25,28 +25,6 @@ const (
25
25
timeThirtySeconds = 30 * time .Second
26
26
)
27
27
28
- func (r * AppWrapperReconciler ) checkExistingMachineSet (ctx context.Context , machineSetName string ) bool {
29
- // Set up the Object key with the requested app wrapper name and requested type
30
- key := client.ObjectKey {
31
- Name : machineSetName ,
32
- Namespace : namespaceToList ,
33
- }
34
-
35
- machineSet := & machinev1beta1.MachineSet {}
36
- err := r .Get (ctx , key , machineSet )
37
- if err != nil {
38
- // Check if the error is due to the MachineSet not existing
39
- if client .IgnoreNotFound (err ) != nil {
40
- // return error if it there is a different error for not getting the MachineSet
41
- klog .Infof ("Error getting MachineSet: %s" , err )
42
- }
43
- // MachineSet does not exist
44
- return false
45
- }
46
- // The MachineSet exists
47
- return true
48
- }
49
-
50
28
func (r * AppWrapperReconciler ) reconcileCreateMachineSet (ctx context.Context , aw * arbv1.AppWrapper , demandMapPerInstanceType map [string ]int ) (ctrl.Result , error ) {
51
29
52
30
allMachineSet := machinev1beta1.MachineSetList {}
@@ -498,94 +476,6 @@ func (r *AppWrapperReconciler) annotateToDeleteMachine(ctx context.Context, aw *
498
476
return nil
499
477
}
500
478
501
- /*
502
- func (r *AppWrapperReconciler) annotateToDeleteMachine(ctx context.Context, aw *arbv1.AppWrapper) error {
503
- label := fmt.Sprintf("%s-%s", aw.Name, aw.Namespace)
504
- // We get a list of Nodes with the AppWrapper name and correct instance type
505
- labelSelector := labels.SelectorFromSet(labels.Set(map[string]string{
506
- label: label,
507
- }))
508
- listOptions := &metav1.ListOptions{
509
- LabelSelector: labelSelector.String(),
510
- }
511
- // List nodes with the AppWrapper name
512
- nodes, _ := r.kubeClient.CoreV1().Nodes().List(ctx, *listOptions)
513
- for _, node := range nodes.Items {
514
- klog.Infof("Filtered node name is %v", aw.Name)
515
- for k, v := range node.Annotations {
516
- if k == "machine.openshift.io/machine" {
517
- machineName := strings.Split(v, "/")
518
- klog.Infof("The machine name to be annotated %v", machineName[1])
519
- allMachines := machinev1beta1.MachineList{}
520
- errm := r.List(ctx, &allMachines)
521
- if errm != nil {
522
- klog.Infof("Error listing machines: %v", errm)
523
- return errm
524
- }
525
- for _, aMachine := range allMachines.Items {
526
- //remove index hardcoding
527
- if aMachine.Name == machineName[1] {
528
- updateMachine := aMachine.DeepCopy()
529
- updateMachine.Annotations["machine.openshift.io/cluster-api-delete-machine"] = "true"
530
- if err := r.Update(ctx, updateMachine); err != nil {
531
- return err
532
- }
533
- var updateMachineset string = ""
534
- for k, v := range updateMachine.Labels {
535
- if k == "machine.openshift.io/cluster-api-machineset" {
536
- updateMachineset = v
537
- klog.Infof("Machineset to update is %v", updateMachineset)
538
- }
539
- }
540
- if updateMachineset != "" {
541
- allMachineSet := machinev1beta1.MachineSetList{}
542
- err := r.List(ctx, &allMachineSet)
543
- if err != nil {
544
- klog.Infof("Machineset retrieval error")
545
- return err
546
- }
547
- for _, aMachineSet := range allMachineSet.Items {
548
- if aMachineSet.Name == updateMachineset {
549
- klog.Infof("Existing machineset replicas %v", &aMachineSet.Spec.Replicas)
550
- //scale down is harded coded to 1??
551
- newReplicas := *aMachineSet.Spec.Replicas - int32(1)
552
- updateMsReplicas := aMachineSet.DeepCopy()
553
- updateMsReplicas.Spec.Replicas = &newReplicas
554
- err := r.Update(ctx, updateMsReplicas)
555
- if err != nil {
556
- klog.Infof("Error updating MachineSet: %s", err)
557
- return err
558
- }
559
- err = r.Get(ctx, types.NamespacedName{Namespace: namespaceToList}, updateMsReplicas)
560
- if err != nil {
561
- klog.Infof("Error updating MachineSet: %s", err)
562
- return err
563
- }
564
- if updateMsReplicas.Labels[fmt.Sprintf("instascale.codeflare.dev-%s-%s", aw.Name, aw.Namespace)] != "" {
565
- if err := r.removeMachineSetLabel(ctx, aw, aMachineSet.Name); err != nil {
566
- return err
567
- }
568
- }
569
- klog.Infof("Replica update successful")
570
- }
571
- }
572
- }
573
- }
574
- }
575
- }
576
- }
577
- }
578
-
579
- for machineSetName := range machineSetNames {
580
- if updateMsReplicas.Labels[fmt.Sprintf("instascale.codeflare.dev-%s-%s", aw.Name, aw.Namespace)] != "" {
581
- if err := r.removeMachineSetLabel(ctx, aw, aMachineSet.Name); err != nil {
582
- return err
583
- }
584
- }
585
- }
586
- return nil
587
- }
588
- */
589
479
func (r * AppWrapperReconciler ) patchMachineLabels (ctx context.Context , oldAw * arbv1.AppWrapper , newAw * arbv1.AppWrapper , machineName string ) error {
590
480
// Retrieve the machine object
591
481
machine := & machinev1beta1.Machine {}
0 commit comments