-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resource_customizations/db.atlasgo.io: atlas operator resources
Signed-off-by: Rotem Tamir <[email protected]>
- Loading branch information
Showing
10 changed files
with
301 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
resource_customizations/db.atlasgo.io/AtlasMigration/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
hs = {} | ||
|
||
local function readyCond(obj) | ||
if obj.status ~= nil and obj.status.conditions ~= nil then | ||
for _, condition in ipairs(obj.status.conditions) do | ||
if condition.type == "Ready" then | ||
return condition | ||
end | ||
end | ||
end | ||
return nil | ||
end | ||
|
||
local ready = readyCond(obj) | ||
|
||
if ready == nil then | ||
hs.status = "Progressing" | ||
hs.message = "Waiting for Atlas Operator" | ||
return hs | ||
end | ||
|
||
if ready.status == "True" then | ||
hs.status = "Healthy" | ||
hs.message = ready.reason | ||
return hs | ||
end | ||
|
||
if ready.reason == "Reconciling" then | ||
hs.status = "Progressing" | ||
else | ||
hs.status = "Degraded" | ||
end | ||
|
||
hs.message = ready.reason | ||
|
||
return hs | ||
|
13 changes: 13 additions & 0 deletions
13
resource_customizations/db.atlasgo.io/AtlasMigration/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests: | ||
- healthStatus: | ||
status: Progressing | ||
message: "Reconciling" | ||
inputPath: testdata/progressing.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Migrating" | ||
inputPath: testdata/degraded.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: "Applied" | ||
inputPath: testdata/healthy.yaml |
29 changes: 29 additions & 0 deletions
29
resource_customizations/db.atlasgo.io/AtlasMigration/testdata/degraded.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: db.atlasgo.io/v1alpha1 | ||
kind: AtlasMigration | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"db.atlasgo.io/v1alpha1","kind":"AtlasMigration","metadata":{"annotations":{},"name":"atlasmigration-sample","namespace":"default"},"spec":{"dir":{"configMapRef":{"name":"migration-dir"}},"urlFrom":{"secretKeyRef":{"key":"url","name":"mysql-credentials"}}}} | ||
creationTimestamp: "2023-11-16T08:37:23Z" | ||
generation: 1 | ||
name: atlasmigration-sample | ||
namespace: default | ||
resourceVersion: "49923" | ||
uid: 0d5bc3d6-750e-4f5a-82a3-8b9173106ef4 | ||
spec: | ||
dir: | ||
configMapRef: | ||
name: migration-dir | ||
urlFrom: | ||
secretKeyRef: | ||
key: url | ||
name: mysql-credentials | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2023-11-16T08:37:23Z" | ||
message: 'Error: checksum mismatch' | ||
reason: Migrating | ||
status: "False" | ||
type: Ready | ||
lastApplied: 0 | ||
observed_hash: "" |
30 changes: 30 additions & 0 deletions
30
resource_customizations/db.atlasgo.io/AtlasMigration/testdata/healthy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: db.atlasgo.io/v1alpha1 | ||
kind: AtlasMigration | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"db.atlasgo.io/v1alpha1","kind":"AtlasMigration","metadata":{"annotations":{},"name":"atlasmigration-sample","namespace":"default"},"spec":{"dir":{"configMapRef":{"name":"migration-dir"}},"urlFrom":{"secretKeyRef":{"key":"url","name":"mysql-credentials"}}}} | ||
creationTimestamp: "2023-11-16T08:37:23Z" | ||
generation: 1 | ||
name: atlasmigration-sample | ||
namespace: default | ||
resourceVersion: "50387" | ||
uid: 0d5bc3d6-750e-4f5a-82a3-8b9173106ef4 | ||
spec: | ||
dir: | ||
configMapRef: | ||
name: migration-dir | ||
urlFrom: | ||
secretKeyRef: | ||
key: url | ||
name: mysql-credentials | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2023-11-16T08:46:27Z" | ||
message: "" | ||
reason: Applied | ||
status: "True" | ||
type: Ready | ||
lastApplied: 1700124387 | ||
lastAppliedVersion: "20230316085611" | ||
observed_hash: 4969b3c84c097ff61a9f9722b595a66c1a4473bd85fdd282107b98a92db8a43b |
30 changes: 30 additions & 0 deletions
30
resource_customizations/db.atlasgo.io/AtlasMigration/testdata/progressing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: db.atlasgo.io/v1alpha1 | ||
kind: AtlasMigration | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"db.atlasgo.io/v1alpha1","kind":"AtlasMigration","metadata":{"annotations":{},"name":"atlasmigration-sample","namespace":"default"},"spec":{"dir":{"configMapRef":{"name":"migration-dir"}},"urlFrom":{"secretKeyRef":{"key":"url","name":"mysql-credentials"}}}} | ||
creationTimestamp: "2023-11-16T08:37:23Z" | ||
generation: 1 | ||
name: atlasmigration-sample | ||
namespace: default | ||
resourceVersion: "50387" | ||
uid: 0d5bc3d6-750e-4f5a-82a3-8b9173106ef4 | ||
spec: | ||
dir: | ||
configMapRef: | ||
name: migration-dir | ||
urlFrom: | ||
secretKeyRef: | ||
key: url | ||
name: mysql-credentials | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2023-11-16T08:46:27Z" | ||
message: "Current migration data has changed" | ||
reason: "Reconciling" | ||
status: "False" | ||
type: Ready | ||
lastApplied: 1700124387 | ||
lastAppliedVersion: "20230316085611" | ||
observed_hash: 4969b3c84c097ff61a9f9722b595a66c1a4473bd85fdd282107b98a92db8a43b |
37 changes: 37 additions & 0 deletions
37
resource_customizations/db.atlasgo.io/AtlasSchema/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
hs = {} | ||
|
||
local function readyCond(obj) | ||
if obj.status ~= nil and obj.status.conditions ~= nil then | ||
for _, condition in ipairs(obj.status.conditions) do | ||
if condition.type == "Ready" then | ||
return condition | ||
end | ||
end | ||
end | ||
return nil | ||
end | ||
|
||
local ready = readyCond(obj) | ||
|
||
if ready == nil then | ||
hs.status = "Progressing" | ||
hs.message = "Waiting for Atlas Operator" | ||
return hs | ||
end | ||
|
||
if ready.status == "True" then | ||
hs.status = "Healthy" | ||
hs.message = ready.reason | ||
return hs | ||
end | ||
|
||
if ready.message == "Reconciling" or ready.message == "GettingDevDB" then | ||
hs.status = "Progressing" | ||
else | ||
hs.status = "Degraded" | ||
end | ||
|
||
hs.message = ready.reason | ||
|
||
return hs | ||
|
13 changes: 13 additions & 0 deletions
13
resource_customizations/db.atlasgo.io/AtlasSchema/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests: | ||
- healthStatus: | ||
status: Progressing | ||
message: "Reconciling" | ||
inputPath: testdata/progressing.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "ApplyingSchema" | ||
inputPath: testdata/degraded.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: "Applied" | ||
inputPath: testdata/healthy.yaml |
38 changes: 38 additions & 0 deletions
38
resource_customizations/db.atlasgo.io/AtlasSchema/testdata/degraded.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: db.atlasgo.io/v1alpha1 | ||
kind: AtlasSchema | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"db.atlasgo.io/v1alpha1","kind":"AtlasSchema","metadata":{"annotations":{},"name":"atlasschema-mysql","namespace":"default"},"spec":{"schema":{"sql":"create table users (\n id int not null auto_increment,\n name varchar(255) not null,\n email varchar(255) unique not null,\n short_bio varchar(255) not null,\n primary key (id)\n);\n"},"urlFrom":{"secretKeyRef":{"key":"url","name":"mysql-credentials"}}}} | ||
creationTimestamp: "2023-11-15T14:33:18Z" | ||
generation: 2 | ||
name: atlasschema-mysql | ||
namespace: default | ||
resourceVersion: "46659" | ||
uid: 54a4cdfc-e4f9-4c3d-934c-e08b6122e38a | ||
spec: | ||
schema: | ||
sql: | | ||
xcreate table users ( | ||
id int not null auto_increment, | ||
name varchar(255) not null, | ||
email varchar(255) unique not null, | ||
short_bio varchar(255) not null, | ||
primary key (id) | ||
); | ||
urlFrom: | ||
secretKeyRef: | ||
key: url | ||
name: mysql-credentials | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2023-11-15T14:38:41Z" | ||
message: |- | ||
Error: sql/migrate: read migration directory state: sql/migrate: execute: executing statement "xcreate table users (\n id int not null auto_increment,\n name varchar(255) not null,\n email varchar(255) unique not null,\n short_bio varchar(255) not null,\n primary key (id)\n);" from version "schema": Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xcreate table users ( | ||
id int not null auto_increment, | ||
name varchar(255) not ' at line 1 | ||
reason: ApplyingSchema | ||
status: "False" | ||
type: Ready | ||
last_applied: 1700058814 | ||
observed_hash: ddfe666707ddf5c2cc7625c2a0de89da51e54fc7caa6403db307146430d20d85 |
39 changes: 39 additions & 0 deletions
39
resource_customizations/db.atlasgo.io/AtlasSchema/testdata/healthy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apiVersion: db.atlasgo.io/v1alpha1 | ||
kind: AtlasSchema | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"db.atlasgo.io/v1alpha1","kind":"AtlasSchema","metadata":{"annotations":{},"name":"atlasschema-mysql","namespace":"default"},"spec":{"schema":{"sql":"create table users (\n id int not null auto_increment,\n name varchar(255) not null,\n email varchar(255) unique not null,\n short_bio varchar(255) not null,\n primary key (id)\n);\n"},"urlFrom":{"secretKeyRef":{"key":"url","name":"mysql-credentials"}}}} | ||
creationTimestamp: "2023-11-15T14:33:18Z" | ||
generation: 1 | ||
name: atlasschema-mysql | ||
namespace: default | ||
resourceVersion: "46390" | ||
uid: 54a4cdfc-e4f9-4c3d-934c-e08b6122e38a | ||
spec: | ||
schema: | ||
sql: | | ||
create table users ( | ||
id int not null auto_increment, | ||
name varchar(255) not null, | ||
email varchar(255) unique not null, | ||
short_bio varchar(255) not null, | ||
primary key (id) | ||
); | ||
urlFrom: | ||
secretKeyRef: | ||
key: url | ||
name: mysql-credentials | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2023-11-15T14:33:34Z" | ||
message: 'The schema has been applied successfully. Apply response: {"Driver":"mysql","URL":{"Scheme":"mysql","Opaque":"","User":{},"Host":"mysql.default:3306","Path":"/myapp","RawPath":"","OmitHost":false,"ForceQuery":false,"RawQuery":"parseTime=true","Fragment":"","RawFragment":"","Schema":"myapp"},"Changes":{"Applied":["CREATE | ||
TABLE `users` (\n `id` int NOT NULL AUTO_INCREMENT,\n `name` varchar(255) | ||
NOT NULL,\n `email` varchar(255) NOT NULL,\n `short_bio` varchar(255) NOT | ||
NULL,\n PRIMARY KEY (`id`),\n UNIQUE INDEX `email` (`email`)\n) CHARSET utf8mb4 | ||
COLLATE utf8mb4_0900_ai_ci"]}}' | ||
reason: Applied | ||
status: "True" | ||
type: Ready | ||
last_applied: 1700058814 | ||
observed_hash: ddfe666707ddf5c2cc7625c2a0de89da51e54fc7caa6403db307146430d20d85 |
35 changes: 35 additions & 0 deletions
35
resource_customizations/db.atlasgo.io/AtlasSchema/testdata/progressing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apiVersion: db.atlasgo.io/v1alpha1 | ||
kind: AtlasSchema | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"db.atlasgo.io/v1alpha1","kind":"AtlasSchema","metadata":{"annotations":{},"name":"atlasschema-mysql","namespace":"default"},"spec":{"schema":{"sql":"create table users (\n id int not null auto_increment,\n name varchar(255) not null,\n email varchar(255) unique not null,\n short_bio varchar(255) not null,\n primary key (id)\n);\n"},"urlFrom":{"secretKeyRef":{"key":"url","name":"mysql-credentials"}}}} | ||
creationTimestamp: "2023-11-15T14:33:18Z" | ||
generation: 1 | ||
name: atlasschema-mysql | ||
namespace: default | ||
resourceVersion: "46390" | ||
uid: 54a4cdfc-e4f9-4c3d-934c-e08b6122e38a | ||
spec: | ||
schema: | ||
sql: | | ||
create table users ( | ||
id int not null auto_increment, | ||
name varchar(255) not null, | ||
email varchar(255) unique not null, | ||
short_bio varchar(255) not null, | ||
primary key (id) | ||
); | ||
urlFrom: | ||
secretKeyRef: | ||
key: url | ||
name: mysql-credentials | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2023-11-15T14:33:34Z" | ||
message: 'Reconciling' | ||
reason: Reconciling | ||
status: "False" | ||
type: Ready | ||
last_applied: 1700058814 | ||
observed_hash: ddfe666707ddf5c2cc7625c2a0de89da51e54fc7caa6403db307146430d20d85 |