Repository: kedacore/http-add-on
Pull request #1008 (2024-04-30 17:56:15)

chore: Update skipscaledobjectcreation annotation to align with KEDA annotations
Originally, [we merged the feature](https://github.com/kedacore/http-add-on/pull/929) using `skipScaledObjectCreation` but this naming isn't aligned with KEDA annotations. As this feature hasn't been shipped yet, it's a good moment to rename it before being a breaking change.

### Checklist

- [x] Commits are signed with Developer Certificate of Origin (DCO)
- [x] Any necessary documentation is added, such as:
  - [`README.md`](/README.md)
  - [The `docs/` directory](./docs)
  - [The docs repo](https://github.com/kedacore/keda-docs)





Patch:
diff --git a/docs/ref/v0.8.0/http_scaled_object.md b/docs/ref/v0.8.0/http_scaled_object.md
index 3a03515..431d535 100644
--- a/docs/ref/v0.8.0/http_scaled_object.md
+++ b/docs/ref/v0.8.0/http_scaled_object.md
@@ -9,6 +9,8 @@ kind: HTTPScaledObject
 apiVersion: http.keda.sh/v1alpha1
 metadata:
     name: xkcd
+    annotations:
+        httpscaledobject.keda.sh/skip-scaledobject-creation: "false"
 spec:
     hosts:
     - myhost.com
@@ -33,7 +35,12 @@ spec:
             targetValue: 100
 ```
 
-This document is a narrated reference guide for the `HTTPScaledObject`, and we'll focus on the `spec` field.
+This document is a narrated reference guide for the `HTTPScaledObject`.
+
+## `httpscaledobject.keda.sh/skip-scaledobject-creation` annotation
+
+This annotation will disable the ScaledObject generation and management but keeping the routing and metrics available. This is done removing the current ScaledObject if it has been already created, allowing to use user managed ScaledObjects pointing the add-on scaler directly (supporting all the ScaledObject configurations and multiple triggers). You can read more about this [here](./../../walkthrough.md#integrating-http-add-on-scaler-with-other-keda-scalers)
+
 
 ## `hosts`
 
diff --git a/docs/walkthrough.md b/docs/walkthrough.md
index 4d4668a..102e448 100644
--- a/docs/walkthrough.md
+++ b/docs/walkthrough.md
@@ -91,7 +91,7 @@ curl -H "Host: myhost.com" localhost:8080/path1
 
 ### Integrating HTTP Add-On Scaler with other KEDA scalers
 
-For scenerios where you want to integrate HTTP Add-On scaler with other keda scalers, you can set the `SkipScaledObjectCreation` annotation to true on your `HTTPScaledObject`.  The reconciler will then skip the KEDA core ScaledObject creation which will allow you to create your own `ScaledObject` and add HTTP scaler as one of your triggers.
+For scenerios where you want to integrate HTTP Add-On scaler with other keda scalers, you can set the `"httpscaledobject.keda.sh/skip-scaledobject-creation"` annotation to true on your `HTTPScaledObject`.  The reconciler will then skip the KEDA core ScaledObject creation which will allow you to create your own `ScaledObject` and add HTTP scaler as one of your triggers.
 
 > 💡 Ensure that your ScaledObject is created with a different name than the `HTTPScaledObject` to ensure your ScaledObject is not removed by the reconciler.
 
@@ -101,7 +101,7 @@ If you don't know how to set the external scaler in the ScaledObject, you can de
 
 ```console
 annotations:
-  skipScaledObjectCreation: false
+  httpscaledobject.keda.sh/skip-scaledobject-creation: "false"
 ```
 
 2. Take copy of the current generated external-push trigger spec on the generated ScaledObject.
@@ -116,11 +116,11 @@ For example:
       scalerAddress: keda-http-add-on-external-scaler.keda:9090
 ```
 
-3. Apply the `skipScaledObjectCreation` annotation with `true` and apply the change. This will remove the originally created `ScaledObject` allowing you to create your own.
+3. Apply the `"httpscaledobject.keda.sh/skip-scaledobject-creation"` annotation with `true` and apply the change. This will remove the originally created `ScaledObject` allowing you to create your own.
 
 ```console
 annotations:
-  skipScaledObjectCreation: true
+  httpscaledobject.keda.sh/skip-scaledobject-creation: "true"
 ```
 
 4. Add the `external-push` trigger taken from step 2 to your own ScaledObject and apply this.
diff --git a/operator/controllers/http/app.go b/operator/controllers/http/app.go
index 2240b1e..2d12d29 100644
--- a/operator/controllers/http/app.go
+++ b/operator/controllers/http/app.go
@@ -14,6 +14,10 @@ import (
 	"github.com/kedacore/http-add-on/operator/controllers/http/config"
 )
 
+var (
+	SkipScaledObjectCreationAnnotation = "httpscaledobject.keda.sh/skip-scaledobject-creation"
+)
+
 func (r *HTTPScaledObjectReconciler) createOrUpdateApplicationResources(
 	ctx context.Context,
 	logger logr.Logger,
@@ -45,12 +49,12 @@ func (r *HTTPScaledObjectReconciler) createOrUpdateApplicationResources(
 	)
 
 	// We want to integrate http scaler with other
-	// scalers. when SkipScaledObjectCreation is set to true,
+	// scalers. when "httpscaledobject.keda.sh/skip-scaledobject-creation" is set to true,
 	// reconciler will skip the KEDA core ScaledObjects creation or delete scaledObject if it already exists.
 	// you can then create your own SO, and add http scaler as one of your triggers.
-	if httpso.Annotations["skipScaledObjectCreation"] == "true" {
+	if httpso.Annotations[SkipScaledObjectCreationAnnotation] == "true" {
 		logger.Info(
-			"Skip scaled objects creation with flag SkipScaledObjectCreation=true",
+			"Skip scaled objects creation with flag 'httpscaledobject.keda.sh/skip-scaledobject-creation'=true",
 			"HTTPScaledObject", httpso.Name)
 		err := r.deleteScaledObject(ctx, cl, logger, httpso)
 		if err != nil {


Test patch:
diff --git a/operator/controllers/http/suite_test.go b/operator/controllers/http/suite_test.go
index 4b89abb..e7e1e09 100644
--- a/operator/controllers/http/suite_test.go
+++ b/operator/controllers/http/suite_test.go
@@ -147,7 +147,7 @@ func newCommonTestInfraWithSkipScaledObjectCreation(namespace, appName string) *
 			Namespace: namespace,
 			Name:      appName,
 			Annotations: map[string]string{
-				"skipScaledObjectCreation": "true",
+				"httpscaledobject.keda.sh/skip-scaledobject-creation": "true",
 			},
 		},
 		Spec: httpv1alpha1.HTTPScaledObjectSpec{
diff --git a/tests/checks/scaling_phase_deployment_with_skip_so_creation/scaling_phase_deployment_with_skip_so_creation_test.go b/tests/checks/scaling_phase_deployment_with_skip_so_creation/scaling_phase_deployment_with_skip_so_creation_test.go
index 33d3d85..88589f3 100644
--- a/tests/checks/scaling_phase_deployment_with_skip_so_creation/scaling_phase_deployment_with_skip_so_creation_test.go
+++ b/tests/checks/scaling_phase_deployment_with_skip_so_creation/scaling_phase_deployment_with_skip_so_creation_test.go
@@ -124,7 +124,7 @@ metadata:
   name: {{.HTTPScaledObjectName}}
   namespace: {{.TestNamespace}}
   annotations:
-    skipScaledObjectCreation: "true"
+    httpscaledobject.keda.sh/skip-scaledobject-creation: "true"
 spec:
   hosts:
   - {{.Host}}