Skip to content

Commit a0bcc51

Browse files
committed
update discoverInstanceTypes to persist annotations
1 parent 3ca7587 commit a0bcc51

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

controllers/appWrapper_controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package controllers
22

33
import (
4+
"context"
45
"testing"
56

67
"github.com/onsi/gomega"
@@ -10,7 +11,7 @@ import (
1011

1112
func (r *AppWrapperReconciler) TestDiscoverInstanceTypes(t *testing.T) {
1213
g := gomega.NewGomegaWithT(t)
13-
14+
ctx := context.Background()
1415
tests := []struct {
1516
name string
1617
input *arbv1.AppWrapper
@@ -99,7 +100,7 @@ func (r *AppWrapperReconciler) TestDiscoverInstanceTypes(t *testing.T) {
99100

100101
for _, test := range tests {
101102
t.Run(test.name, func(t *testing.T) {
102-
result := r.discoverInstanceTypes(test.input)
103+
result := r.discoverInstanceTypes(ctx, test.input)
103104
g.Expect(result).To(gomega.Equal(test.expected))
104105
})
105106
}

controllers/appwrapper_controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request)
132132
return ctrl.Result{}, nil
133133
}
134134

135-
demandPerInstanceType := r.discoverInstanceTypes(&appwrapper)
135+
demandPerInstanceType := r.discoverInstanceTypes(ctx, &appwrapper)
136136
if ocmSecretRef := r.Config.OCMSecretRef; ocmSecretRef != nil {
137137
switch r.MachineType {
138138
case MachineTypeNodePool:
@@ -252,13 +252,16 @@ func (r *AppWrapperReconciler) getOCMSecret(ctx context.Context, secretRef *core
252252
return r.kubeClient.CoreV1().Secrets(secretRef.Namespace).Get(ctx, secretRef.Name, metav1.GetOptions{})
253253
}
254254

255-
func (r *AppWrapperReconciler) discoverInstanceTypes(aw *arbv1.AppWrapper) map[string]int {
255+
func (r *AppWrapperReconciler) discoverInstanceTypes(ctx context.Context, aw *arbv1.AppWrapper) map[string]int {
256256
demandMapPerInstanceType := make(map[string]int)
257257
instanceRequired := getInstanceRequired(aw.Labels)
258258
if len(instanceRequired) < 1 {
259259
if _, exists := aw.Annotations["loggedNoInstances"]; !exists {
260260
klog.Infof("Found AW %s that cannot be scaled due to missing orderedinstance label", aw.ObjectMeta.Name)
261261
r.setAnnotation(aw, "loggedNoInstances", "true")
262+
if err := r.Update(ctx, aw); err != nil {
263+
return nil
264+
}
262265
}
263266
return demandMapPerInstanceType
264267
}

0 commit comments

Comments
 (0)