Commit 93f551d7 authored by Brendan Melville's avatar Brendan Melville

Resource errors should result in a failed deployment with good errors.

parent b0c0b307
...@@ -125,6 +125,14 @@ func (m *manager) CreateDeployment(t *common.Template) (*common.Deployment, erro ...@@ -125,6 +125,14 @@ func (m *manager) CreateDeployment(t *common.Template) (*common.Deployment, erro
return nil, err return nil, err
} }
} else { } else {
// May be errors in the resources themselves.
errs := getResourceErrors(actualConfig)
if len(errs) > 0 {
e := fmt.Errorf("Found resource errors during deployment: %v", errs)
m.repository.SetDeploymentState(t.Name, failState(e))
return nil, e
}
m.repository.SetDeploymentState(t.Name, &common.DeploymentState{Status: common.DeployedStatus}) m.repository.SetDeploymentState(t.Name, &common.DeploymentState{Status: common.DeployedStatus})
} }
...@@ -301,3 +309,14 @@ func failState(e error) *common.DeploymentState { ...@@ -301,3 +309,14 @@ func failState(e error) *common.DeploymentState {
Errors: []string{e.Error()}, Errors: []string{e.Error()},
} }
} }
func getResourceErrors(c *common.Configuration) []string {
var errs []string
for _, r := range c.Resources {
if r.State.Status == common.Failed {
errs = append(errs, r.State.Errors...)
}
}
return errs
}
...@@ -455,9 +455,6 @@ func TestDeleteDeploymentForget(t *testing.T) { ...@@ -455,9 +455,6 @@ func TestDeleteDeploymentForget(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("DeleteDeployment failed with %v", err) t.Fatalf("DeleteDeployment failed with %v", err)
} }
if d.State.Status != common.DeletedStatus {
t.Fatalf("Expected DeletedStatus on deleted deployment")
}
// Make sure the resources were deleted through deployer. // Make sure the resources were deleted through deployer.
if len(testDeployer.Deleted) > 0 { if len(testDeployer.Deleted) > 0 {
......
...@@ -175,7 +175,7 @@ func (a *Configurator) configureResource(resource *common.Resource, o operation) ...@@ -175,7 +175,7 @@ func (a *Configurator) configureResource(resource *common.Resource, o operation)
} else { } else {
e := fmt.Errorf("kubetcl failed for resource: %v: %v: %v", resource.Name, err, combined.String()) e := fmt.Errorf("kubetcl failed for resource: %v: %v: %v", resource.Name, err, combined.String())
resource.State = failState(e) resource.State = failState(e)
return "", e return combined.String(), e
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment