From 220dee0200fb5e80f466433c12baa26a8902d1cc Mon Sep 17 00:00:00 2001 From: Michael Haigh Date: Wed, 1 May 2024 12:22:23 -0400 Subject: [PATCH] Adding astra.netapp.io CRD health checks (#17999) --- .../astra.netapp.io/AppVault/health.lua | 13 ++ .../astra.netapp.io/AppVault/health_test.yaml | 13 ++ .../AppVault/testdata/degraded.yaml | 23 ++++ .../AppVault/testdata/healthy.yaml | 21 ++++ .../testdata/progressing_nostatus.yaml | 18 +++ .../astra.netapp.io/Application/health.lua | 17 +++ .../Application/health_test.yaml | 13 ++ .../Application/testdata/degraded.yaml | 26 ++++ .../Application/testdata/healthy.yaml | 24 ++++ .../Application/testdata/progressing.yaml | 16 +++ .../astra.netapp.io/Backup/health.lua | 16 +++ .../astra.netapp.io/Backup/health_test.yaml | 17 +++ .../Backup/testdata/degraded.yaml | 79 ++++++++++++ .../Backup/testdata/healthy.yaml | 116 ++++++++++++++++++ .../Backup/testdata/progressing_nostatus.yaml | 26 ++++ .../Backup/testdata/progressing_status.yaml | 76 ++++++++++++ .../astra.netapp.io/ExecHook/health.lua | 13 ++ .../astra.netapp.io/ExecHook/health_test.yaml | 13 ++ .../ExecHook/testdata/healthy.yaml | 23 ++++ .../testdata/progressing_nostatus.yaml | 22 ++++ .../ExecHook/testdata/suspended.yaml | 23 ++++ .../astra.netapp.io/ExecHooksRun/health.lua | 16 +++ .../ExecHooksRun/health_test.yaml | 17 +++ .../ExecHooksRun/testdata/degraded.yaml | 71 +++++++++++ .../ExecHooksRun/testdata/healthy.yaml | 71 +++++++++++ .../testdata/progressing_nostatus.yaml | 26 ++++ .../testdata/progressing_status.yaml | 69 +++++++++++ .../astra.netapp.io/ResourceBackup/health.lua | 16 +++ .../ResourceBackup/health_test.yaml | 17 +++ .../ResourceBackup/testdata/degraded.yaml | 52 ++++++++ .../ResourceBackup/testdata/healthy.yaml | 49 ++++++++ .../testdata/progressing_nostatus.yaml | 24 ++++ .../testdata/progressing_status.yaml | 48 ++++++++ .../ResticVolumeBackup/health.lua | 16 +++ .../ResticVolumeBackup/health_test.yaml | 17 +++ .../ResticVolumeBackup/testdata/degraded.yaml | 99 +++++++++++++++ .../ResticVolumeBackup/testdata/healthy.yaml | 94 ++++++++++++++ .../testdata/progressing_nostatus.yaml | 49 ++++++++ .../testdata/progressing_status.yaml | 92 ++++++++++++++ .../astra.netapp.io/Schedule/health.lua | 7 ++ .../astra.netapp.io/Schedule/health_test.yaml | 9 ++ .../Schedule/testdata/healthy_nostatus.yaml | 28 +++++ .../Schedule/testdata/healthy_status.yaml | 30 +++++ .../astra.netapp.io/Snapshot/health.lua | 16 +++ .../astra.netapp.io/Snapshot/health_test.yaml | 17 +++ .../Snapshot/testdata/degraded.yaml | 80 ++++++++++++ .../Snapshot/testdata/healthy.yaml | 81 ++++++++++++ .../testdata/progressing_nostatus.yaml | 24 ++++ .../Snapshot/testdata/progressing_status.yaml | 73 +++++++++++ 49 files changed, 1816 insertions(+) create mode 100644 resource_customizations/astra.netapp.io/AppVault/health.lua create mode 100644 resource_customizations/astra.netapp.io/AppVault/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/AppVault/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/AppVault/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/AppVault/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/Application/health.lua create mode 100644 resource_customizations/astra.netapp.io/Application/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/Application/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/Application/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/Application/testdata/progressing.yaml create mode 100644 resource_customizations/astra.netapp.io/Backup/health.lua create mode 100644 resource_customizations/astra.netapp.io/Backup/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/Backup/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/Backup/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/Backup/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/Backup/testdata/progressing_status.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHook/health.lua create mode 100644 resource_customizations/astra.netapp.io/ExecHook/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHook/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHook/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHook/testdata/suspended.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHooksRun/health.lua create mode 100644 resource_customizations/astra.netapp.io/ExecHooksRun/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHooksRun/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHooksRun/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_status.yaml create mode 100644 resource_customizations/astra.netapp.io/ResourceBackup/health.lua create mode 100644 resource_customizations/astra.netapp.io/ResourceBackup/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/ResourceBackup/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/ResourceBackup/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_status.yaml create mode 100644 resource_customizations/astra.netapp.io/ResticVolumeBackup/health.lua create mode 100644 resource_customizations/astra.netapp.io/ResticVolumeBackup/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_status.yaml create mode 100644 resource_customizations/astra.netapp.io/Schedule/health.lua create mode 100644 resource_customizations/astra.netapp.io/Schedule/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/Schedule/testdata/healthy_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/Schedule/testdata/healthy_status.yaml create mode 100644 resource_customizations/astra.netapp.io/Snapshot/health.lua create mode 100644 resource_customizations/astra.netapp.io/Snapshot/health_test.yaml create mode 100644 resource_customizations/astra.netapp.io/Snapshot/testdata/degraded.yaml create mode 100644 resource_customizations/astra.netapp.io/Snapshot/testdata/healthy.yaml create mode 100644 resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_nostatus.yaml create mode 100644 resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_status.yaml diff --git a/resource_customizations/astra.netapp.io/AppVault/health.lua b/resource_customizations/astra.netapp.io/AppVault/health.lua new file mode 100644 index 000000000000..7490ed2a89fd --- /dev/null +++ b/resource_customizations/astra.netapp.io/AppVault/health.lua @@ -0,0 +1,13 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.state ~= nil then + if obj.status.state == "available" or obj.status.state == "Available" then + hs.status = "Healthy" + hs.message = obj.kind .. " Available" + elseif obj.status.state == "failed" or obj.status.state == "Failed" then + hs.status = "Degraded" + hs.message = obj.kind .. " Failed" + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/AppVault/health_test.yaml b/resource_customizations/astra.netapp.io/AppVault/health_test.yaml new file mode 100644 index 000000000000..03918c3ecaa5 --- /dev/null +++ b/resource_customizations/astra.netapp.io/AppVault/health_test.yaml @@ -0,0 +1,13 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Healthy + message: "AppVault Available" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "AppVault Failed" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/AppVault/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/AppVault/testdata/degraded.yaml new file mode 100644 index 000000000000..0ece84574b9b --- /dev/null +++ b/resource_customizations/astra.netapp.io/AppVault/testdata/degraded.yaml @@ -0,0 +1,23 @@ +apiVersion: astra.netapp.io/v1 +kind: AppVault +metadata: + creationTimestamp: "2024-04-26T14:25:45Z" + generation: 1 + name: astra-gcp-backup-743cfd150129 + namespace: astra-connector + resourceVersion: "12094908" + uid: 12943b68-323a-4e8a-ba78-604da0801d11 +spec: + providerConfig: + bucketName: astra-gcp-backup-743cfd150129 + providerCredentials: + credentials: + valueFromSecret: + key: credentials.json + name: astra-gcp-backup-734ced050128-5rdt4 + providerType: gcp +status: + error: + 'failed to close GCP object "appVault.json" in bucket "astra-gcp-backup-743cfd150129": + googleapi: Error 404: The specified bucket does not exist., notFound' + state: failed diff --git a/resource_customizations/astra.netapp.io/AppVault/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/AppVault/testdata/healthy.yaml new file mode 100644 index 000000000000..3ea713e8ef74 --- /dev/null +++ b/resource_customizations/astra.netapp.io/AppVault/testdata/healthy.yaml @@ -0,0 +1,21 @@ +apiVersion: astra.netapp.io/v1 +kind: AppVault +metadata: + creationTimestamp: "2024-04-11T21:28:27Z" + generation: 1 + name: astra-gcp-backup-743cfd150129 + namespace: astra-connector + resourceVersion: "70908" + uid: d1b552b2-5d8e-467b-829b-1e6af7240400 +spec: + providerConfig: + bucketName: astra-gcp-backup-743cfd150129 + providerCredentials: + credentials: + valueFromSecret: + key: credentials.json + name: astra-gcp-backup-743cfd150129-5rdt4 + providerType: gcp +status: + state: available + uid: c708262e-3944-49bf-af96-ad1c3eb6cafb diff --git a/resource_customizations/astra.netapp.io/AppVault/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/AppVault/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..d6987da72c34 --- /dev/null +++ b/resource_customizations/astra.netapp.io/AppVault/testdata/progressing_nostatus.yaml @@ -0,0 +1,18 @@ +apiVersion: astra.netapp.io/v1 +kind: AppVault +metadata: + creationTimestamp: "2024-04-26T14:25:45Z" + generation: 1 + name: astra-gcp-backup-743cfd150129 + namespace: astra-connector + resourceVersion: "12094608" + uid: 12943b68-323a-4e8a-ba78-604da0801d11 +spec: + providerConfig: + bucketName: astra-gcp-backup-743cfd150129 + providerCredentials: + credentials: + valueFromSecret: + key: credentials.json + name: astra-gcp-backup-734ced050128-5rdt4 + providerType: gcp diff --git a/resource_customizations/astra.netapp.io/Application/health.lua b/resource_customizations/astra.netapp.io/Application/health.lua new file mode 100644 index 000000000000..967400d8819b --- /dev/null +++ b/resource_customizations/astra.netapp.io/Application/health.lua @@ -0,0 +1,17 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.conditions ~= nil then + for _, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" and condition.status == "True" then + hs.status = "Healthy" + hs.message = "Astra Application Ready, protectionState: " .. obj.status.protectionState + return hs + elseif condition.type == "Ready" and condition.status == "False" then + hs.status = "Degraded" + hs.message = "Astra Application Degraded, message: " .. condition.message + return hs + end + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/Application/health_test.yaml b/resource_customizations/astra.netapp.io/Application/health_test.yaml new file mode 100644 index 000000000000..d1c2bc9b769c --- /dev/null +++ b/resource_customizations/astra.netapp.io/Application/health_test.yaml @@ -0,0 +1,13 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing.yaml + - healthStatus: + status: Healthy + message: "Astra Application Ready, protectionState: protected" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "Astra Application Degraded, message: namespace wordpress is in terminating state" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/Application/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/Application/testdata/degraded.yaml new file mode 100644 index 000000000000..9b25186fa958 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Application/testdata/degraded.yaml @@ -0,0 +1,26 @@ +apiVersion: astra.netapp.io/v1 +kind: Application +metadata: + creationTimestamp: "2024-04-15T20:59:56Z" + finalizers: + - astra.netapp.io/finalizer + generation: 2 + name: wordpress + namespace: astra-connector + resourceVersion: "10484469" + uid: 5ab7cd7d-7a9b-4508-9da2-c7dcb10a69b3 +spec: + includedNamespaces: + - labelSelector: {} + namespace: wordpress +status: + conditions: + - lastTransitionTime: "2024-04-24T16:13:26Z" + message: namespace wordpress is in terminating state + reason: Ready + status: "False" + type: Ready + protectionState: partial + protectionStateDetails: + - Active backup schedule missing + - Application unavailable diff --git a/resource_customizations/astra.netapp.io/Application/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/Application/testdata/healthy.yaml new file mode 100644 index 000000000000..f42f84b1a60a --- /dev/null +++ b/resource_customizations/astra.netapp.io/Application/testdata/healthy.yaml @@ -0,0 +1,24 @@ +apiVersion: astra.netapp.io/v1 +kind: Application +metadata: + creationTimestamp: "2024-04-15T20:46:16Z" + finalizers: + - astra.netapp.io/finalizer + generation: 3 + labels: + argocd.argoproj.io/instance: ghost-demo + name: ghost + namespace: astra-connector + resourceVersion: "3235325" + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 +spec: + includedNamespaces: + - namespace: ghost +status: + conditions: + - lastTransitionTime: "2024-04-15T20:46:16Z" + message: "" + reason: Ready + status: "True" + type: Ready + protectionState: protected diff --git a/resource_customizations/astra.netapp.io/Application/testdata/progressing.yaml b/resource_customizations/astra.netapp.io/Application/testdata/progressing.yaml new file mode 100644 index 000000000000..64450c1aebc8 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Application/testdata/progressing.yaml @@ -0,0 +1,16 @@ +apiVersion: astra.netapp.io/v1 +kind: Application +metadata: + creationTimestamp: "2024-04-15T20:46:16Z" + finalizers: + - astra.netapp.io/finalizer + generation: 3 + labels: + argocd.argoproj.io/instance: ghost-demo + name: ghost + namespace: astra-connector + resourceVersion: "3235325" + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 +spec: + includedNamespaces: + - namespace: ghost diff --git a/resource_customizations/astra.netapp.io/Backup/health.lua b/resource_customizations/astra.netapp.io/Backup/health.lua new file mode 100644 index 000000000000..39de4ac74eb6 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Backup/health.lua @@ -0,0 +1,16 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.state ~= nil then + if obj.status.state == "Completed" then + hs.status = "Healthy" + hs.message = obj.kind .. " Completed" + elseif obj.status.state == "Running" then + hs.status = "Progressing" + hs.message = obj.kind .. " Running" + else + hs.status = "Degraded" + hs.message = obj.status.state + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/Backup/health_test.yaml b/resource_customizations/astra.netapp.io/Backup/health_test.yaml new file mode 100644 index 000000000000..56385a102f68 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Backup/health_test.yaml @@ -0,0 +1,17 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Progressing + message: "Backup Running" + inputPath: testdata/progressing_status.yaml + - healthStatus: + status: Healthy + message: "Backup Completed" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "Failed" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/Backup/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/Backup/testdata/degraded.yaml new file mode 100644 index 000000000000..8dbe9ca86c36 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Backup/testdata/degraded.yaml @@ -0,0 +1,79 @@ +apiVersion: astra.netapp.io/v1 +kind: Backup +metadata: + creationTimestamp: "2024-04-24T19:54:18Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: backup-20240424193746 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "10641332" + uid: ad301b6a-6536-4313-89c1-d10ad0275430 +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost +status: + conditions: + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourceSnapshotExists + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: + "Source snapshot failed with permanent error: reconcile timeout of 1h0m0s + exceeded" + reason: Failed + status: "False" + type: SourceSnapshotCompleted + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: SnapshotAppArchiveCopied + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PreBackupExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: VolumeBackupsCompleted + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PostBackupExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: TemporarySnapshotCleanedUp + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + - lastTransitionTime: "2024-04-24T19:54:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailurePostBackupExecHooksRunCompleted + error: + "Source snapshot failed with permanent error: reconcile timeout of 1h0m0s + exceeded" + progress: {} + sourceSnapshotName: backup-ad301b6a-6536-4313-89c1-d10ad0275430 + state: Failed diff --git a/resource_customizations/astra.netapp.io/Backup/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/Backup/testdata/healthy.yaml new file mode 100644 index 000000000000..d3f32fbf93d2 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Backup/testdata/healthy.yaml @@ -0,0 +1,116 @@ +apiVersion: astra.netapp.io/v1 +kind: Backup +metadata: + annotations: + astra.netapp.io/correlationid: 3c492b7e-8b1f-491a-af99-aa3fca9d54cf + created-by-astra-schedule-name: ghost-daily + created-by-astra-schedule-namespace: astra-connector + creationTimestamp: "2024-04-24T01:00:00Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + labels: + created-by-astra-schedule-uid: a2736922-6801-482c-a199-03ef8a3f35d7 + name: daily-a4587-20240424010000 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "9965658" + uid: d4b61932-5c8e-4310-82a5-37a0b671aa2d +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + snapshotRef: daily-a4587-20240424010000 +status: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/backups/daily-a4587-20240424010000_d4b61932-5c8e-4310-82a5-37a0b671aa2d + completionTimestamp: "2024-04-24T01:02:30Z" + conditions: + - lastTransitionTime: "2024-04-24T01:00:00Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T01:00:00Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourceSnapshotExists + - lastTransitionTime: "2024-04-24T01:00:30Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourceSnapshotCompleted + - lastTransitionTime: "2024-04-24T01:00:33Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SnapshotAppArchiveCopied + - lastTransitionTime: "2024-04-24T01:00:34Z" + message: Successfully reconciled + reason: Done + status: "True" + type: PreBackupExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T01:02:30Z" + message: Successfully reconciled + reason: Done + status: "True" + type: VolumeBackupsCompleted + - lastTransitionTime: "2024-04-24T01:02:30Z" + message: Successfully reconciled + reason: Done + status: "True" + type: PostBackupExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T01:02:30Z" + message: Successfully reconciled + reason: Done + status: "True" + type: TemporarySnapshotCleanedUp + - lastTransitionTime: "2024-04-24T01:02:31Z" + message: Successfully reconciled + reason: Done + status: "True" + type: Completed + - lastTransitionTime: "2024-04-24T01:00:00Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailurePostBackupExecHooksRunCompleted + postBackupExecHooksRunResults: [] + postSnapshotExecHooksRunResults: [] + preBackupExecHooksRunResults: [] + preSnapshotExecHooksRunResults: [] + progress: + volumeBackups: + - completionTimestamp: "2024-04-24T01:02:30Z" + pvcUid: b9ff9e05-5049-4862-82c6-dea080c2fe0d + resticRepositoryPath: gs:astra-gcp-backup-743cfd150129://ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/restic/ghost/ghost_b9ff9e05-5049-4862-82c6-dea080c2fe0d + resticSnapshotID: 5d066ee6e4626ec2e3eff50d766f080ba90b2339df5b9f7baf46c281d0763da6 + resticVolumeBackupCompleted: true + resticVolumeBackupCreated: true + sourceVolumeSnapshot: + name: snapshot-71804332-e19d-42a0-bc02-56bd606b9f66-pvc-b9ff9e05-5049-4862-82c6-dea080c2fe0d + namespace: ghost + volumeSnapshotContentCopyName: backup-d4b61932-5c8e-4310-82a5-37a0b671aa2d-vsc-ab718bad-fa67-4159-a761-6d1eb5de5330 + volumeSnapshotCopied: true + volumeSnapshotCopyDeleted: true + volumeSnapshotCopyName: backup-d4b61932-5c8e-4310-82a5-37a0b671aa2d-vs-d55f9b97-11e5-4fb7-89c0-a2559eba753d + volumeSnapshotCopyReadyToUse: true + - completionTimestamp: "2024-04-24T01:02:30Z" + pvcUid: 38c468b3-eed6-48f2-b43b-15083dd1c030 + resticRepositoryPath: gs:astra-gcp-backup-743cfd150129://ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/restic/ghost/mysql-pv-claim_38c468b3-eed6-48f2-b43b-15083dd1c030 + resticSnapshotID: dc601d5db3ed78823b134326c6cc9607f1636530783707eb8cd02a018b244e07 + resticVolumeBackupCompleted: true + resticVolumeBackupCreated: true + sourceVolumeSnapshot: + name: snapshot-71804332-e19d-42a0-bc02-56bd606b9f66-pvc-38c468b3-eed6-48f2-b43b-15083dd1c030 + namespace: ghost + volumeSnapshotContentCopyName: backup-d4b61932-5c8e-4310-82a5-37a0b671aa2d-vsc-df43df62-1501-406b-b7ba-90aafcd763d5 + volumeSnapshotCopied: true + volumeSnapshotCopyDeleted: true + volumeSnapshotCopyName: backup-d4b61932-5c8e-4310-82a5-37a0b671aa2d-vs-ecf680cf-1665-4320-9f84-c99911b48a2b + volumeSnapshotCopyReadyToUse: true + sourceSnapshotName: daily-a4587-20240424010000 + state: Completed diff --git a/resource_customizations/astra.netapp.io/Backup/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/Backup/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..9cc87d827cb1 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Backup/testdata/progressing_nostatus.yaml @@ -0,0 +1,26 @@ +apiVersion: astra.netapp.io/v1 +kind: Backup +metadata: + annotations: + astra.netapp.io/correlationid: 3c492b7e-8b1f-491a-af99-aa3fca9d54cf + created-by-astra-schedule-name: ghost-daily + created-by-astra-schedule-namespace: astra-connector + creationTimestamp: "2024-04-24T01:00:00Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + labels: + created-by-astra-schedule-uid: a2736922-6801-482c-a199-03ef8a3f35d7 + name: daily-a4587-20240424010000 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "9965658" + uid: d4b61932-5c8e-4310-82a5-37a0b671aa2d +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + snapshotRef: daily-a4587-20240424010000 diff --git a/resource_customizations/astra.netapp.io/Backup/testdata/progressing_status.yaml b/resource_customizations/astra.netapp.io/Backup/testdata/progressing_status.yaml new file mode 100644 index 000000000000..38477b5a3f02 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Backup/testdata/progressing_status.yaml @@ -0,0 +1,76 @@ +apiVersion: astra.netapp.io/v1 +kind: Backup +metadata: + annotations: + astra.netapp.io/correlationid: cd272631-d0a8-4a61-9cde-6a7202074051 + creationTimestamp: "2024-04-24T19:39:34Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: backup-20240424193745 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "10599529" + uid: fea5520e-553c-400d-8539-e9d2bbe5b762 +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost +status: + conditions: + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourceSnapshotExists + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Waiting for source Snapshot to complete + reason: Waiting + status: "False" + type: SourceSnapshotCompleted + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: SnapshotAppArchiveCopied + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PreBackupExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: VolumeBackupsCompleted + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PostBackupExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: TemporarySnapshotCleanedUp + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + - lastTransitionTime: "2024-04-24T19:39:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailurePostBackupExecHooksRunCompleted + progress: {} + sourceSnapshotName: backup-fea5520e-553c-400d-8539-e9d2bbe5b762 + state: Running diff --git a/resource_customizations/astra.netapp.io/ExecHook/health.lua b/resource_customizations/astra.netapp.io/ExecHook/health.lua new file mode 100644 index 000000000000..6d7389ccf070 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHook/health.lua @@ -0,0 +1,13 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.spec ~= nil then + if obj.spec.enabled ~= nil then + if obj.spec.enabled == true then + hs.status = "Healthy" + hs.message = obj.kind .. " enabled" + elseif obj.spec.enabled == false then + hs.status = "Suspended" + hs.message = obj.kind .. " disabled" + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/ExecHook/health_test.yaml b/resource_customizations/astra.netapp.io/ExecHook/health_test.yaml new file mode 100644 index 000000000000..abe46b3f6714 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHook/health_test.yaml @@ -0,0 +1,13 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Healthy + message: "ExecHook enabled" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Suspended + message: "ExecHook disabled" + inputPath: testdata/suspended.yaml diff --git a/resource_customizations/astra.netapp.io/ExecHook/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/ExecHook/testdata/healthy.yaml new file mode 100644 index 000000000000..fd0e7ad1af15 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHook/testdata/healthy.yaml @@ -0,0 +1,23 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHook +metadata: + creationTimestamp: "2024-04-25T14:17:52Z" + generation: 1 + labels: + argocd.argoproj.io/instance: ghost-demo + name: pre-snapshot + namespace: astra-connector + resourceVersion: "11239151" + uid: 105679e3-4acc-4618-a3c2-53e0e5949f65 +spec: + action: snapshot + applicationRef: ghost + arguments: + - pre + enabled: true + hookSource: IyEvYmluL3NoCgojCiMgc3VjY2Vzc19zYW1wbGUuc2gKIwojIEEgc2ltcGxlIG5vb3Agc3VjY2VzcyBob29rIHNjcmlwdCBmb3IgdGVzdGluZyBwdXJwb3Nlcy4KIwojIGFyZ3M6IE5vbmUKIwoKCiMKIyBXcml0ZXMgdGhlIGdpdmVuIG1lc3NhZ2UgdG8gc3RhbmRhcmQgb3V0cHV0CiMKIyAkKiAtIFRoZSBtZXNzYWdlIHRvIHdyaXRlCiMKbXNnKCkgewogICAgZWNobyAiJCoiCn0KCgojCiMgV3JpdGVzIHRoZSBnaXZlbiBpbmZvcm1hdGlvbiBtZXNzYWdlIHRvIHN0YW5kYXJkIG91dHB1dAojCiMgJCogLSBUaGUgbWVzc2FnZSB0byB3cml0ZQojCmluZm8oKSB7CiAgICBtc2cgIklORk86ICQqIgp9CgojCiMgV3JpdGVzIHRoZSBnaXZlbiBlcnJvciBtZXNzYWdlIHRvIHN0YW5kYXJkIGVycm9yCiMKIyAkKiAtIFRoZSBtZXNzYWdlIHRvIHdyaXRlCiMKZXJyb3IoKSB7CiAgICBtc2cgIkVSUk9SOiAkKiIgMT4mMgp9CgoKIwojIG1haW4KIwoKIyBsb2cgc29tZXRoaW5nIHRvIHN0ZG91dAppbmZvICJydW5uaW5nIHN1Y2Nlc3Nfc2FtcGxlLnNoIgoKIyBleGl0IHdpdGggMCB0byBpbmRpY2F0ZSBzdWNjZXNzIAppbmZvICJleGl0IDAiCmV4aXQgMA== + matchingCriteria: + - type: containerImage + value: mysql + stage: pre + timeout: 25 diff --git a/resource_customizations/astra.netapp.io/ExecHook/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/ExecHook/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..ba5af3f288bf --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHook/testdata/progressing_nostatus.yaml @@ -0,0 +1,22 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHook +metadata: + creationTimestamp: "2024-04-25T14:17:52Z" + generation: 3 + labels: + argocd.argoproj.io/instance: ghost-demo + name: pre-snapshot + namespace: astra-connector + resourceVersion: "11342335" + uid: 105679e3-4acc-4618-a3c2-53e0e5949f65 +spec: + action: snapshot + applicationRef: ghost + arguments: + - pre + hookSource: IyEvYmluL3NoCgojCiMgc3VjY2Vzc19zYW1wbGUuc2gKIwojIEEgc2ltcGxlIG5vb3Agc3VjY2VzcyBob29rIHNjcmlwdCBmb3IgdGVzdGluZyBwdXJwb3Nlcy4KIwojIGFyZ3M6IE5vbmUKIwoKCiMKIyBXcml0ZXMgdGhlIGdpdmVuIG1lc3NhZ2UgdG8gc3RhbmRhcmQgb3V0cHV0CiMKIyAkKiAtIFRoZSBtZXNzYWdlIHRvIHdyaXRlCiMKbXNnKCkgewogICAgZWNobyAiJCoiCn0KCgojCiMgV3JpdGVzIHRoZSBnaXZlbiBpbmZvcm1hdGlvbiBtZXNzYWdlIHRvIHN0YW5kYXJkIG91dHB1dAojCiMgJCogLSBUaGUgbWVzc2FnZSB0byB3cml0ZQojCmluZm8oKSB7CiAgICBtc2cgIklORk86ICQqIgp9CgojCiMgV3JpdGVzIHRoZSBnaXZlbiBlcnJvciBtZXNzYWdlIHRvIHN0YW5kYXJkIGVycm9yCiMKIyAkKiAtIFRoZSBtZXNzYWdlIHRvIHdyaXRlCiMKZXJyb3IoKSB7CiAgICBtc2cgIkVSUk9SOiAkKiIgMT4mMgp9CgoKIwojIG1haW4KIwoKIyBsb2cgc29tZXRoaW5nIHRvIHN0ZG91dAppbmZvICJydW5uaW5nIHN1Y2Nlc3Nfc2FtcGxlLnNoIgoKIyBleGl0IHdpdGggMCB0byBpbmRpY2F0ZSBzdWNjZXNzIAppbmZvICJleGl0IDAiCnNsZWVwIDMwMApleGl0IDA= + matchingCriteria: + - type: containerImage + value: mysql + stage: pre + timeout: 25 diff --git a/resource_customizations/astra.netapp.io/ExecHook/testdata/suspended.yaml b/resource_customizations/astra.netapp.io/ExecHook/testdata/suspended.yaml new file mode 100644 index 000000000000..607b3df61616 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHook/testdata/suspended.yaml @@ -0,0 +1,23 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHook +metadata: + creationTimestamp: "2024-04-25T14:17:52Z" + generation: 3 + labels: + argocd.argoproj.io/instance: ghost-demo + name: pre-snapshot + namespace: astra-connector + resourceVersion: "11342335" + uid: 105679e3-4acc-4618-a3c2-53e0e5949f65 +spec: + action: snapshot + applicationRef: ghost + arguments: + - pre + enabled: false + hookSource: IyEvYmluL3NoCgojCiMgc3VjY2Vzc19zYW1wbGUuc2gKIwojIEEgc2ltcGxlIG5vb3Agc3VjY2VzcyBob29rIHNjcmlwdCBmb3IgdGVzdGluZyBwdXJwb3Nlcy4KIwojIGFyZ3M6IE5vbmUKIwoKCiMKIyBXcml0ZXMgdGhlIGdpdmVuIG1lc3NhZ2UgdG8gc3RhbmRhcmQgb3V0cHV0CiMKIyAkKiAtIFRoZSBtZXNzYWdlIHRvIHdyaXRlCiMKbXNnKCkgewogICAgZWNobyAiJCoiCn0KCgojCiMgV3JpdGVzIHRoZSBnaXZlbiBpbmZvcm1hdGlvbiBtZXNzYWdlIHRvIHN0YW5kYXJkIG91dHB1dAojCiMgJCogLSBUaGUgbWVzc2FnZSB0byB3cml0ZQojCmluZm8oKSB7CiAgICBtc2cgIklORk86ICQqIgp9CgojCiMgV3JpdGVzIHRoZSBnaXZlbiBlcnJvciBtZXNzYWdlIHRvIHN0YW5kYXJkIGVycm9yCiMKIyAkKiAtIFRoZSBtZXNzYWdlIHRvIHdyaXRlCiMKZXJyb3IoKSB7CiAgICBtc2cgIkVSUk9SOiAkKiIgMT4mMgp9CgoKIwojIG1haW4KIwoKIyBsb2cgc29tZXRoaW5nIHRvIHN0ZG91dAppbmZvICJydW5uaW5nIHN1Y2Nlc3Nfc2FtcGxlLnNoIgoKIyBleGl0IHdpdGggMCB0byBpbmRpY2F0ZSBzdWNjZXNzIAppbmZvICJleGl0IDAiCnNsZWVwIDMwMApleGl0IDA= + matchingCriteria: + - type: containerImage + value: mysql + stage: pre + timeout: 25 diff --git a/resource_customizations/astra.netapp.io/ExecHooksRun/health.lua b/resource_customizations/astra.netapp.io/ExecHooksRun/health.lua new file mode 100644 index 000000000000..39de4ac74eb6 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHooksRun/health.lua @@ -0,0 +1,16 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.state ~= nil then + if obj.status.state == "Completed" then + hs.status = "Healthy" + hs.message = obj.kind .. " Completed" + elseif obj.status.state == "Running" then + hs.status = "Progressing" + hs.message = obj.kind .. " Running" + else + hs.status = "Degraded" + hs.message = obj.status.state + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/ExecHooksRun/health_test.yaml b/resource_customizations/astra.netapp.io/ExecHooksRun/health_test.yaml new file mode 100644 index 000000000000..52b629e5e701 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHooksRun/health_test.yaml @@ -0,0 +1,17 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Progressing + message: "ExecHooksRun Running" + inputPath: testdata/progressing_status.yaml + - healthStatus: + status: Healthy + message: "ExecHooksRun Completed" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "Failed" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/degraded.yaml new file mode 100644 index 000000000000..d8822c311f44 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/degraded.yaml @@ -0,0 +1,71 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHooksRun +metadata: + annotations: + astra.netapp.io/correlationid: 1c47a636-f819-43f3-baee-054793424bb5 + creationTimestamp: "2024-04-25T17:00:50Z" + generation: 1 + name: post-snapshot-073d13d7-4a0c-4c5e-914f-331ef6d00de2 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: argo-presync-20240425163524 + uid: 073d13d7-4a0c-4c5e-914f-331ef6d00de2 + resourceVersion: "11335239" + uid: 9bfcda95-2731-47dc-8eb2-6e83ae19da00 +spec: + action: snapshot + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240425163526_argo-presync-20240425163524_073d13d7-4a0c-4c5e-914f-331ef6d00de2 + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + resourceFilter: {} + stage: post +status: + completionTimestamp: "2024-04-25T17:00:56Z" + conditions: + - lastTransitionTime: "2024-04-25T17:00:50Z" + message: failed to get application archive + reason: Done + status: "False" + type: RetrievedMatchingContainers + - lastTransitionTime: "2024-04-25T17:00:50Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: WaitForReadiness + - lastTransitionTime: "2024-04-25T17:00:56Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: ProcessMatchingContainers + - lastTransitionTime: "2024-04-25T17:00:56Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: ArchiveExecHooksUsed + - lastTransitionTime: "2024-04-25T17:00:56Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + - lastTransitionTime: "2024-04-25T17:00:50Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailureArchiveExecHooksUsed + matchingContainers: + - completionTimestamp: "2024-04-25T17:00:56Z" + containerImage: docker.io/bitnami/mysql:8.0.32-debian-11-r8 + containerName: mysql + execHookRef: post-snapshot + execHookUID: 2cafb1b4-2575-426c-8102-29437ebee48b + jobName: ehr-47223ea8dd0115ca18a986c77380aeb3 + namespace: ghost + podName: ghost-mysql-5bfb6bc8f5-stw4w + podUID: 15ddfce0-1565-4574-89a6-80662450aedd + startTimestamp: "2024-04-25T17:00:50Z" + state: Failed diff --git a/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/healthy.yaml new file mode 100644 index 000000000000..0d237f0eb75a --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/healthy.yaml @@ -0,0 +1,71 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHooksRun +metadata: + annotations: + astra.netapp.io/correlationid: 1c47a636-f819-43f3-baee-054793424bb5 + creationTimestamp: "2024-04-25T17:00:50Z" + generation: 1 + name: post-snapshot-073d13d7-4a0c-4c5e-914f-331ef6d00de2 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: argo-presync-20240425163524 + uid: 073d13d7-4a0c-4c5e-914f-331ef6d00de2 + resourceVersion: "11335239" + uid: 9bfcda95-2731-47dc-8eb2-6e83ae19da00 +spec: + action: snapshot + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240425163526_argo-presync-20240425163524_073d13d7-4a0c-4c5e-914f-331ef6d00de2 + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + resourceFilter: {} + stage: post +status: + completionTimestamp: "2024-04-25T17:00:56Z" + conditions: + - lastTransitionTime: "2024-04-25T17:00:50Z" + message: Found 1 matching container/exechook pairs + reason: Done + status: "True" + type: RetrievedMatchingContainers + - lastTransitionTime: "2024-04-25T17:00:50Z" + message: Wait only needed on a restore + reason: Done + status: "True" + type: WaitForReadiness + - lastTransitionTime: "2024-04-25T17:00:56Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ProcessMatchingContainers + - lastTransitionTime: "2024-04-25T17:00:56Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ArchiveExecHooksUsed + - lastTransitionTime: "2024-04-25T17:00:56Z" + message: Successfully reconciled + reason: Done + status: "True" + type: Completed + - lastTransitionTime: "2024-04-25T17:00:50Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailureArchiveExecHooksUsed + matchingContainers: + - completionTimestamp: "2024-04-25T17:00:56Z" + containerImage: docker.io/bitnami/mysql:8.0.32-debian-11-r8 + containerName: mysql + execHookRef: post-snapshot + execHookUID: 2cafb1b4-2575-426c-8102-29437ebee48b + jobName: ehr-47223ea8dd0115ca18a986c77380aeb3 + namespace: ghost + podName: ghost-mysql-5bfb6bc8f5-stw4w + podUID: 15ddfce0-1565-4574-89a6-80662450aedd + startTimestamp: "2024-04-25T17:00:50Z" + state: Completed diff --git a/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..4d3b6704d4d2 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_nostatus.yaml @@ -0,0 +1,26 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHooksRun +metadata: + annotations: + astra.netapp.io/correlationid: 1c47a636-f819-43f3-baee-054793424bb5 + creationTimestamp: "2024-04-25T16:35:34Z" + generation: 1 + name: pre-snapshot-073d13d7-4a0c-4c5e-914f-331ef6d00de2 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: argo-presync-20240425163524 + uid: 073d13d7-4a0c-4c5e-914f-331ef6d00de2 + resourceVersion: "11320392" + uid: 064199e2-d540-4628-b4ec-5b417bb85128 +spec: + action: snapshot + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240425163526_argo-presync-20240425163524_073d13d7-4a0c-4c5e-914f-331ef6d00de2 + appVaultRef: astra-gcp-backup-734ced050128 + applicationRef: ghost + completionTimeout: 0s + resourceFilter: {} + stage: pre diff --git a/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_status.yaml b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_status.yaml new file mode 100644 index 000000000000..44578700d61d --- /dev/null +++ b/resource_customizations/astra.netapp.io/ExecHooksRun/testdata/progressing_status.yaml @@ -0,0 +1,69 @@ +apiVersion: astra.netapp.io/v1 +kind: ExecHooksRun +metadata: + annotations: + astra.netapp.io/correlationid: 1c47a636-f819-43f3-baee-054793424bb5 + creationTimestamp: "2024-04-25T16:35:34Z" + generation: 1 + name: pre-snapshot-073d13d7-4a0c-4c5e-914f-331ef6d00de2 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: argo-presync-20240425163524 + uid: 073d13d7-4a0c-4c5e-914f-331ef6d00de2 + resourceVersion: "11320407" + uid: 064199e2-d540-4628-b4ec-5b417bb85128 +spec: + action: snapshot + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240425163526_argo-presync-20240425163524_073d13d7-4a0c-4c5e-914f-331ef6d00de2 + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + resourceFilter: {} + stage: pre +status: + conditions: + - lastTransitionTime: "2024-04-25T16:35:34Z" + message: Found 1 matching container/exechook pairs + reason: Done + status: "True" + type: RetrievedMatchingContainers + - lastTransitionTime: "2024-04-25T16:35:34Z" + message: Wait only needed on a restore + reason: Done + status: "True" + type: WaitForReadiness + - lastTransitionTime: "2024-04-25T16:35:34Z" + message: Waiting + reason: Waiting + status: "False" + type: ProcessMatchingContainers + - lastTransitionTime: "2024-04-25T16:35:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: ArchiveExecHooksUsed + - lastTransitionTime: "2024-04-25T16:35:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + - lastTransitionTime: "2024-04-25T16:35:34Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailureArchiveExecHooksUsed + matchingContainers: + - containerImage: docker.io/bitnami/mysql:8.0.32-debian-11-r8 + containerName: mysql + execHookRef: pre-snapshot + execHookUID: 105679e3-4acc-4618-a3c2-53e0e5949f65 + jobName: ehr-ea0e89c8221790b54e94b4ac937aeac2 + namespace: ghost + podName: ghost-mysql-5bfb6bc8f5-stw4w + podUID: 15ddfce0-1565-4574-89a6-80662450aedd + startTimestamp: "2024-04-25T16:35:34Z" + state: Running diff --git a/resource_customizations/astra.netapp.io/ResourceBackup/health.lua b/resource_customizations/astra.netapp.io/ResourceBackup/health.lua new file mode 100644 index 000000000000..39de4ac74eb6 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResourceBackup/health.lua @@ -0,0 +1,16 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.state ~= nil then + if obj.status.state == "Completed" then + hs.status = "Healthy" + hs.message = obj.kind .. " Completed" + elseif obj.status.state == "Running" then + hs.status = "Progressing" + hs.message = obj.kind .. " Running" + else + hs.status = "Degraded" + hs.message = obj.status.state + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/ResourceBackup/health_test.yaml b/resource_customizations/astra.netapp.io/ResourceBackup/health_test.yaml new file mode 100644 index 000000000000..21668ca2006e --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResourceBackup/health_test.yaml @@ -0,0 +1,17 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Progressing + message: "ResourceBackup Running" + inputPath: testdata/progressing_status.yaml + - healthStatus: + status: Healthy + message: "ResourceBackup Completed" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "Error" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/ResourceBackup/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/degraded.yaml new file mode 100644 index 000000000000..dc8bcd087f06 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/degraded.yaml @@ -0,0 +1,52 @@ +apiVersion: astra.netapp.io/v1 +kind: ResourceBackup +metadata: + annotations: + astra.netapp.io/correlationid: 6094b54d-b02b-475a-b5db-136729841240 + creationTimestamp: "2024-04-24T19:54:19Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: snapshot-7b0d4f5e-53d0-4742-adec-15ef5d527865 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: backup-ad301b6a-6536-4313-89c1-d10ad0275430 + uid: 7b0d4f5e-53d0-4742-adec-15ef5d527865 + resourceVersion: "10608354" + uid: 9f8505a1-29ac-4755-92b5-536e6d825c35 +spec: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424195419_backup-ad301b6a-6536-4313-89c1-d10ad0275430_7b0d4f5e-53d0-4742-adec-15ef5d527865 + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost +status: + conditions: + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: + 'unable to fetch appVault: AppVault.astra.netapp.io "astra-gcp-backup-743cfd150129" + not found' + reason: Error + status: "False" + type: JobCreated + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: JobCompleted + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: JobCleanedUp + error: + 'unable to fetch appVault: AppVault.astra.netapp.io "astra-gcp-backup-743cfd150129" + not found' + state: Error diff --git a/resource_customizations/astra.netapp.io/ResourceBackup/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/healthy.yaml new file mode 100644 index 000000000000..047ccbf583b5 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/healthy.yaml @@ -0,0 +1,49 @@ +apiVersion: astra.netapp.io/v1 +kind: ResourceBackup +metadata: + annotations: + astra.netapp.io/correlationid: 5b89a58c-9b7c-42e8-b426-c8f863e88f41 + creationTimestamp: "2024-04-18T02:00:00Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: snapshot-0b1c9d28-33bd-45ce-b75b-2a45721e7218 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: daily-02c95-20240418020000 + uid: 0b1c9d28-33bd-45ce-b75b-2a45721e7218 + resourceVersion: "5060306" + uid: 28c08689-2f8d-4b1e-bfa4-ac8c8795adff +spec: + appArchivePath: wordpress_5ab7cd7d-7a9b-4508-9da2-c7dcb10a69b3/snapshots/20240418020000_daily-02c95-20240418020000_0b1c9d28-33bd-45ce-b75b-2a45721e7218 + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: wordpress +status: + appArchivePath: wordpress_5ab7cd7d-7a9b-4508-9da2-c7dcb10a69b3/snapshots/20240418020000_daily-02c95-20240418020000_0b1c9d28-33bd-45ce-b75b-2a45721e7218 + completionTimestamp: "2024-04-18T02:00:09Z" + conditions: + - lastTransitionTime: "2024-04-18T02:00:00Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-18T02:00:00Z" + message: Successfully reconciled + reason: Done + status: "True" + type: JobCreated + - lastTransitionTime: "2024-04-18T02:00:09Z" + message: Successfully reconciled + reason: Done + status: "True" + type: JobCompleted + - lastTransitionTime: "2024-04-18T02:00:10Z" + message: Successfully reconciled + reason: Done + status: "True" + type: JobCleanedUp + state: Completed diff --git a/resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..e4e5f9f6512d --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_nostatus.yaml @@ -0,0 +1,24 @@ +apiVersion: astra.netapp.io/v1 +kind: ResourceBackup +metadata: + annotations: + astra.netapp.io/correlationid: ee3baf3b-c470-486f-a327-47a6eada0722 + creationTimestamp: "2024-04-24T21:30:21Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: snapshot-0796d78d-e751-4835-a0d4-be61b9f9076a + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: argo-presync-20240424213020 + uid: 0796d78d-e751-4835-a0d4-be61b9f9076a + resourceVersion: "10661760" + uid: 6ed660f0-95be-4369-b548-15cb094a44c2 +spec: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424213020_argo-presync-20240424213020_0796d78d-e751-4835-a0d4-be61b9f9076a + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost diff --git a/resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_status.yaml b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_status.yaml new file mode 100644 index 000000000000..ba27f3627f79 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResourceBackup/testdata/progressing_status.yaml @@ -0,0 +1,48 @@ +apiVersion: astra.netapp.io/v1 +kind: ResourceBackup +metadata: + annotations: + astra.netapp.io/correlationid: ee3baf3b-c470-486f-a327-47a6eada0722 + creationTimestamp: "2024-04-24T21:30:21Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: snapshot-0796d78d-e751-4835-a0d4-be61b9f9076a + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Snapshot + name: argo-presync-20240424213020 + uid: 0796d78d-e751-4835-a0d4-be61b9f9076a + resourceVersion: "10661760" + uid: 6ed660f0-95be-4369-b548-15cb094a44c2 +spec: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424213020_argo-presync-20240424213020_0796d78d-e751-4835-a0d4-be61b9f9076a + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost +status: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424213020_argo-presync-20240424213020_0796d78d-e751-4835-a0d4-be61b9f9076a + conditions: + - lastTransitionTime: "2024-04-24T21:30:21Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T21:30:21Z" + message: Successfully reconciled + reason: Done + status: "True" + type: JobCreated + - lastTransitionTime: "2024-04-24T21:30:21Z" + message: waiting for resource backup job to complete + reason: Waiting + status: "False" + type: JobCompleted + - lastTransitionTime: "2024-04-24T21:30:21Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: JobCleanedUp + state: Running diff --git a/resource_customizations/astra.netapp.io/ResticVolumeBackup/health.lua b/resource_customizations/astra.netapp.io/ResticVolumeBackup/health.lua new file mode 100644 index 000000000000..39de4ac74eb6 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResticVolumeBackup/health.lua @@ -0,0 +1,16 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.state ~= nil then + if obj.status.state == "Completed" then + hs.status = "Healthy" + hs.message = obj.kind .. " Completed" + elseif obj.status.state == "Running" then + hs.status = "Progressing" + hs.message = obj.kind .. " Running" + else + hs.status = "Degraded" + hs.message = obj.status.state + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/ResticVolumeBackup/health_test.yaml b/resource_customizations/astra.netapp.io/ResticVolumeBackup/health_test.yaml new file mode 100644 index 000000000000..2038e85656a2 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResticVolumeBackup/health_test.yaml @@ -0,0 +1,17 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Progressing + message: "ResticVolumeBackup Running" + inputPath: testdata/progressing_status.yaml + - healthStatus: + status: Healthy + message: "ResticVolumeBackup Completed" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "Failed" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/degraded.yaml new file mode 100644 index 000000000000..dd1e080791b2 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/degraded.yaml @@ -0,0 +1,99 @@ +apiVersion: astra.netapp.io/v1 +kind: ResticVolumeBackup +metadata: + annotations: + astra.netapp.io/correlationid: 26d34f64-38cc-4775-881d-a2fa12437f4b + creationTimestamp: "2024-04-17T13:50:44Z" + deletionGracePeriodSeconds: 0 + deletionTimestamp: "2024-04-17T14:51:28Z" + finalizers: + - astra.netapp.io/finalizer + generation: 2 + name: backup-8f2ae7bd-82fc-4b4f-a22d-d08edc2e4e27-vs-54c8ec7f-42e8-48aa-b347-d4acab7b877b + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Backup + name: hourly-acde9-20240417135000 + uid: 8f2ae7bd-82fc-4b4f-a22d-d08edc2e4e27 + resourceVersion: "4675672" + uid: ba90a4f7-a68f-4978-bc04-86902281adc2 +spec: + clonePVC: + metadata: {} + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 100Gi + storageClassName: netapp-cvs-perf-premium + dataSourceRef: + apiGroup: snapshot.storage.k8s.io + kind: VolumeSnapshot + name: backup-8f2ae7bd-82fc-4b4f-a22d-d08edc2e4e27-vs-54c8ec7f-42e8-48aa-b347-d4acab7b877b + resticEnv: + - name: GOOGLE_PROJECT_ID + - name: GOOGLE_APPLICATION_CREDENTIALS + value: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4/credentials.json + - name: RESTIC_PASSWORD + value: password + resticRepository: gs:astra-gcp-backup-743cfd150129://ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/restic/ghost/ghost_b9ff9e05-5049-4862-82c6-dea080c2fe0d + resticVolumeMounts: + - mount: + mountPath: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4 + name: secret-astra-gcp-backup-743cfd150129-5rdt4 + readOnly: true + source: + items: + - key: credentials.json + path: credentials.json + secretName: astra-gcp-backup-743cfd150129-5rdt4 +status: + clonePVCName: restic-volume-backup-ba90a4f7-a68f-4978-bc04-86902281adc2 + clonePVName: "" + conditions: + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourcePVCExists + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ResticJobCreated + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: + "restic job restic-volume-backup-ba90a4f7-a68f-4978-bc04-86902281adc2 + failed: permanent error" + reason: Failed + status: "False" + type: ResticJobCompleted + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: ResticJobCleanedUp + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: TemporaryPVCCloneCleanedUp + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: TemporaryPVCloneCleanedUp + - lastTransitionTime: "2024-04-17T13:50:44Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + error: + "restic job restic-volume-backup-ba90a4f7-a68f-4978-bc04-86902281adc2 failed: + permanent error" + resticJobName: restic-volume-backup-ba90a4f7-a68f-4978-bc04-86902281adc2 + state: Failed diff --git a/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/healthy.yaml new file mode 100644 index 000000000000..55d5fdf49055 --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/healthy.yaml @@ -0,0 +1,94 @@ +apiVersion: astra.netapp.io/v1 +kind: ResticVolumeBackup +metadata: + annotations: + astra.netapp.io/correlationid: 2d54c3e9-2b18-4ce9-958e-4c307619e4e7 + creationTimestamp: "2024-04-25T20:30:15Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: backup-40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14-vs-78b36b0d-52db-4b24-afe4-ceec56209bbb + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Backup + name: hourly-acde9-20240425195000 + uid: 40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14 + resourceVersion: "11460297" + uid: f3424a57-862e-4609-88ce-e534a655a5d6 +spec: + clonePVC: + metadata: {} + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + storageClassName: netapp-cvs-perf-premium + dataSourceRef: + apiGroup: snapshot.storage.k8s.io + kind: VolumeSnapshot + name: backup-40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14-vs-78b36b0d-52db-4b24-afe4-ceec56209bbb + resticEnv: + - name: GOOGLE_PROJECT_ID + - name: GOOGLE_APPLICATION_CREDENTIALS + value: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4/credentials.json + - name: RESTIC_PASSWORD + value: password + resticRepository: gs:astra-gcp-backup-743cfd150129://ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/restic/ghost/mysql-pv-claim_5749beb5-e09a-4286-8cb4-1af9750f6929 + resticVolumeMounts: + - mount: + mountPath: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4 + name: secret-astra-gcp-backup-743cfd150129-5rdt4 + readOnly: true + source: + items: + - key: credentials.json + path: credentials.json + secretName: astra-gcp-backup-743cfd150129-5rdt4 +status: + clonePVCName: restic-volume-backup-f3424a57-862e-4609-88ce-e534a655a5d6 + clonePVName: pvc-90470af6-7d44-4500-80c1-99f925193654 + completionTimestamp: "2024-04-25T20:31:57Z" + conditions: + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourcePVCExists + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ResticJobCreated + - lastTransitionTime: "2024-04-25T20:30:54Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ResticJobCompleted + - lastTransitionTime: "2024-04-25T20:30:54Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ResticJobCleanedUp + - lastTransitionTime: "2024-04-25T20:30:54Z" + message: Successfully reconciled + reason: Done + status: "True" + type: TemporaryPVCCloneCleanedUp + - lastTransitionTime: "2024-04-25T20:31:57Z" + message: Successfully reconciled + reason: Done + status: "True" + type: TemporaryPVCloneCleanedUp + - lastTransitionTime: "2024-04-25T20:31:57Z" + message: Successfully reconciled + reason: Done + status: "True" + type: Completed + resticJobName: restic-volume-backup-f3424a57-862e-4609-88ce-e534a655a5d6 + resticSnapshotID: 88c5684cf3e0cd73e57d96f11d20b1c6b03c913cf574cb73cb40da95078d6694 + state: Completed diff --git a/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..b622e552015f --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_nostatus.yaml @@ -0,0 +1,49 @@ +apiVersion: astra.netapp.io/v1 +kind: ResticVolumeBackup +metadata: + creationTimestamp: "2024-04-25T20:30:15Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: backup-40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14-vs-78b36b0d-52db-4b24-afe4-ceec56209bbb + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Backup + name: hourly-acde9-20240425195000 + uid: 40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14 + resourceVersion: "11459172" + uid: f3424a57-862e-4609-88ce-e534a655a5d6 +spec: + clonePVC: + metadata: {} + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + storageClassName: netapp-cvs-perf-premium + dataSourceRef: + apiGroup: snapshot.storage.k8s.io + kind: VolumeSnapshot + name: backup-40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14-vs-78b36b0d-52db-4b24-afe4-ceec56209bbb + resticEnv: + - name: GOOGLE_PROJECT_ID + - name: GOOGLE_APPLICATION_CREDENTIALS + value: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4/credentials.json + - name: RESTIC_PASSWORD + value: password + resticRepository: gs:astra-gcp-backup-743cfd150129://ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/restic/ghost/mysql-pv-claim_5749beb5-e09a-4286-8cb4-1af9750f6929 + resticVolumeMounts: + - mount: + mountPath: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4 + name: secret-astra-gcp-backup-743cfd150129-5rdt4 + readOnly: true + source: + items: + - key: credentials.json + path: credentials.json + secretName: astra-gcp-backup-743cfd150129-5rdt4 diff --git a/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_status.yaml b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_status.yaml new file mode 100644 index 000000000000..e0889bf955fd --- /dev/null +++ b/resource_customizations/astra.netapp.io/ResticVolumeBackup/testdata/progressing_status.yaml @@ -0,0 +1,92 @@ +apiVersion: astra.netapp.io/v1 +kind: ResticVolumeBackup +metadata: + annotations: + astra.netapp.io/correlationid: 2d54c3e9-2b18-4ce9-958e-4c307619e4e7 + creationTimestamp: "2024-04-25T20:30:15Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: backup-40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14-vs-78b36b0d-52db-4b24-afe4-ceec56209bbb + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Backup + name: hourly-acde9-20240425195000 + uid: 40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14 + resourceVersion: "11459181" + uid: f3424a57-862e-4609-88ce-e534a655a5d6 +spec: + clonePVC: + metadata: {} + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + storageClassName: netapp-cvs-perf-premium + dataSourceRef: + apiGroup: snapshot.storage.k8s.io + kind: VolumeSnapshot + name: backup-40b1dc7d-f1c0-4c3d-b34e-d7db5cc26d14-vs-78b36b0d-52db-4b24-afe4-ceec56209bbb + resticEnv: + - name: GOOGLE_PROJECT_ID + - name: GOOGLE_APPLICATION_CREDENTIALS + value: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4/credentials.json + - name: RESTIC_PASSWORD + value: password + resticRepository: gs:astra-gcp-backup-743cfd150129://ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/restic/ghost/mysql-pv-claim_5749beb5-e09a-4286-8cb4-1af9750f6929 + resticVolumeMounts: + - mount: + mountPath: /var/run/secrets/neptune/astra-gcp-backup-743cfd150129-5rdt4 + name: secret-astra-gcp-backup-743cfd150129-5rdt4 + readOnly: true + source: + items: + - key: credentials.json + path: credentials.json + secretName: astra-gcp-backup-743cfd150129-5rdt4 +status: + clonePVCName: restic-volume-backup-f3424a57-862e-4609-88ce-e534a655a5d6 + clonePVName: "" + conditions: + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Successfully reconciled + reason: Done + status: "True" + type: SourcePVCExists + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ResticJobCreated + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: ResticJobCompleted + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: ResticJobCleanedUp + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: TemporaryPVCCloneCleanedUp + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: TemporaryPVCloneCleanedUp + - lastTransitionTime: "2024-04-25T20:30:15Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + resticJobName: restic-volume-backup-f3424a57-862e-4609-88ce-e534a655a5d6 + state: Running diff --git a/resource_customizations/astra.netapp.io/Schedule/health.lua b/resource_customizations/astra.netapp.io/Schedule/health.lua new file mode 100644 index 000000000000..5d122593e5b0 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Schedule/health.lua @@ -0,0 +1,7 @@ +hs = { status = "Healthy", message = "Protection policy not yet executed" } +if obj.status ~= nil then + if obj.status.lastScheduleTime ~= nil then + hs.message = "Protection policy lastScheduleTime: " .. obj.status.lastScheduleTime + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/Schedule/health_test.yaml b/resource_customizations/astra.netapp.io/Schedule/health_test.yaml new file mode 100644 index 000000000000..73414e0b58d5 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Schedule/health_test.yaml @@ -0,0 +1,9 @@ +tests: + - healthStatus: + status: Healthy + message: "Protection policy not yet executed" + inputPath: testdata/healthy_nostatus.yaml + - healthStatus: + status: Healthy + message: "Protection policy lastScheduleTime: 2024-04-24T01:00:00Z" + inputPath: testdata/healthy_status.yaml diff --git a/resource_customizations/astra.netapp.io/Schedule/testdata/healthy_nostatus.yaml b/resource_customizations/astra.netapp.io/Schedule/testdata/healthy_nostatus.yaml new file mode 100644 index 000000000000..0456fb39fc0f --- /dev/null +++ b/resource_customizations/astra.netapp.io/Schedule/testdata/healthy_nostatus.yaml @@ -0,0 +1,28 @@ +apiVersion: astra.netapp.io/v1 +kind: Schedule +metadata: + creationTimestamp: "2024-04-15T20:46:16Z" + generation: 2 + labels: + argocd.argoproj.io/instance: ghost-demo + name: ghost-monthly + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "3231157" + uid: f75ebc6f-627c-4b34-ba36-e64ddc3948e3 +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + backupRetention: "1" + dayOfMonth: "1" + dayOfWeek: "" + enabled: true + granularity: monthly + hour: "2" + minute: "0" + recurrenceRule: "" + snapshotRetention: "1" diff --git a/resource_customizations/astra.netapp.io/Schedule/testdata/healthy_status.yaml b/resource_customizations/astra.netapp.io/Schedule/testdata/healthy_status.yaml new file mode 100644 index 000000000000..71f99ddf2329 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Schedule/testdata/healthy_status.yaml @@ -0,0 +1,30 @@ +apiVersion: astra.netapp.io/v1 +kind: Schedule +metadata: + creationTimestamp: "2024-04-15T20:46:16Z" + generation: 2 + labels: + argocd.argoproj.io/instance: ghost-demo + name: ghost-daily + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "9963815" + uid: a2736922-6801-482c-a199-03ef8a3f35d7 +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + backupRetention: "1" + dayOfMonth: "" + dayOfWeek: "" + enabled: true + granularity: daily + hour: "1" + minute: "0" + recurrenceRule: "" + snapshotRetention: "1" +status: + lastScheduleTime: "2024-04-24T01:00:00Z" diff --git a/resource_customizations/astra.netapp.io/Snapshot/health.lua b/resource_customizations/astra.netapp.io/Snapshot/health.lua new file mode 100644 index 000000000000..39de4ac74eb6 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Snapshot/health.lua @@ -0,0 +1,16 @@ +hs = { status = "Progressing", message = "No status available" } +if obj.status ~= nil then + if obj.status.state ~= nil then + if obj.status.state == "Completed" then + hs.status = "Healthy" + hs.message = obj.kind .. " Completed" + elseif obj.status.state == "Running" then + hs.status = "Progressing" + hs.message = obj.kind .. " Running" + else + hs.status = "Degraded" + hs.message = obj.status.state + end + end +end +return hs diff --git a/resource_customizations/astra.netapp.io/Snapshot/health_test.yaml b/resource_customizations/astra.netapp.io/Snapshot/health_test.yaml new file mode 100644 index 000000000000..c15b3d8b3a9f --- /dev/null +++ b/resource_customizations/astra.netapp.io/Snapshot/health_test.yaml @@ -0,0 +1,17 @@ +tests: + - healthStatus: + status: Progressing + message: "No status available" + inputPath: testdata/progressing_nostatus.yaml + - healthStatus: + status: Progressing + message: "Snapshot Running" + inputPath: testdata/progressing_status.yaml + - healthStatus: + status: Healthy + message: "Snapshot Completed" + inputPath: testdata/healthy.yaml + - healthStatus: + status: Degraded + message: "Failed" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/astra.netapp.io/Snapshot/testdata/degraded.yaml b/resource_customizations/astra.netapp.io/Snapshot/testdata/degraded.yaml new file mode 100644 index 000000000000..89851bbe5dc0 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Snapshot/testdata/degraded.yaml @@ -0,0 +1,80 @@ +apiVersion: astra.netapp.io/v1 +kind: Snapshot +metadata: + annotations: + astra.netapp.io/correlationid: 6094b54d-b02b-475a-b5db-136729841240 + creationTimestamp: "2024-04-24T19:54:18Z" + finalizers: + - astra.netapp.io/finalizer + generation: 1 + name: backup-ad301b6a-6536-4313-89c1-d10ad0275430 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + blockOwnerDeletion: true + controller: true + kind: Backup + name: backup-20240424193746 + uid: ad301b6a-6536-4313-89c1-d10ad0275430 + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "10641329" + uid: 7b0d4f5e-53d0-4742-adec-15ef5d527865 +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + volumeSnapshotsCreatedTimeout: 0s + volumeSnapshotsReadyToUseTimeout: 0s +status: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424195419_backup-ad301b6a-6536-4313-89c1-d10ad0275430_7b0d4f5e-53d0-4742-adec-15ef5d527865 + conditions: + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppArchivePathNameGenerated + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: reconcile timeout of 1h0m0s exceeded + reason: Timeout + status: "False" + type: ResourceBackupCompleted + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PreSnapshotExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: VolumeSnapshotsCreated + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PostSnapshotExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: VolumeSnapshotsReady + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + - lastTransitionTime: "2024-04-24T19:54:19Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailurePostSnapshotExecHooksRunCompleted + error: reconcile timeout of 1h0m0s exceeded + state: Failed diff --git a/resource_customizations/astra.netapp.io/Snapshot/testdata/healthy.yaml b/resource_customizations/astra.netapp.io/Snapshot/testdata/healthy.yaml new file mode 100644 index 000000000000..7073f9c5147b --- /dev/null +++ b/resource_customizations/astra.netapp.io/Snapshot/testdata/healthy.yaml @@ -0,0 +1,81 @@ +apiVersion: astra.netapp.io/v1 +kind: Snapshot +metadata: + annotations: + astra.netapp.io/correlationid: 87091676-6489-4c76-8728-6b81bf4936b0 + creationTimestamp: "2024-04-24T14:23:18Z" + finalizers: + - astra.netapp.io/finalizer + generation: 2 + name: argo-presync-20240424142317 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "10421471" + uid: 152faab3-0374-4cef-bac9-6e7940b06aa9 +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + volumeSnapshotsCreatedTimeout: 0s + volumeSnapshotsReadyToUseTimeout: 0s +status: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424142318_argo-presync-20240424142317_152faab3-0374-4cef-bac9-6e7940b06aa9 + completionTimestamp: "2024-04-24T14:23:43Z" + conditions: + - lastTransitionTime: "2024-04-24T14:23:18Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T14:23:18Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppArchivePathNameGenerated + - lastTransitionTime: "2024-04-24T14:23:30Z" + message: Successfully reconciled + reason: Done + status: "True" + type: ResourceBackupCompleted + - lastTransitionTime: "2024-04-24T14:23:31Z" + message: Successfully reconciled + reason: Done + status: "True" + type: PreSnapshotExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T14:23:41Z" + message: Successfully reconciled + reason: Done + status: "True" + type: VolumeSnapshotsCreated + - lastTransitionTime: "2024-04-24T14:23:42Z" + message: Successfully reconciled + reason: Done + status: "True" + type: PostSnapshotExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T14:23:43Z" + message: Successfully reconciled + reason: Done + status: "True" + type: VolumeSnapshotsReady + - lastTransitionTime: "2024-04-24T14:23:43Z" + message: Successfully reconciled + reason: Done + status: "True" + type: Completed + - lastTransitionTime: "2024-04-24T14:23:18Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailurePostSnapshotExecHooksRunCompleted + postSnapshotExecHooksRunResults: [] + preSnapshotExecHooksRunResults: [] + state: Completed + volumeSnapshots: + - name: snapshot-152faab3-0374-4cef-bac9-6e7940b06aa9-pvc-b9ff9e05-5049-4862-82c6-dea080c2fe0d + namespace: ghost + - name: snapshot-152faab3-0374-4cef-bac9-6e7940b06aa9-pvc-38c468b3-eed6-48f2-b43b-15083dd1c030 + namespace: ghost diff --git a/resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_nostatus.yaml b/resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_nostatus.yaml new file mode 100644 index 000000000000..28501e28fd95 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_nostatus.yaml @@ -0,0 +1,24 @@ +apiVersion: astra.netapp.io/v1 +kind: Snapshot +metadata: + annotations: + astra.netapp.io/correlationid: de2315e9-4733-4733-91a0-1abec5f1e44e + creationTimestamp: "2024-04-24T21:17:04Z" + finalizers: + - astra.netapp.io/finalizer + generation: 2 + name: argo-presync-20240424211703 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "10654224" + uid: b200db48-c186-4ae8-9748-1ba7bec23d6d +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + volumeSnapshotsCreatedTimeout: 0s + volumeSnapshotsReadyToUseTimeout: 0s diff --git a/resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_status.yaml b/resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_status.yaml new file mode 100644 index 000000000000..08951648c6d7 --- /dev/null +++ b/resource_customizations/astra.netapp.io/Snapshot/testdata/progressing_status.yaml @@ -0,0 +1,73 @@ +apiVersion: astra.netapp.io/v1 +kind: Snapshot +metadata: + annotations: + astra.netapp.io/correlationid: de2315e9-4733-4733-91a0-1abec5f1e44e + creationTimestamp: "2024-04-24T21:17:04Z" + finalizers: + - astra.netapp.io/finalizer + generation: 2 + name: argo-presync-20240424211703 + namespace: astra-connector + ownerReferences: + - apiVersion: astra.netapp.io/v1 + kind: Application + name: ghost + uid: 0af10ee8-772b-4367-8334-44f9e4ad2849 + resourceVersion: "10654224" + uid: b200db48-c186-4ae8-9748-1ba7bec23d6d +spec: + appVaultRef: astra-gcp-backup-743cfd150129 + applicationRef: ghost + completionTimeout: 0s + volumeSnapshotsCreatedTimeout: 0s + volumeSnapshotsReadyToUseTimeout: 0s +status: + appArchivePath: ghost_0af10ee8-772b-4367-8334-44f9e4ad2849/snapshots/20240424211704_argo-presync-20240424211703_b200db48-c186-4ae8-9748-1ba7bec23d6d + conditions: + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppOwnerReferenceCreated + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Successfully reconciled + reason: Done + status: "True" + type: AppArchivePathNameGenerated + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Waiting for ResourceBackup to complete + reason: Waiting + status: "False" + type: ResourceBackupCompleted + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PreSnapshotExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: VolumeSnapshotsCreated + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: PostSnapshotExecHooksRunCompleted + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: VolumeSnapshotsReady + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: Completed + - lastTransitionTime: "2024-04-24T21:17:04Z" + message: Not yet reconciled + reason: Pending + status: Unknown + type: OnFailurePostSnapshotExecHooksRunCompleted + state: Running