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

Backport/bugfix/bugfix/gh 77 dep status issue #292

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
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