Skip to content

Commit

Permalink
Merge pull request #292 from ystia/backport/bugfix/bugfix/gh-77-dep-s…
Browse files Browse the repository at this point in the history
…tatus-issue

Backport/bugfix/bugfix/gh 77 dep status issue
  • Loading branch information
stefbenoist authored Feb 1, 2019
2 parents 4ce6e77 + 2deb810 commit 7182122
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Can't deploy applications using a secured yorc/consul ([GH-274](https://github.com/ystia/yorc/issues/274))
* Unable to purge an application that appears in the list ([GH-238](https://github.com/ystia/yorc/issues/238))
* K8S jobs namespace should not be removed if its provided ([GH-245](https://github.com/ystia/yorc/issues/245))
* Deployment with a topology parsing error remains in initial status ([GH-283](https://github.com/ystia/yorc/issues/283)

## 3.1.0 (December 20, 2018)

Expand Down
19 changes: 13 additions & 6 deletions deployments/definition_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,35 @@ func StoreDeploymentDefinition(ctx context.Context, kv *api.KV, deploymentID str
topology := tosca.Topology{}
definition, err := os.Open(defPath)
if err != nil {
return errors.Wrapf(err, "Failed to open definition file %q", defPath)
return handleDeploymentStatus(deploymentID, errors.Wrapf(err, "Failed to open definition file %q", defPath))
}
defBytes, err := ioutil.ReadAll(definition)
if err != nil {
return errors.Wrapf(err, "Failed to open definition file %q", defPath)
return handleDeploymentStatus(deploymentID, errors.Wrapf(err, "Failed to open definition file %q", defPath))
}

err = yaml.Unmarshal(defBytes, &topology)
if err != nil {
return errors.Wrapf(err, "Failed to unmarshal yaml definition for file %q", defPath)
return handleDeploymentStatus(deploymentID, errors.Wrapf(err, "Failed to unmarshal yaml definition for file %q", defPath))
}

err = storeDeployment(ctx, topology, deploymentID, filepath.Dir(defPath))
if err != nil {
return errors.Wrapf(err, "Failed to store TOSCA Definition for deployment with id %q, (file path %q)", deploymentID, defPath)
return handleDeploymentStatus(deploymentID, errors.Wrapf(err, "Failed to store TOSCA Definition for deployment with id %q, (file path %q)", deploymentID, defPath))
}
err = registerImplementationTypes(ctx, kv, deploymentID)
if err != nil {
return err
return handleDeploymentStatus(deploymentID, err)
}

return enhanceNodes(ctx, kv, deploymentID)
return handleDeploymentStatus(deploymentID, enhanceNodes(ctx, kv, deploymentID))
}

func handleDeploymentStatus(deploymentID string, err error) error {
if err != nil {
consulutil.StoreConsulKeyAsString(path.Join(consulutil.DeploymentKVPrefix, deploymentID, "status"), fmt.Sprint(DEPLOYMENT_FAILED))
}
return err
}

// storeDeployment stores a whole deployment.
Expand Down

0 comments on commit 7182122

Please sign in to comment.