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

Integrate Experiments with Analysis #210

Merged
merged 14 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Initial integration with experiments and analysis
  • Loading branch information
jessesuen committed Oct 19, 2019
commit 3648c50e447aac8119ce4fa06303eba65193ffec
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ lint:

.PHONY: test
test:
go test -failfast -covermode=count -coverprofile=coverage.out `go list ./...`
go test -failfast -covermode=count -coverprofile=coverage.out `go list ./... | grep -v github.com/argoproj/argo-rollouts/pkg/client`

.PHONY: mocks
mocks:
Expand Down
2 changes: 1 addition & 1 deletion docs/features/analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ kind: Experiment
name:
name: guestbook-6c54544bf9-0
spec:
durationSeconds: 3600
duration: 3600
templates:
- name: baseline
replicas: 1
Expand Down
10 changes: 8 additions & 2 deletions docs/features/rollout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
minReadySeconds: 30
# The number of old ReplicaSets to retain. If unspecified, will retain 10 old ReplicaSets
revisionHistoryLimit: 3
# Indiciates if the rollout is paused
# Indicates if the rollout is paused
paused: false
# The maximum time in seconds for a rollout to make progress before it is considered to be failed. Argo Rollouts will continue to process failed rollouts and a condition with a ProgressDeadlineExceeded reason will be surfaced in the rollout status. Note that progress will not be estimated during the time a rollout is paused. Defaults to 600s.
progressDeadlineSeconds: 600
Expand Down Expand Up @@ -54,4 +54,10 @@ spec:
duration: 3600 # One hour
- setWeight: 40
# Sets .spec.paused to true and waits until the field is changed back
- pause: {}
- pause: {}
status:
pauseConditions:
- reason: StepPause
startTime: 2019-10-00T1234
- reason: BlueGreenPause
- reason: AnalysisRunInconclusive
18 changes: 5 additions & 13 deletions experiments/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
)

