Skip to content

Commit 48a3529

Browse files
authored
Merge pull request #459 from vshn/develop
🔀 Merge develop into master (Release)
2 parents f9c7636 + 7c10d21 commit 48a3529

File tree

20 files changed

+820
-63
lines changed

20 files changed

+820
-63
lines changed

.github/workflows/merge.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,16 @@ jobs:
8282
exit 1
8383
fi
8484
85-
- name: Check required status checks on appcat PR
86-
run: |
87-
PASSED=$(gh api repos/${{ github.repository }}/commits/${{ steps.appcat.outputs.last-sha }}/check-runs \
88-
--jq '[.check_runs[].conclusion] | all(. == "success" or . == "skipped")')
89-
90-
if [ "$PASSED" != "true" ]; then
91-
echo "❌ Required status checks did not pass"
92-
exit 1
93-
fi
85+
# Disable temporarily
86+
#- name: Check required status checks on appcat PR
87+
# run: |
88+
# PASSED=$(gh api repos/${{ github.repository }}/commits/${{ steps.appcat.outputs.last-sha }}/check-runs \
89+
# --jq '[.check_runs[].conclusion] | all(. == "success" or . == "skipped")')
90+
#
91+
# if [ "$PASSED" != "true" ]; then
92+
# echo "❌ Required status checks did not pass"
93+
# exit 1
94+
# fi
9495

9596
- name: Check for merge conflicts on appcat PR
9697
id: check-conflicts

.github/workflows/pre-release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ jobs:
8585
git push origin $NEW_TAG
8686
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
8787
88+
- name: Trigger Release Workflow
89+
uses: peter-evans/repository-dispatch@v3
90+
with:
91+
token: ${{ secrets.GITHUB_TOKEN }}
92+
repository: ${{ env.APPCAT_REPO }}
93+
event-type: trigger-release
94+
client-payload: '{"tag": "${{ steps.bump.outputs.new_tag }}"}'
8895

8996
create-component-release-pr:
9097
needs: create-and-merge-appcat-pr
@@ -132,4 +139,3 @@ jobs:
132139
--body "This PR updates the version in defaults.yaml and regenerates golden files."
133140
env:
134141
GH_TOKEN: ${{ secrets.COMPONENT_ACCESS_TOKEN }}
135-

.github/workflows/release.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ on:
44
push:
55
tags:
66
- "*"
7-
workflow_dispatch:
8-
inputs:
9-
tag:
10-
description: 'Tag to release'
11-
required: true
12-
type: string
7+
repository_dispatch:
8+
types: [trigger-release]
139

1410
env:
1511
APP_NAME: appcat
@@ -26,6 +22,16 @@ jobs:
2622
- uses: actions/checkout@v4
2723
with:
2824
fetch-depth: 0
25+
# Checkout the specific tag when triggered by repository_dispatch
26+
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag || github.ref }}
27+
28+
- name: Set tag variable
29+
run: |
30+
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
31+
echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV
32+
else
33+
echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
34+
fi
2935
3036
- name: Determine Go version from go.mod
3137
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
@@ -56,11 +62,11 @@ jobs:
5662

5763
- name: Push docker image
5864
if: env.PUSH_IMAGE == 'true'
59-
run: make docker-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }}
65+
run: make docker-push -e IMG_TAG=${{ env.TAG }} -e APP_NAME=${{ env.APP_NAME }}
6066

6167
- name: Build and push function package
6268
if: env.PUSH_PACKAGE == 'true'
63-
run: make package-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }}
69+
run: make package-push -e IMG_TAG=${{ env.TAG }} -e APP_NAME=${{ env.APP_NAME }}
6470

6571
- name: Login to Upbound
6672
if: env.PUSH_UPBOUND == 'true'
@@ -72,7 +78,7 @@ jobs:
7278

