Skip to content

Commit

Permalink
KEP-29: instance controller reconciliation for parent instances (#1555)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Dukhovniy committed Jun 9, 2020
1 parent a0a7e34 commit 2aac262
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/kudo/v1beta1/instance_types.go
Expand Up @@ -182,12 +182,12 @@ var (
}
)

// IsTerminal returns true if the status is terminal (either complete, or in a nonrecoverable error)
// IsTerminal returns true if the status is terminal (either complete, or in a fatal error)
func (s ExecutionStatus) IsTerminal() bool {
return s == ExecutionComplete || s == ExecutionFatalError
}

// IsFinished returns true if the status is complete regardless of errors
// IsFinished returns true if the status is complete successfully (not in 'FATAL_ERROR' state)
func (s ExecutionStatus) IsFinished() bool {
return s == ExecutionComplete
}
Expand Down
13 changes: 0 additions & 13 deletions pkg/apis/kudo/v1beta1/instance_types_helpers.go
Expand Up @@ -208,19 +208,6 @@ func wasRunAfter(p1 PlanStatus, p2 PlanStatus) bool {
return p1.LastUpdatedTimestamp.Time.After(p2.LastUpdatedTimestamp.Time)
}

// GetExistingParamDefinitions retrieves parameter metadata from OperatorVersion
func GetExistingParamDefinitions(params map[string]string, ov *OperatorVersion) []Parameter {
defs := []Parameter{}
for p1 := range params {
for _, p2 := range ov.Spec.Parameters {
if p2.Name == p1 {
defs = append(defs, p2)
}
}
}
return defs
}

// GetParamDefinitions retrieves parameter metadata from OperatorVersion but returns an error if any parameter is missing
func GetParamDefinitions(params map[string]string, ov *OperatorVersion) ([]Parameter, error) {
defs := []Parameter{}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/instance/instance_controller.go
Expand Up @@ -175,6 +175,7 @@ func (r *Reconciler) Reconcile(request ctrl.Request) (ctrl.Result, error) {
}

// ---------- 2. Get currently scheduled plan if it exists ----------

// get the scheduled plan
plan, uid := scheduledPlan(instance, ov)
if plan == "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/task/task_kudo_operator.go
Expand Up @@ -137,7 +137,7 @@ func instanceResource(instanceName, operatorName, operatorVersionName, namespace
},
Status: v1beta1.InstanceStatus{},
}
if err := controllerutil.SetControllerReference(owner, instance, scheme); err != nil {
if err := controllerutil.SetOwnerReference(owner, instance, scheme); err != nil {
return nil, fmt.Errorf("failed to set resource ownership for the new instance: %v", err)
}

Expand Down
10 changes: 10 additions & 0 deletions test/integration/operator-with-dependencies/01-assert.yaml
@@ -1,5 +1,15 @@
apiVersion: kudo.dev/v1beta1
kind: Instance
metadata:
name: dummy-instance
status:
planStatus:
deploy:
status: COMPLETE

---
apiVersion: kudo.dev/v1beta1
kind: Instance
metadata:
name: dummy-instance.child
status:
Expand Down

0 comments on commit 2aac262

Please sign in to comment.