func TestUpdateProgressingLastUpdateTime(t *testing.T) {
f := newFixture(t)
defer f.Close()

templates := generateTemplates("bar")
templates[0].Replicas = pointer.Int32Ptr(2)
Expand All @@ -29,11 +27,10 @@ func TestUpdateProgressingLastUpdateTime(t *testing.T) {
*prevCond,
}

f.experimentLister = append(f.experimentLister, e)
f.objects = append(f.objects, e)
rs := templateToRS(e, templates[0], 1)
f.replicaSetLister = append(f.replicaSetLister, rs)
f.kubeobjects = append(f.kubeobjects, rs)

f := newFixture(t, e, rs)
defer f.Close()

patchIndex := f.expectPatchExperimentAction(e)

Expand All @@ -49,9 +46,6 @@ func TestUpdateProgressingLastUpdateTime(t *testing.T) {
}

func TestEnterTimeoutDegradedState(t *testing.T) {
f := newFixture(t)
defer f.Close()

templates := generateTemplates("bar")
e := newExperiment("foo", templates, nil, pointer.BoolPtr(true))
e.Status.TemplateStatuses = []v1alpha1.TemplateStatus{{
Expand All @@ -66,11 +60,9 @@ func TestEnterTimeoutDegradedState(t *testing.T) {
*prevCond,
}

f.experimentLister = append(f.experimentLister, e)
f.objects = append(f.objects, e)
rs := templateToRS(e, templates[0], 0)
f.replicaSetLister = append(f.replicaSetLister, rs)
f.kubeobjects = append(f.kubeobjects, rs)
f := newFixture(t, e, rs)
defer f.Close()

patchIndex := f.expectPatchExperimentAction(e)

Expand Down
24 changes: 10 additions & 14 deletions experiments/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,17 @@ func (ec *ExperimentController) syncHandler(key string) error {
return err
}

exCtx := experimentContext{
log: logCtx,
ex: experiment,
templateRSs: templateRSs,
kubeclientset: ec.kubeclientset,
argoProjClientset: ec.argoProjClientset,
replicaSetLister: ec.replicaSetLister,
recorder: ec.recorder,
enqueueExperimentAfter: ec.enqueueExperimentAfter,
}
exCtx := newExperimentContext(
experiment,
templateRSs,
ec.kubeclientset,
ec.argoProjClientset,
ec.replicaSetLister,
ec.recorder,
ec.enqueueExperimentAfter,
)

newStatus, err := exCtx.reconcile()
if err != nil {
return err
}
newStatus := exCtx.reconcile()
dthomson25 marked this conversation as resolved.
Show resolved Hide resolved
return ec.persistExperimentStatus(experiment, newStatus)
}

Expand Down
45 changes: 21 additions & 24 deletions experiments/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,23 @@ type fixture struct {
unfreezeTime func()
}

func newFixture(t *testing.T) *fixture {
func newFixture(t *testing.T, objects ...runtime.Object) *fixture {
f := &fixture{}
f.t = t
f.objects = []runtime.Object{}
f.kubeobjects = []runtime.Object{}
for _, obj := range objects {
switch obj.(type) {
case *v1alpha1.Experiment:
f.objects = append(f.objects, obj)
f.experimentLister = append(f.experimentLister, obj.(*v1alpha1.Experiment))
case *appsv1.ReplicaSet:
f.kubeobjects = append(f.kubeobjects, obj)
f.replicaSetLister = append(f.replicaSetLister, obj.(*appsv1.ReplicaSet))
}
}
f.client = fake.NewSimpleClientset(f.objects...)
f.kubeclient = k8sfake.NewSimpleClientset(f.kubeobjects...)
f.enqueuedObjects = make(map[string]int)
now := time.Now()
patch := monkey.Patch(time.Now, func() time.Time { return now })
Expand Down Expand Up @@ -284,9 +296,6 @@ func getKey(experiment *v1alpha1.Experiment, t *testing.T) string {
type resyncFunc func() time.Duration

func (f *fixture) newController(resync resyncFunc) (*ExperimentController, informers.SharedInformerFactory, kubeinformers.SharedInformerFactory) {
f.client = fake.NewSimpleClientset(f.objects...)
f.kubeclient = k8sfake.NewSimpleClientset(f.kubeobjects...)

i := informers.NewSharedInformerFactory(f.client, resync())
k8sI := kubeinformers.NewSharedInformerFactory(f.kubeclient, resync())

Expand Down Expand Up @@ -593,15 +602,12 @@ func validatePatch(t *testing.T, patch string, running *bool, availableleAt avai
}

func TestAddInvalidSpec(t *testing.T) {
f := newFixture(t)
defer f.Close()

templates := generateTemplates("bar", "baz")
e := newExperiment("foo", templates, nil, pointer.BoolPtr(true))
e.Spec.Templates[0].Name = ""

f.experimentLister = append(f.experimentLister, e)
f.objects = append(f.objects, e)
f := newFixture(t, e)
defer f.Close()

patchIndex := f.expectPatchExperimentAction(e)
f.run(getKey(e, t))
Expand All @@ -617,9 +623,6 @@ func TestAddInvalidSpec(t *testing.T) {
}

func TestKeepInvalidSpec(t *testing.T) {
f := newFixture(t)
defer f.Close()

templates := generateTemplates("bar", "baz")
e := newExperiment("foo", templates, nil, pointer.BoolPtr(true))
e.Status.Conditions = []v1alpha1.ExperimentCondition{{
Expand All @@ -630,17 +633,14 @@ func TestKeepInvalidSpec(t *testing.T) {
}}
e.Spec.Templates[0].Name = ""

f.experimentLister = append(f.experimentLister, e)
f.objects = append(f.objects, e)
f := newFixture(t, e)
defer f.Close()

f.run(getKey(e, t))

}

func TestUpdateInvalidSpec(t *testing.T) {
f := newFixture(t)
defer f.Close()

templates := generateTemplates("bar", "baz")
e := newExperiment("foo", templates, nil, pointer.BoolPtr(true))

Expand All @@ -653,8 +653,8 @@ func TestUpdateInvalidSpec(t *testing.T) {

e.Spec.Templates[0].Name = ""

f.experimentLister = append(f.experimentLister, e)
f.objects = append(f.objects, e)
f := newFixture(t, e)
defer f.Close()

patchIndex := f.expectPatchExperimentAction(e)
f.run(getKey(e, t))
Expand All @@ -671,9 +671,6 @@ func TestUpdateInvalidSpec(t *testing.T) {
}

func TestRemoveInvalidSpec(t *testing.T) {
f := newFixture(t)
defer f.Close()

templates := generateTemplates("bar", "baz")
e := newExperiment("foo", templates, nil, pointer.BoolPtr(true))

Expand All @@ -683,8 +680,8 @@ func TestRemoveInvalidSpec(t *testing.T) {
Reason: conditions.InvalidSpecReason,
}}

f.experimentLister = append(f.experimentLister, e)
f.objects = append(f.objects, e)
f := newFixture(t, e)
defer f.Close()

createFirstRSIndex := f.expectCreateReplicaSetAction(templateToRS(e, templates[0], 0))
createSecondRSIndex := f.expectCreateReplicaSetAction(templateToRS(e, templates[1], 0))
Expand Down
Loading