Skip to content

Commit 3059f49

Browse files
ybelMekktommytroenchristeredvartsen
committed
add(postgres): gql ID for App storage resolver
* update test files Co-authored-by: Tommy Trøen <[email protected]> Co-authored-by: Christer Edvartsen <[email protected]>
1 parent ba19098 commit 3059f49

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

data/k8s/dev/devteam/app-w-all-storage.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spec:
1212
sqlInstances:
1313
- type: POSTGRES_15
1414
cascadingDelete: true
15-
name: deleteme
15+
name: contests
1616
- type: POSTGRES_14
1717
name: donotdelete
1818
bigQueryDatasets:

data/k8s/dev/devteam/sqlinstance.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ metadata:
1616
app.kubernetes.io/name: app-w-all-storage
1717
helm.sh/chart: app-w-all-storage-2024-02-22-115844-b411609
1818
team: nais
19-
name: deleteme
19+
name: contests
2020
namespace: nais-system
2121
spec:
2222
databaseVersion: POSTGRES_15
2323
instanceType: CLOUD_SQL_INSTANCE
2424
maintenanceVersion: POSTGRES_15_10.R20240130.00_05
2525
region: europe-north1
26-
resourceID: deleteme
26+
resourceID: contests
2727
settings:
2828
activationPolicy: ALWAYS
2929
availabilityType: ZONAL
@@ -59,9 +59,9 @@ status:
5959
conditions:
6060
- lastTransitionTime: "2024-01-23T09:30:20Z"
6161
message: The resource is up to date
62-
reason: Provisioning
62+
reason: UpToDate
6363
status: "True"
64-
type: NotReady
64+
type: Ready
6565
connectionName: nais-dev-123:europe-north1:app-w-all-storage
6666
firstIpAddress: 1.2.3.4
6767
instanceType: CLOUD_SQL_INSTANCE
@@ -135,10 +135,10 @@ spec:
135135
status:
136136
conditions:
137137
- lastTransitionTime: "2024-01-23T09:30:20Z"
138-
message: The resource is up to date
139-
reason: Provisioning
140-
status: "True"
141-
type: NotReady
138+
message: "Update call failed: error applying desired state: summary: Error, failed to update instance settings for : googleapi: Error 400: Invalid request: backup retention should be >= transaction log retention.,"
139+
reason: UpdateFailed
140+
status: "False"
141+
type: Ready
142142
connectionName: nais-dev-123:europe-north1:app-w-all-storage
143143
firstIpAddress: 1.2.3.4
144144
instanceType: CLOUD_SQL_INSTANCE

data/k8s/superprod/devteam/sqlinstance_update_failed.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ status:
6565
- lastTransitionTime: "2024-04-03T10:49:48Z"
6666
message: 'Update call failed: error applying desired state: summary: Error, failed
6767
to update instance settings for : googleapi: Error 400: Invalid request: Incorrect
68-
Service Networking config for instance: tommytest3-dev-a367:contests-failing:SERVICE_NETWORKING_NOT_ENABLED.,
68+
Service Networking config for instance: superprod-test:contests-failing:SERVICE_NETWORKING_NOT_ENABLED.,
6969
invalid'
7070
reason: UpdateFailed
7171
status: "False"

internal/k8s/apps.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (c *Client) App(ctx context.Context, name, team, env string) (*model.App, e
112112
return nil, c.error(ctx, err, "getting topics")
113113
}
114114

115-
storage, err := appStorage(obj.(*unstructured.Unstructured), topics)
115+
storage, err := appStorage(obj.(*unstructured.Unstructured), topics, env)
116116
if err != nil {
117117
return nil, c.error(ctx, err, "converting to app storage")
118118
}
@@ -928,7 +928,7 @@ func synchronizationStateCondition(conditions []metav1.Condition) *metav1.Condit
928928
return nil
929929
}
930930

931-
func appStorage(u *unstructured.Unstructured, topics []*model.Topic) ([]model.Storage, error) {
931+
func appStorage(u *unstructured.Unstructured, topics []*model.Topic, env string) ([]model.Storage, error) {
932932
app := &naisv1alpha1.Application{}
933933
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, app); err != nil {
934934
return nil, fmt.Errorf("converting to application: %w", err)
@@ -954,6 +954,7 @@ func appStorage(u *unstructured.Unstructured, topics []*model.Topic) ([]model.St
954954
if sqlInstance.Name == "" {
955955
sqlInstance.Name = app.Name
956956
}
957+
sqlInstance.ID = scalar.SqlInstanceIdent("sqlInstance_" + env + "_" + app.GetNamespace() + "_" + sqlInstance.GetName())
957958
ret = append(ret, sqlInstance)
958959
}
959960

0 commit comments

Comments
 (0)