Skip to content

Commit

Permalink
feat: Revision History Limit for sensor. Closes #1786 (#2244)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
AalokAhluwalia authored and whynowy committed Dec 12, 2022
1 parent 314f07b commit 3a0fb22
Show file tree
Hide file tree
Showing 12 changed files with 403 additions and 271 deletions.
5 changes: 5 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,11 @@
"format": "int32",
"type": "integer"
},
"revisionHistoryLimit": {
"description": "RevisionHistoryLimit specifies how many old deployment revisions to retain",
"format": "int32",
"type": "integer"
},
"template": {
"$ref": "#/definitions/io.argoproj.sensor.v1alpha1.Template",
"description": "Template is the pod specification for the sensor"
Expand Down
5 changes: 5 additions & 0 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions api/sensor.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions api/sensor.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion controllers/sensor/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ func buildDeploymentSpec(args *AdaptorArgs) (*appv1.DeploymentSpec, error) {
Selector: &metav1.LabelSelector{
MatchLabels: args.Labels,
},
Replicas: &replicas,
Replicas: &replicas,
RevisionHistoryLimit: args.Sensor.Spec.RevisionHistoryLimit,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: podTemplateLabels,
Expand Down
14 changes: 14 additions & 0 deletions controllers/sensor/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ func Test_BuildDeployment(t *testing.T) {
assert.True(t, hasTmpVolume)
assert.True(t, len(deployment.Spec.Template.Spec.ImagePullSecrets) > 0)
assert.Equal(t, deployment.Spec.Template.Spec.PriorityClassName, "test-class")
assert.Nil(t, deployment.Spec.RevisionHistoryLimit)
})
t.Run("test revisionHistoryLimit", func(t *testing.T) {
sensorWithRevisionHistoryLimit := sensorObj.DeepCopy()
sensorWithRevisionHistoryLimit.Spec.RevisionHistoryLimit = func() *int32 { i := int32(3); return &i }()
args := &AdaptorArgs{
Image: testImage,
Sensor: sensorWithRevisionHistoryLimit,
Labels: testLabels,
}
deployment, err := buildDeployment(args, fakeEventBus)
assert.Nil(t, err)
assert.NotNil(t, deployment)
assert.Equal(t, int32(3), *deployment.Spec.RevisionHistoryLimit)
})
}

Expand Down
10 changes: 10 additions & 0 deletions docs/sensors/more-about-sensors-and-triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,13 @@ spec:
# Requests per unit
requestsPerUnit: 20
```
## Revision History Limit
Optionally, a `revisionHistoryLimit` may be configured in the spec as following:

```yaml
spec:
# Optional
revisionHistoryLimit: 3
```
570 changes: 300 additions & 270 deletions pkg/apis/sensor/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pkg/apis/sensor/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/apis/sensor/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/apis/sensor/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ type SensorSpec struct {
EventBusName string `json:"eventBusName,omitempty" protobuf:"bytes,5,opt,name=eventBusName"`
// Replicas is the sensor deployment replicas
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,6,opt,name=replicas"`
// RevisionHistoryLimit specifies how many old deployment revisions to retain
// +optional
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,7,opt,name=revisionHistoryLimit"`
}

func (s SensorSpec) GetReplicas() int32 {
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/sensor/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a0fb22

Please sign in to comment.