Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client proxy webhook rule #1000

Merged
merged 21 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions api/v1/verticadb_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,22 @@ func (v *VerticaDB) checkImmutableBasic(oldObj *VerticaDB, allErrs field.ErrorLi
"local.storageClass cannot change after creation")
allErrs = append(allErrs, err)
}
// annotation vertica.com/use-client-proxy cannot change after creation
if v.Annotations[vmeta.UseVProxyAnnotation] != oldObj.Annotations[vmeta.UseVProxyAnnotation] {
prefix := field.NewPath("metadata").Child("annotations")
errMsg := fmt.Sprintf("annotation %s cannot change after creation", vmeta.UseVProxyAnnotation)
err := field.Invalid(prefix.Key(vmeta.UseVProxyAnnotation),
v.Annotations[vmeta.VClusterOpsAnnotation],
errMsg)
allErrs = append(allErrs, err)
}
// proxy.image cannot change after creation
if v.Spec.Proxy.Image != oldObj.Spec.Proxy.Image {
err := field.Invalid(field.NewPath("spec").Child("proxy").Child("image"),
v.Spec.Proxy.Image,
"proxy.image cannot change after creation")
allErrs = append(allErrs, err)
}
HaoYang0000 marked this conversation as resolved.
Show resolved Hide resolved
// when update subcluster names, there should be at least one sc's name match its old name.
// This limitation should not be hold in online upgrade since we need to rename all subclusters
// after sandbox promotion.
Expand Down
10 changes: 10 additions & 0 deletions api/v1/verticadb_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ var _ = Describe("verticadb_webhook", func() {
vdbUpdate.Spec.Local.StorageClass = "MyStorageClass"
validateImmutableFields(vdbUpdate, true)
})
It("should not change proxy.image after creation", func() {
vdbUpdate := createVDBHelper()
vdbUpdate.Spec.Proxy.Image = "NewProxyImage"
validateImmutableFields(vdbUpdate, true)
})
It("should not change annotation vertica.com/use-client-proxy after creation", func() {
vdbUpdate := createVDBHelper()
vdbUpdate.Annotations[vmeta.UseVProxyAnnotation] = "NewValue"
validateImmutableFields(vdbUpdate, true)
})
It("should not change local.depotVolume after DB init", func() {
vdbUpdate := createVDBHelper()
vdbUpdate.Spec.Local.DepotVolume = EmptyDir
Expand Down
Loading