7379
- name: Build branch and push package to upbound
7480
if: env.PUSH_UPBOUND == 'true' && env.PUSH_PACKAGE == 'true'
75-
run: make package-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} -e IMG_REPO=xpkg.upbound.io
81+
run: make package-push -e IMG_TAG=${{ env.TAG }} -e APP_NAME=${{ env.APP_NAME }} -e IMG_REPO=xpkg.upbound.io
7682

7783
- name: Build changelog from PRs with labels
7884
id: build_changelog
@@ -82,8 +88,9 @@ jobs:
8288
# PreReleases still get a changelog, but the next full release gets a diff since the last full release,
8389
# combining possible changelogs of all previous PreReleases in between. PreReleases show a partial changelog
8490
# since last PreRelease.
85-
ignorePreReleases: "${{ !contains(github.ref, '-rc') }}"
91+
ignorePreReleases: "${{ !contains(env.TAG, '-rc') }}"
8692
outputFile: .github/release-notes.md
93+
toTag: ${{ env.TAG }}
8794
env:
8895
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8996

@@ -95,4 +102,3 @@ jobs:
95102
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96103
CONTAINER_REGISTRY: ghcr.io
97104
IMAGE_NAME: ${{ github.repository }}${{ env.SUFFIX }}
98-

apis/vshn/v1/common_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ type Security struct {
196196

197197
// DeletionProtection blocks the deletion of the instance if it is enabled (enabled by default)
198198
// +kubebuilder:default=true
199-
DeletionProtection bool `json:"deletionProtection,omitempty"`
199+
// +kubebuilder:validation:Optional
200+
DeletionProtection bool `json:"deletionProtection"`
200201

201202
// AllowedGroups defines a list of Groups that have limited access to the instance namespace
202203
AllowedGroups []string `json:"allowedGroups,omitempty"`

apis/vshn/v1/dbaas_vshn_postgresql.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ type VSHNPostgreSQLBackup struct {
186186
// DeletionProtection will protect the instance from being deleted for the given retention time.
187187
// This is enabled by default.
188188
// +kubebuilder:default=true
189-
DeletionProtection *bool `json:"deletionProtection,omitempty"`
189+
// +kubebuilder:validation:Optional
190+
DeletionProtection *bool `json:"deletionProtection"`
190191

191192
// DeletionRetention specifies in days how long the instance should be kept after deletion.
192193
// The default is keeping it one week.

pkg/comp-functions/functions/common/password.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,22 @@ func AddCredentialsSecret(comp InfoGetter, svc *runtime.ServiceRuntime, fieldLis
3232
// This is helpful if multiple different random generated passwords are necessary.
3333
func AddGenericSecret(comp InfoGetter, svc *runtime.ServiceRuntime, suffix string, fieldList []string, allowDeletion bool, opts ...CredentialSecretOption) (string, error) {
3434
secretObjectName := runtime.EscapeDNS1123(comp.GetName()+"-"+suffix, false)
35+
3536
secret := &corev1.Secret{}
3637
cd := []xkube.ConnectionDetail{}
38+
39+
errObj := svc.GetObservedComposedResource(&xkube.Object{}, secretObjectName)
40+
3741
err := svc.GetObservedKubeObject(secret, secretObjectName)
38-
if err == runtime.ErrNotFound {
42+
43+
// runtime.ErrNotFound for the secret alone isn't enough here to prevent re-creating passwords
44+
// during provisioning it can happen that provider-kubernetes already applied a secret, but
45+
// hasn't yet set the status. If the status of the object is empty, the runtime will
46+
// also throw an ErrNotFound.
47+
// So we also check for the existence of the `Object` itself from the observed state, by
48+
// trying to get the object directly.
49+
if err == runtime.ErrNotFound && errObj == runtime.ErrNotFound {
50+
3951
stringData := map[string]string{}
4052

4153
for _, field := range fieldList {
@@ -51,7 +63,7 @@ func AddGenericSecret(comp InfoGetter, svc *runtime.ServiceRuntime, suffix strin
5163
},
5264
StringData: stringData,
5365
}
54-
} else if err != nil {
66+
} else if err != nil && err != runtime.ErrNotFound {
5567
return secretObjectName, err
5668
}
5769

pkg/comp-functions/functions/common/schedule.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
)
1010

1111
var (
12-
maitenanceWindowStart = time.Date(1970, 1, 1, 21, 0, 0, 0, time.UTC)
13-
maitenanceWindowEnd = time.Date(1970, 1, 2, 5, 0, 0, 0, time.UTC)
14-
maitenanceWindowRange = maitenanceWindowEnd.Unix() - maitenanceWindowStart.Unix()
12+
maintenanceWindowStart = time.Date(1970, 1, 1, 21, 0, 0, 0, time.UTC)
13+
maintenanceWindowEnd = time.Date(1970, 1, 2, 5, 0, 0, 0, time.UTC)
14+
maintenanceWindowRange = maintenanceWindowEnd.Unix() - maintenanceWindowStart.Unix()
1515
)
1616

1717
// BackupScheduler can schedule backups
@@ -26,12 +26,26 @@ type MaintenanceScheduler interface {
2626
GetMaintenanceTimeOfDay() *v1.TimeOfDay
2727
}
2828

29-
// SetRandomSchedules initializes the backup and maintenance schedules if the user did not explicitly provide a schedule.
30-
// The maintenance will be set to a random time on Tuesday night between 21:00 and 5:00, and the backup schedule will be set to once a day between 20:00 and 4:00.
29+
// SetRandomSchedules initializes the backup and maintenance schedules if the user did not explicitly provide a schedule.
30+
// The maintenance will be set to a random time on a random day (Sunday-Friday) between 21:00 and 5:00,
31+
// with the exception that Sunday maintenance only runs after 21:00 (not in the early morning hours).
32+
// The backup schedule will be set to once a day between 20:00 and 4:00.
3133
// If neither maintenance nor backup is set, the function will make sure that there will be backup scheduled one hour before the maintenance.
3234
func SetRandomSchedules(backup BackupScheduler, maintenance MaintenanceScheduler) {
3335
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
34-
maintTime := time.Unix(maitenanceWindowStart.Unix()+rng.Int63n(maitenanceWindowRange), 0).In(time.UTC)
36+
availableDays := []string{"sunday", "monday", "tuesday", "wednesday", "thursday", "friday"}
37+
selectedDay := availableDays[rng.Intn(len(availableDays))]
38+
maintTime := time.Unix(maintenanceWindowStart.Unix()+rng.Int63n(maintenanceWindowRange), 0).In(time.UTC)
39+
40+
// Special handling for Sunday: only allow times after 21:00 (not early morning)
41+
if selectedDay == "sunday" && maintTime.Hour() < 21 {
42+
// If time is in early morning (0-5), shift to evening (21-23)
43+
eveningStart := time.Date(1970, 1, 1, 21, 0, 0, 0, time.UTC)
44+
eveningEnd := time.Date(1970, 1, 1, 23, 59, 59, 0, time.UTC)
45+
eveningRange := eveningEnd.Unix() - eveningStart.Unix()
46+
maintTime = time.Unix(eveningStart.Unix()+rng.Int63n(eveningRange), 0).In(time.UTC)
47+
}
48+
3549
backupTime := maintTime.Add(-1 * time.Hour).In(time.UTC)
3650

3751
if backup.GetBackupSchedule() == "" {
@@ -45,10 +59,6 @@ func SetRandomSchedules(backup BackupScheduler, maintenance MaintenanceScheduler
4559
}
4660

4761
if maintenance.GetMaintenanceDayOfWeek() == "" {
48-
day := "tuesday"
49-
if maintTime.Day() > 1 {
50-
day = "wednesday"
51-
}
52-
maintenance.SetMaintenanceDayOfWeek(day)
62+
maintenance.SetMaintenanceDayOfWeek(selectedDay)
5363
}
5464
}

0 commit comments

Comments
 (0)