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

Fix plan marked as completed when template was broken #519

Merged
merged 18 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
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
6 changes: 5 additions & 1 deletion pkg/controller/planexecution/planexecution_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
if err != nil {
r.recorder.Event(planExecution, "Warning", "InvalidPlanExecution", fmt.Sprintf("Error expanding template: %v", err))
log.Printf("PlanExecutionController: Error expanding template: %v", err)
planExecution.Status.State = kudov1alpha1.PhaseStateError
planExecution.Status.Phases[i].State = kudov1alpha1.PhaseStateError
// returning error = nil so that we don't retry since this is non-recoverable
return reconcile.Result{}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update the API object here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
fsys.WriteFile(fmt.Sprintf("%s/%s", basePath, res), []byte(templatedYaml))
resources = append(resources, res)
Expand Down Expand Up @@ -449,7 +453,7 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
planExecution.Status.Phases[i].Steps[j].Name = step.Name
planExecution.Status.Phases[i].Steps[j].Objects = objs
planExecution.Status.Phases[i].Steps[j].Delete = step.Delete
log.Printf("PlanExecutionController: Phase \"%v\" Step \"%v\" has %v object(s)", phase.Name, step.Name, len(objs))
log.Printf("PlanExecutionController: Phase \"%v\" Step \"%v\" of instance '%v' has %v object(s)", phase.Name, step.Name, instance.Name, len(objs))
}
}

Expand Down
18 changes: 18 additions & 0 deletions test/integration/rendering-error-plan-failed/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kudo.k8s.io/v1alpha1
kind: PlanExecution
metadata:
labels:
instance: invalid1
operator-version: invalid-v1
ownerReferences:
- apiVersion: kudo.k8s.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: Instance
name: invalid1
status:
name: deploy
state: ERROR
phases:
- name: invalid-phase
state: ERROR
73 changes: 73 additions & 0 deletions test/integration/rendering-error-plan-failed/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: kudo.k8s.io/v1alpha1
kind: Operator
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: invalid
---
apiVersion: kudo.k8s.io/v1alpha1
kind: OperatorVersion
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: invalid-v1
spec:
version: "1.0.0"
connectionString: ""
operator:
name: Toy
kind: Operator
templates:
serial.yaml: |
apiVersion: batch/v1
kind: Job
metadata:
name: serial-{{ .StepName }}
spec:
template:
metadata:
name: "{{ .StepName }}-serial-{{ .StepNumber }}"
spec:
restartPolicy: OnFailure
containers:
- name: bb
image: busybox:latest
Copy link
Member

@jbarrick-mesosphere jbarrick-mesosphere Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These pods are (currently) being created against envtest so no actual containers are able to be created. If there's not a way to write this test without requiring containers to start, I'll setup a KIND environment to run our tests like we do for the operator tests (either, a separate suite or just run everything in KIND).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this shouldn't render at all, I see :)

imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- "sleep {{ .Params.NonExisting }}"
tasks:
invalid-task:
resources:
- serial.yaml
parameters:
- name: Sleep
description: "how long to have the container sleep for before returning"
required: true
displayName: "Sleep Time"
plans:
deploy:
strategy: serial
phases:
- name: invalid-phase
strategy: serial
steps:
- name: invalid-step
tasks:
- invalid-task
---
apiVersion: kudo.k8s.io/v1alpha1
kind: Instance
metadata:
labels:
controller-tools.k8s.io: "1.0"
operator: invalid
name: invalid1
spec:
operatorVersion:
name: invalid-v1
type: OperatorVersions
# Add fields here
parameters:
Sleep: "30"