Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit c7347e3

Browse files
committed
Ensure calculated default set on project
This change additionally ensures that existing projects are also updated so that their default region is set. Tests are also refactored to unit tests when possible. Signed-off-by: Donnie Adams <[email protected]>
1 parent b832817 commit c7347e3

File tree

21 files changed

+227
-484
lines changed

21 files changed

+227
-484
lines changed

integration/client/projects/projects_test.go

Lines changed: 0 additions & 210 deletions
This file was deleted.

integration/helper/namespace.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ func TempNamespace(t *testing.T, client client.Client) *corev1.Namespace {
2222
"test.acorn.io/namespace": "true",
2323
labels.AcornProject: "true",
2424
},
25-
Annotations: map[string]string{
26-
labels.AcornProjectDefaultRegion: "local",
27-
labels.AcornProjectSupportedRegions: "local",
28-
},
2925
},
3026
Spec: corev1.NamespaceSpec{},
3127
Status: corev1.NamespaceStatus{},

integration/run/run_test.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,57 +1119,6 @@ func TestAppWithBadRegion(t *testing.T) {
11191119
}
11201120
}
11211121

1122-
func TestAppUpdateRegion(t *testing.T) {
1123-
helper.StartController(t)
1124-
1125-
k8sclient := helper.MustReturn(kclient.Default)
1126-
ctx := helper.GetCTX(t)
1127-
c, _ := helper.ClientAndNamespace(t)
1128-
1129-
image, err := c.AcornImageBuild(ctx, "./testdata/simple/Acornfile", &client.AcornImageBuildOptions{
1130-
Cwd: "./testdata/simple",
1131-
})
1132-
if err != nil {
1133-
t.Fatal(err)
1134-
}
1135-
1136-
app, err := c.AppRun(ctx, image.ID, nil)
1137-
if err != nil {
1138-
t.Fatal(err)
1139-
}
1140-
1141-
app = helper.WaitForObject(t, helper.Watcher(t, c), &apiv1.AppList{}, app, func(obj *apiv1.App) bool {
1142-
return obj.Status.Condition(v1.AppInstanceConditionParsed).Success &&
1143-
obj.Status.Condition(v1.AppInstanceConditionReady).Success
1144-
})
1145-
1146-
for {
1147-
// Update the app region to be `local`, which should be the default
1148-
if err = k8sclient.Get(ctx, kclient.ObjectKey{Namespace: app.Namespace, Name: app.Name}, app); err != nil {
1149-
t.Fatal(err)
1150-
}
1151-
app.Spec.Region = "local"
1152-
if err = k8sclient.Update(ctx, app); err == nil {
1153-
break
1154-
} else if !apierrors.IsConflict(err) {
1155-
t.Fatal(err)
1156-
}
1157-
}
1158-
1159-
for {
1160-
// Now try to update the app region to something else, which should fail
1161-
if err = k8sclient.Get(ctx, kclient.ObjectKey{Namespace: app.Namespace, Name: app.Name}, app); err != nil {
1162-
t.Fatal(err)
1163-
}
1164-
app.Spec.Region = "non-local"
1165-
if err = k8sclient.Update(ctx, app); err == nil {
1166-
t.Fatal("expected error")
1167-
} else if !apierrors.IsConflict(err) {
1168-
break
1169-
}
1170-
}
1171-
}
1172-
11731122
func getStorageClassName(t *testing.T, storageClasses *storagev1.StorageClassList) string {
11741123
t.Helper()
11751124
if len(storageClasses.Items) == 0 {

pkg/controller/defaults/defaults.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ func calculate(req router.Request, appInstance *internalv1.AppInstance) error {
4545
return err
4646
}
4747

48-
if err = addDefaultRegion(req.Ctx, req.Client, appInstance); err != nil {
49-
return err
50-
}
51-
5248
if err = addVolumeClassDefaults(req.Ctx, req.Client, appInstance); err != nil {
5349
return err
5450
}

pkg/controller/defaults/region.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

pkg/controller/defaults/region_test.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

pkg/controller/defaults/testdata/region/default/existing.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

pkg/controller/defaults/testdata/region/default/expected.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

pkg/controller/defaults/testdata/region/default/input.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)