Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian J <[email protected]>
  • Loading branch information
derjust committed Nov 19, 2021
1 parent 55791d4 commit 5e40c54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 0 additions & 1 deletion pkg/signals/signal_posix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build !windows
// +build !windows

package signals
Expand Down
3 changes: 0 additions & 3 deletions rollout/temlateref.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -249,8 +248,6 @@ func (r *informerBasedTemplateResolver) updateRolloutsReferenceAnnotation(obj in
// update the annotation causes the rollout to be requeued and the template will be resolved to the referred
// workload during next reconciliation
ro.Spec.Template.Spec.Containers = []corev1.Container{}
log.Infof("Selector should not exist: %v in %v", ro.Spec.Selector, ro)
ro.Spec.Selector = &metav1.LabelSelector{}
_, err := r.argoprojclientset.ArgoprojV1alpha1().Rollouts(ro.Namespace).Update(context.TODO(), ro, v1.UpdateOptions{})
if err != nil {
log.Errorf("Cannot update the workload-ref/annotation for %s/%s: %v", ro.GetName(), ro.GetNamespace(), err)
Expand Down
25 changes: 17 additions & 8 deletions rollout/trafficrouting/alb/alb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,11 @@ func TestGetForwardActionStringMarshalsZeroCorrectly(t *testing.T) {

func TestGetForwardActionStringMarshalsDisabledStickyConfigCorrectly(t *testing.T) {
r := fakeRollout("stable", "canary", "ingress", 443)
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig.Enabled = false
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig.DurationSeconds = 0
stickinessConfig := v1alpha1.StickinessConfig{
Enabled: false,
DurationSeconds: 0,
}
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig = &stickinessConfig
forwardAction, err := getForwardActionString(r, 443, 0)
if err != nil {
t.Fatal(err)
Expand All @@ -334,23 +337,29 @@ func TestGetForwardActionStringMarshalsDisabledStickyConfigCorrectly(t *testing.

func TestGetForwardActionStringDetectsNegativeStickyConfigDuration(t *testing.T) {
r := fakeRollout("stable", "canary", "ingress", 443)
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig.Enabled = true
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig.DurationSeconds = 0
stickinessConfig := v1alpha1.StickinessConfig{
Enabled: true,
DurationSeconds: 0,
}
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig = &stickinessConfig
forwardAction, err := getForwardActionString(r, 443, 0)

assert.NotNilf(t, forwardAction, "There should be no forwardAction being generated: %v", forwardAction)
expectedErrorMsg := "asdf"
expectedErrorMsg := "TargetGroupStickinessConfig's duration must be between 1 and 604800 seconds (7 days)!"
assert.EqualErrorf(t, err, expectedErrorMsg, "Error should be: %v, got: %v", expectedErrorMsg, err)
}

func TestGetForwardActionStringDetectsTooLargeStickyConfigDuration(t *testing.T) {
r := fakeRollout("stable", "canary", "ingress", 443)
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig.Enabled = true
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig.DurationSeconds = 604800 + 1
stickinessConfig := v1alpha1.StickinessConfig{
Enabled: true,
DurationSeconds: 604800 + 1,
}
r.Spec.Strategy.Canary.TrafficRouting.ALB.StickinessConfig = &stickinessConfig
forwardAction, err := getForwardActionString(r, 443, 0)

assert.NotNilf(t, forwardAction, "There should be no forwardAction being generated: %v", forwardAction)
expectedErrorMsg := "asdf"
expectedErrorMsg := "TargetGroupStickinessConfig's duration must be between 1 and 604800 seconds (7 days)!"
assert.EqualErrorf(t, err, expectedErrorMsg, "Error should be: %v, got: %v", expectedErrorMsg, err)
}

Expand Down

0 comments on commit 5e40c54

Please sign in to comment.