Skip to content

Commit a1d20ec

Browse files
Merge pull request #583 from vshn/add-pinimagetag
Add pin image tag attribute
2 parents dd2f9d5 + 0f9df28 commit a1d20ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+690
-301
lines changed

apis/vshn/v1/common_types.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ type VSHNDBaaSMaintenanceScheduleSpec struct {
8787
// Format: "hh:mm:ss".
8888
TimeOfDay TimeOfDay `json:"timeOfDay,omitempty"`
8989

90-
// +kubebuilder:default=false
91-
// DisableServiceMaintenance disables automatic service version updates during maintenance windows.
92-
// When enabled, the version specified in spec.parameters.service.version is used as the target version.
90+
// PinImageTag allows pinning the service to a specific image tag.
91+
// When set, the exact specified tag will be used, even if it's older than the currently deployed version.
9392
// WARNING: User takes full responsibility for version management and security updates.
94-
DisableServiceMaintenance bool `json:"disableServiceMaintenance,omitempty"`
93+
// Downgrades are allowed when pinning - the customer assumes all risk.
94+
PinImageTag string `json:"pinImageTag,omitempty"`
9595

9696
// +kubebuilder:default=false
9797
// DisableAppcatRelease disables automatic AppCat composition revision rollouts during maintenance windows.
@@ -121,9 +121,14 @@ func (n *VSHNDBaaSMaintenanceScheduleSpec) SetMaintenanceTimeOfDay(tod TimeOfDay
121121
n.TimeOfDay = tod
122122
}
123123

124-
// IsServiceMaintenanceDisabled returns true if service maintenance is disabled
125-
func (n *VSHNDBaaSMaintenanceScheduleSpec) IsServiceMaintenanceDisabled() bool {
126-
return n.DisableServiceMaintenance
124+
// GetPinImageTag returns the pinned image tag if set
125+
func (n *VSHNDBaaSMaintenanceScheduleSpec) GetPinImageTag() string {
126+
return n.PinImageTag
127+
}
128+
129+
// IsPinImageTagSet returns true if an image tag is pinned
130+
func (n *VSHNDBaaSMaintenanceScheduleSpec) IsPinImageTagSet() bool {
131+
return n.PinImageTag != ""
127132
}
128133

129134
// IsAppcatReleaseDisabled returns true if AppCat release updates are disabled

apis/vshn/v1/common_types_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,32 @@ func Test_IsSet(t *testing.T) {
109109
}
110110
}
111111

112-
func Test_IsServiceMaintenanceDisabled(t *testing.T) {
112+
func Test_PinImageTag(t *testing.T) {
113113
tests := []struct {
114114
name string
115115
scheduleSpec VSHNDBaaSMaintenanceScheduleSpec
116-
want bool
116+
wantTag string
117+
wantIsSet bool
117118
}{
118119
{
119-
name: "GivenDisableServiceMaintenanceTrue_ThenExpectTrue",
120+
name: "GivenPinImageTagSet_ThenExpectTagAndTrue",
120121
scheduleSpec: VSHNDBaaSMaintenanceScheduleSpec{
121-
DisableServiceMaintenance: true,
122+
PinImageTag: "7.2.5",
122123
},
123-
want: true,
124+
wantTag: "7.2.5",
125+
wantIsSet: true,
124126
},
125127
{
126-
name: "GivenDefaultValue_ThenExpectFalse",
128+
name: "GivenDefaultValue_ThenExpectEmptyAndFalse",
127129
scheduleSpec: VSHNDBaaSMaintenanceScheduleSpec{},
128-
want: false,
130+
wantTag: "",
131+
wantIsSet: false,
129132
},
130133
}
131134
for _, tt := range tests {
132135
t.Run(tt.name, func(t *testing.T) {
133-
assert.Equal(t, tt.want, tt.scheduleSpec.IsServiceMaintenanceDisabled())
136+
assert.Equal(t, tt.wantTag, tt.scheduleSpec.GetPinImageTag())
137+
assert.Equal(t, tt.wantIsSet, tt.scheduleSpec.IsPinImageTagSet())
134138
})
135139
}
136140
}

apis/vshn/v1/dbaas_vshn_forgejo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ type VSHNForgejoStatus struct {
172172
// InitialMaintenance tracks the status of the initial maintenance job,
173173
// including when it ran and whether it succeeded or failed.
174174
InitialMaintenance InitialMaintenanceStatus `json:"initialMaintenance,omitempty"`
175+
// CurrentReleaseTag contains the currently deployed image tag.
176+
CurrentReleaseTag string `json:"currentReleaseTag,omitempty"`
175177

176178
// ResourceStatus represents the observed state of a managed resource.
177179
xpv1.ResourceStatus `json:",inline"`

apis/vshn/v1/dbaas_vshn_keycloak.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ type VSHNKeycloakStatus struct {
227227
// InitialMaintenance tracks the status of the initial maintenance job,
228228
// including when it ran and whether it succeeded or failed.
229229
InitialMaintenance InitialMaintenanceStatus `json:"initialMaintenance,omitempty"`
230+
// CurrentReleaseTag contains the currently deployed image tag.
231+
CurrentReleaseTag string `json:"currentReleaseTag,omitempty"`
230232
// ResourceStatus represents the observed state of a managed resource.
231233
xpv1.ResourceStatus `json:",inline"`
232234
// LastConfigHash is the hash of last applied customConfigurationRef.

apis/vshn/v1/dbaas_vshn_redis.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ type VSHNRedisStatus struct {
156156
// InitialMaintenance tracks the status of the initial maintenance job,
157157
// including when it ran and whether it succeeded or failed.
158158
InitialMaintenance InitialMaintenanceStatus `json:"initialMaintenance,omitempty"`
159+
// CurrentReleaseTag contains the currently deployed image tag.
160+
CurrentReleaseTag string `json:"currentReleaseTag,omitempty"`
159161
// ResourceStatus represents the observed state of a managed resource.
160162
xpv1.ResourceStatus `json:",inline"`
161163
}

apis/vshn/v1/vshn_minio.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ type VSHNMinioStatus struct {
105105
// InitialMaintenance tracks the status of the initial maintenance job,
106106
// including when it ran and whether it succeeded or failed.
107107
InitialMaintenance InitialMaintenanceStatus `json:"initialMaintenance,omitempty"`
108+
// CurrentReleaseTag contains the currently deployed image tag.
109+
CurrentReleaseTag string `json:"currentReleaseTag,omitempty"`
108110
// ResourceStatus represents the observed state of a managed resource.
109111
xpv1.ResourceStatus `json:",inline"`
110112
}

apis/vshn/v1/vshn_nextcloud.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ type VSHNNextcloudStatus struct {
184184
// InitialMaintenance tracks the status of the initial maintenance job,
185185
// including when it ran and whether it succeeded or failed.
186186
InitialMaintenance InitialMaintenanceStatus `json:"initialMaintenance,omitempty"`
187+
// CurrentReleaseTag contains the currently deployed image tag.
188+
CurrentReleaseTag string `json:"currentReleaseTag,omitempty"`
187189
// ResourceStatus represents the observed state of a managed resource.
188190
xpv1.ResourceStatus `json:",inline"`
189191
}

cmd/maintenance.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,14 @@ func (c *controller) runMaintenance(cmd *cobra.Command, _ []string) error {
164164
panic("service name is mandatory")
165165
}
166166

167-
disableServiceMaintenance, err := strconv.ParseBool(viper.GetString("DISABLE_SERVICE_MAINTENANCE"))
168-
if err != nil {
169-
return fmt.Errorf("cannot parse env variable DISABLE_SERVICE_MAINTENANCE to bool: %w", err)
170-
}
167+
pinImageTag := viper.GetString("PIN_IMAGE_TAG")
171168
disableAppcatRelease, err := strconv.ParseBool(viper.GetString("DISABLE_APPCAT_RELEASE"))
172169
if err != nil {
173170
return fmt.Errorf("cannot parse env variable DISABLE_APPCAT_RELEASE to bool: %w", err)
174171
}
175172

176-
if disableAppcatRelease && disableServiceMaintenance {
177-
log.Info("AppCat release and service maintenance disabled, skipping...")
173+
if disableAppcatRelease && pinImageTag != "" {
174+
log.Info("AppCat release disabled and image tag pinned, skipping...")
178175
return nil
179176
}
180177

@@ -216,8 +213,8 @@ func (c *controller) runMaintenance(cmd *cobra.Command, _ []string) error {
216213
return m.ReleaseLatest(ctx, enabled, maintClient, minAge)
217214
}(),
218215
func() error {
219-
if disableServiceMaintenance {
220-
log.Info("Service maintenance disabled by user configuration")
216+
if pinImageTag != "" {
217+
log.Info("Image tag pinned by user configuration, skipping service maintenance", "pinnedTag", pinImageTag)
221218
return nil
222219
}
223220
return m.DoMaintenance(ctx)

crds/vshn.appcat.vshn.io_vshnforgejoes.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ spec:
103103
which may contain bug fixes, security patches, and new features.
104104
WARNING: Strongly discouraged - may leave instance without security patches and bug fixes.
105105
type: boolean
106-
disableServiceMaintenance:
107-
default: false
106+
pinImageTag:
108107
description: |-
109-
DisableServiceMaintenance disables automatic service version updates during maintenance windows.
110-
When enabled, the version specified in spec.parameters.service.version is used as the target version.
108+
PinImageTag allows pinning the service to a specific image tag.
109+
When set, the exact specified tag will be used, even if it's older than the currently deployed version.
111110
WARNING: User takes full responsibility for version management and security updates.
112-
type: boolean
111+
Downgrades are allowed when pinning - the customer assumes all risk.
112+
type: string
113113
timeOfDay:
114114
description: |-
115115
TimeOfDay for installing updates in UTC.
@@ -4773,6 +4773,9 @@ spec:
47734773
x-kubernetes-list-map-keys:
47744774
- type
47754775
x-kubernetes-list-type: map
4776+
currentReleaseTag:
4777+
description: CurrentReleaseTag contains the currently deployed image tag.
4778+
type: string
47764779
initialMaintenance:
47774780
description: |-
47784781
InitialMaintenance tracks the status of the initial maintenance job,
@@ -4875,13 +4878,13 @@ spec:
48754878
which may contain bug fixes, security patches, and new features.
48764879
WARNING: Strongly discouraged - may leave instance without security patches and bug fixes.
48774880
type: boolean
4878-
disableServiceMaintenance:
4879-
default: false
4881+
pinImageTag:
48804882
description: |-
4881-
DisableServiceMaintenance disables automatic service version updates during maintenance windows.
4882-
When enabled, the version specified in spec.parameters.service.version is used as the target version.
4883+
PinImageTag allows pinning the service to a specific image tag.
4884+
When set, the exact specified tag will be used, even if it's older than the currently deployed version.
48834885
WARNING: User takes full responsibility for version management and security updates.
4884-
type: boolean
4886+
Downgrades are allowed when pinning - the customer assumes all risk.
4887+
type: string
48854888
timeOfDay:
48864889
description: |-
48874890
TimeOfDay for installing updates in UTC.

crds/vshn.appcat.vshn.io_vshnkeycloaks.yaml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ spec:
106106
which may contain bug fixes, security patches, and new features.
107107
WARNING: Strongly discouraged - may leave instance without security patches and bug fixes.
108108
type: boolean
109-
disableServiceMaintenance:
110-
default: false
109+
pinImageTag:
111110
description: |-
112-
DisableServiceMaintenance disables automatic service version updates during maintenance windows.
113-
When enabled, the version specified in spec.parameters.service.version is used as the target version.
111+
PinImageTag allows pinning the service to a specific image tag.
112+
When set, the exact specified tag will be used, even if it's older than the currently deployed version.
114113
WARNING: User takes full responsibility for version management and security updates.
115-
type: boolean
114+
Downgrades are allowed when pinning - the customer assumes all risk.
115+
type: string
116116
timeOfDay:
117117
description: |-
118118
TimeOfDay for installing updates in UTC.
@@ -4833,13 +4833,13 @@ spec:
48334833
which may contain bug fixes, security patches, and new features.
48344834
WARNING: Strongly discouraged - may leave instance without security patches and bug fixes.
48354835
type: boolean
4836-
disableServiceMaintenance:
4837-
default: false
4836+
pinImageTag:
48384837
description: |-
4839-
DisableServiceMaintenance disables automatic service version updates during maintenance windows.
4840-
When enabled, the version specified in spec.parameters.service.version is used as the target version.
4838+
PinImageTag allows pinning the service to a specific image tag.
4839+
When set, the exact specified tag will be used, even if it's older than the currently deployed version.
48414840
WARNING: User takes full responsibility for version management and security updates.
4842-
type: boolean
4841+
Downgrades are allowed when pinning - the customer assumes all risk.
4842+
type: string
48434843
timeOfDay:
48444844
description: |-
48454845
TimeOfDay for installing updates in UTC.
@@ -9738,6 +9738,9 @@ spec:
97389738
x-kubernetes-list-map-keys:
97399739
- type
97409740
x-kubernetes-list-type: map
9741+
currentReleaseTag:
9742+
description: CurrentReleaseTag contains the currently deployed image tag.
9743+
type: string
97419744
initialMaintenance:
97429745
description: |-
97439746
InitialMaintenance tracks the status of the initial maintenance job,
@@ -9846,13 +9849,13 @@ spec:
98469849
which may contain bug fixes, security patches, and new features.
98479850
WARNING: Strongly discouraged - may leave instance without security patches and bug fixes.
98489851
type: boolean
9849-
disableServiceMaintenance:
9850-
default: false
9852+
pinImageTag:
98519853
description: |-
9852-
DisableServiceMaintenance disables automatic service version updates during maintenance windows.
9853-
When enabled, the version specified in spec.parameters.service.version is used as the target version.
9854+
PinImageTag allows pinning the service to a specific image tag.
9855+
When set, the exact specified tag will be used, even if it's older than the currently deployed version.
98549856
WARNING: User takes full responsibility for version management and security updates.
9855-
type: boolean
9857+
Downgrades are allowed when pinning - the customer assumes all risk.
9858+
type: string
98569859
timeOfDay:
98579860
description: |-
98589861
TimeOfDay for installing updates in UTC.

0 commit comments

Comments
 (0)