Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: RedHatInsights/clowder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bada018d61ac7ecea39b4f03cf25aa05af1ebd85
Choose a base ref
..
head repository: RedHatInsights/clowder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7782fac115f7e3bd40c7efac32e7a5c1e3fa8b48
Choose a head ref
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/go-toolset:1.22.9-1 as builder
FROM registry.access.redhat.com/ubi8/go-toolset:1.22.9-1.1734311333 as builder
USER 0
ENV GOSUMDB=off

4 changes: 4 additions & 0 deletions apis/cloud.redhat.com/v1alpha1/clowdapp_types.go
Original file line number Diff line number Diff line change
@@ -251,6 +251,10 @@ func (d *Deployment) GetReplicaCount() *int32 {
return &retVal
}

func (d *Deployment) HasAutoScaler() bool {
return d.AutoScaler != nil || d.AutoScalerSimple != nil
}

type DeploymentStrategy struct {
// PrivateStrategy allows a deployment that only uses a private port to set
// the deployment strategy one of Recreate or Rolling, default for a
9 changes: 8 additions & 1 deletion controllers/cloud.redhat.com/providers/deployment/impl.go
Original file line number Diff line number Diff line change
@@ -65,7 +65,14 @@ func setMinReplicas(deployment *crd.Deployment, d *apps.Deployment) {

// No sense in running all these conditionals if desired state and observed state match
if d.Spec.Replicas != nil && (*d.Spec.Replicas >= *replicaCount) {
return
// if deployment has an autoscaler, just keep the replica count the same it currently is
// since it has at least the desired count
if deployment.HasAutoScaler() {
return
}
// reset the replica count when there is no autoscaler. this will scale down a deployment that
// has more than desired count
d.Spec.Replicas = replicaCount
}

// If the spec has nil replicas or the spec replicas are less than the deployment replicas
7 changes: 7 additions & 0 deletions tests/kuttl/test-replica-scaledown-nonzero/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: test-replica-scaledown-nonzero
spec:
finalizers:
- kubernetes
21 changes: 21 additions & 0 deletions tests/kuttl/test-replica-scaledown-nonzero/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: v1
kind: Secret
metadata:
name: puptoo
namespace: test-replica-scaledown-nonzero
labels:
app: puptoo
ownerReferences:
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
name: puptoo
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: puptoo-processor
namespace: test-replica-scaledown-nonzero
spec:
replicas: 4
47 changes: 47 additions & 0 deletions tests/kuttl/test-replica-scaledown-nonzero/01-pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
metadata:
name: test-replica-scaledown-nonzero
spec:
targetNamespace: test-replica-scaledown-nonzero
providers:
web:
port: 8000
mode: operator
metrics:
port: 9000
mode: operator
path: "/metrics"
kafka:
mode: none
db:
mode: none
logging:
mode: none
objectStore:
mode: none
inMemoryDb:
mode: none
featureFlags:
mode: none
resourceDefaults:
limits:
cpu: 400m
memory: 1024Mi
requests:
cpu: 30m
memory: 512Mi
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: puptoo
namespace: test-replica-scaledown-nonzero
spec:
envName: test-replica-scaledown-nonzero
deployments:
- name: processor
replicas: 4
podSpec:
image: quay.io/psav/clowder-hello
8 changes: 8 additions & 0 deletions tests/kuttl/test-replica-scaledown-nonzero/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: puptoo-processor
namespace: test-replica-scaledown-nonzero
spec:
replicas: 1
13 changes: 13 additions & 0 deletions tests/kuttl/test-replica-scaledown-nonzero/02-pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: puptoo
namespace: test-replica-scaledown-nonzero
spec:
envName: test-replica-scaledown-nonzero
deployments:
- name: processor
replicas: 1
podSpec:
image: quay.io/psav/clowder-hello
10 changes: 10 additions & 0 deletions tests/kuttl/test-replica-scaledown-nonzero/03-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: v1
kind: Namespace
name: test-replica-scaledown-nonzero
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
name: test-replica-scaledown-nonzero