diff --git a/charts/pleco/Chart.yaml b/charts/pleco/Chart.yaml index 05c206e..1c6f184 100644 --- a/charts/pleco/Chart.yaml +++ b/charts/pleco/Chart.yaml @@ -3,6 +3,6 @@ name: pleco description: Automatically removes Cloud managed services and Kubernetes resources based on tags with TTL type: application home: https://github.com/Qovery/pleco -version: 0.9.23 -appVersion: 0.9.23 +version: 0.9.24 +appVersion: 0.9.24 icon: https://github.com/Qovery/pleco/raw/main/assets/pleco_logo.png diff --git a/charts/pleco/values.yaml b/charts/pleco/values.yaml index cad06dc..1d6c8ed 100644 --- a/charts/pleco/values.yaml +++ b/charts/pleco/values.yaml @@ -3,7 +3,7 @@ replicaCount: 1 image: repository: qoveryrd/pleco pullPolicy: IfNotPresent - plecoImageTag: "0.9.23" + plecoImageTag: "0.9.24" cloudProvider: "" diff --git a/cmd/version.go b/cmd/version.go index da48800..7aacf7b 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -19,5 +19,5 @@ func init() { } func GetCurrentVersion() string { - return "0.9.23" // ci-version-check + return "0.9.24" // ci-version-check } diff --git a/pkg/aws/db_documentdb.go b/pkg/aws/db_documentdb.go index 8e88b90..54f5bc2 100644 --- a/pkg/aws/db_documentdb.go +++ b/pkg/aws/db_documentdb.go @@ -125,7 +125,7 @@ func DeleteExpiredDocumentDBClusters(sessions AWSSessions, options AwsOptions) { } func listClusterSnapshots(svc rds.RDS) []*rds.DBClusterSnapshot { - result, err := svc.DescribeDBClusterSnapshots(&rds.DescribeDBClusterSnapshotsInput{}) + result, err := svc.DescribeDBClusterSnapshots(&rds.DescribeDBClusterSnapshotsInput{SnapshotType: aws.String("manual")}) if err != nil { log.Errorf("Can't list RDS snapshots in region %s: %s", *svc.Config.Region, err.Error()) @@ -142,7 +142,7 @@ func getExpiredClusterSnapshots(svc rds.RDS) []*rds.DBClusterSnapshot { if len(dbs) == 0 { for _, snap := range snaps { - if snap.SnapshotCreateTime.Before(time.Now().UTC().Add(3 * time.Hour)) { + if snap.SnapshotCreateTime.Before(time.Now().UTC().Add(3 * time.Hour)) && common.CheckClusterSnapshot(snap) { expiredSnaps = append(expiredSnaps, snap) } } @@ -152,7 +152,9 @@ func getExpiredClusterSnapshots(svc rds.RDS) []*rds.DBClusterSnapshot { snapsChecking := make(map[string]*rds.DBClusterSnapshot) for _, snap := range snaps { - snapsChecking[*snap.DBClusterSnapshotIdentifier] = snap + if common.CheckClusterSnapshot(snap) { + snapsChecking[*snap.DBClusterSnapshotIdentifier] = snap + } } for _, db := range dbs { diff --git a/pkg/aws/db_rds.go b/pkg/aws/db_rds.go index 59a700e..22a3869 100644 --- a/pkg/aws/db_rds.go +++ b/pkg/aws/db_rds.go @@ -328,7 +328,7 @@ func DeleteExpiredCompleteRDSParameterGroups(sessions AWSSessions, options AwsOp } func listSnapshots(svc rds.RDS) []*rds.DBSnapshot { - result, err := svc.DescribeDBSnapshots(&rds.DescribeDBSnapshotsInput{}) + result, err := svc.DescribeDBSnapshots(&rds.DescribeDBSnapshotsInput{SnapshotType: aws.String("manual")}) if err != nil { log.Errorf("Can't list RDS snapshots in region %s: %s", *svc.Config.Region, err.Error()) @@ -345,7 +345,7 @@ func getExpiredSnapshots(svc rds.RDS) []*rds.DBSnapshot { if len(dbs) == 0 { for _, snap := range snaps { - if snap.SnapshotCreateTime.Before(time.Now().UTC().Add(3 * time.Hour)) { + if snap.SnapshotCreateTime.Before(time.Now().UTC().Add(3 * time.Hour)) && common.CheckSnapshot(snap) { expiredSnaps = append(expiredSnaps, snap) } } @@ -355,6 +355,9 @@ func getExpiredSnapshots(svc rds.RDS) []*rds.DBSnapshot { snapsChecking := make(map[string]*rds.DBSnapshot) for _, snap := range snaps { + if common.CheckSnapshot(snap) { + snapsChecking[*snap.DBSnapshotIdentifier] = snap + } snapsChecking[*snap.DBSnapshotIdentifier] = snap } diff --git a/pkg/common/utils.go b/pkg/common/utils.go index 409721d..d4a7518 100644 --- a/pkg/common/utils.go +++ b/pkg/common/utils.go @@ -212,3 +212,11 @@ func stringDateToTimeDate(date string) time.Time { return time.Date(int(year), time.Month(month), int(day), int(hour), int(minutes), int(seconds), 0, time.UTC) } + +func CheckSnapshot(snap *rds.DBSnapshot) bool { + return !strings.Contains(*snap.Status, "") && strings.Contains(*snap.DBSnapshotIdentifier, "default:") +} + +func CheckClusterSnapshot(snap *rds.DBClusterSnapshot) bool { + return !strings.Contains(*snap.Status, "") && strings.Contains(*snap.DBClusterSnapshotIdentifier, "default:") +}