Skip to content

Commit

Permalink
Improve Delete error handling AND release bugfixes as 1.8.2 (#721)
Browse files Browse the repository at this point in the history
* fix: Continue over individual delete failures

Also improve some log messages as part of aggregated error logging.

This change brings delete in line with the general idea to continue
as far as possible also applied to deployments. In this case, failure
to delete a single defined object, does not mean that the rest can not
be deleted.

ref: #720

* docs(release): Release Monaco in version 1.8.2

This bugfix release mostly improves resilience with extended retry logic,
and improves messages presented to the user in case of erros.

* feat: Retry SLO creation on additional know error

* fix: Continue over individual delete failures
* fix: Workaround synthetic API failing if Application ID can not (yet) be found
* fix: filter the mime types correctly for logging (#709)
* fix(download): Deleting configs with slashes in the name does no longer error. (#706)
* fix(download): Downloading single config Apis now report encountered errors

* docs: Rename 1.8.0 sidebar to 1.8.1 as .0 docs where completely replaced
* docs: Upgrade to docusaurus 2.0.1 release
* chore(deps): bump github.com/urfave/cli/v2 from 2.11.1 to 2.11.2
  • Loading branch information
UnseenWizzard authored Aug 30, 2022
1 parent 04807b4 commit 1ec37a2
Show file tree
Hide file tree
Showing 31 changed files with 28 additions and 25 deletions.
10 changes: 5 additions & 5 deletions documentation/docs/Get-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ For Linux/macOS, we recommend using `curl`. You can download it from [here](http
```shell
# Linux
# x64
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.7.0/monaco-linux-amd64 -o monaco
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.2/monaco-linux-amd64 -o monaco

# x86
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.7.0/monaco-linux-386 -o monaco
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.2/monaco-linux-386 -o monaco

# macOS
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.7.0/monaco-darwin-10.16-amd64 -o monaco
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.2/monaco-darwin-10.16-amd64 -o monaco
```

Make the binary executable:
Expand Down Expand Up @@ -71,7 +71,7 @@ NAME:
USAGE:
monaco-linux-amd64 [global options] command [command options] [working directory]
VERSION:
1.7.0
1.8.2
DESCRIPTION:
Tool used to deploy dynatrace configurations via the cli
Examples:
Expand Down Expand Up @@ -122,7 +122,7 @@ USAGE:
monaco.exe [global options] command [command options] [working directory]

VERSION:
1.7.0
1.8.2

DESCRIPTION:
Tool used to deploy dynatrace configurations via the cli
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ For Linux/macOS, we recommend using `curl`. You can download it from [here](http
```shell
# Linux
# x64
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.1/monaco-linux-amd64 -o monaco
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.2/monaco-linux-amd64 -o monaco

# x86
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.1/monaco-linux-386 -o monaco
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.2/monaco-linux-386 -o monaco

# macOS
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.1/monaco-darwin-10.16-amd64 -o monaco
curl -L https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/releases/download/v1.8.2/monaco-darwin-10.16-amd64 -o monaco
```

Make the binary executable:
Expand Down Expand Up @@ -71,7 +71,7 @@ NAME:
USAGE:
monaco-linux-amd64 [global options] command [command options] [working directory]
VERSION:
1.8.1
1.8.2
DESCRIPTION:
Tool used to deploy dynatrace configurations via the cli
Examples:
Expand Down Expand Up @@ -122,7 +122,7 @@ USAGE:
monaco.exe [global options] command [command options] [working directory]

VERSION:
1.8.1
1.8.2

DESCRIPTION:
Tool used to deploy dynatrace configurations via the cli
Expand Down Expand Up @@ -153,4 +153,4 @@ GLOBAL OPTIONS:
</TabItem>
</Tabs>
Now that Monaco is installed, follow our introductory guide on [how to deploy a configuration to Dynatrace.](../configuration/deploy_configuration)
Now that Monaco is installed, follow our introductory guide on [how to deploy a configuration to Dynatrace.](../configuration/deploy_configuration)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version-1.8.1/tutorialSidebar": [
"version-1.8.2/tutorialSidebar": [
{
"type": "autogenerated",
"dirName": "."
Expand Down
2 changes: 1 addition & 1 deletion documentation/versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
"1.8.1",
"1.8.2",
"1.7.0",
"1.6.0",
"1.5.3"
Expand Down
21 changes: 12 additions & 9 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ func Deploy(
util.Log.Info("Deployment finished without errors")
}

err = deleteConfigs(apis, environments, workingDir, dryRun, fs)
if err != nil {
return fmt.Errorf("errors during delete! Check log")
deleteErrors := deleteConfigs(apis, environments, workingDir, dryRun, fs)
if len(deleteErrors) > 0 {
util.Log.Error("Errors during delete:")
util.PrintErrors(deleteErrors)
}

return nil
Expand Down Expand Up @@ -346,7 +347,7 @@ func uploadConfig(client rest.DynatraceClient, project project.Project, config c
}

// deleteConfigs deletes specified configs, if a delete.yaml file was found
func deleteConfigs(apis map[string]api.Api, environments map[string]environment.Environment, path string, dryRun bool, fs afero.Fs) error {
func deleteConfigs(apis map[string]api.Api, environments map[string]environment.Environment, path string, dryRun bool, fs afero.Fs) (errs []error) {
configs, err := delete.LoadConfigsToDelete(fs, apis, path)
util.FailOnError(err, "deletion failed")

Expand All @@ -357,25 +358,27 @@ func deleteConfigs(apis map[string]api.Api, environments map[string]environment.

apiToken, err := environment.GetToken()
if err != nil {
return err
return []error{err}
}

client, err := rest.NewDynatraceClient(environment.GetEnvironmentUrl(), apiToken)
if err != nil {
return err
return []error{err}
}

for _, config := range configs {
util.Log.Debug("\tTrying to delete config %v (%v)", config.GetId(), config.GetApi().GetId())

err = client.DeleteByName(config.GetApi(), config.GetId())
if err != nil {
return err
util.Log.Error("\tFailed to delete config %v (%v)", config.GetId(), config.GetApi().GetId())
errs = append(errs, err)
} else {
util.Log.Info("\tDeleted config %v (%v)", config.GetId(), config.GetApi().GetId())
}
util.Log.Info("\tDeleted config %v (%v)", config.GetId(), config.GetApi().GetId())
}
}
}

return nil
return errs
}
4 changes: 2 additions & 2 deletions pkg/rest/config_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func deleteDynatraceObject(client *http.Client, api api.Api, name string, url st

existingId, err := getObjectIdIfAlreadyExists(client, api, url, name, token)
if err != nil {
return err
return fmt.Errorf("failed to get config for deletion %s (%s):\n %w", name, api.GetId(), err)
}

if len(existingId) == 0 {
Expand All @@ -306,7 +306,7 @@ func deleteDynatraceObject(client *http.Client, api api.Api, name string, url st

err = deleteConfig(client, url, token, existingId)
if err != nil {
return fmt.Errorf("failed to delete config %s (%s): %w", name, api.GetId(), err)
return fmt.Errorf("failed to delete config %s (%s):\n %w", name, api.GetId(), err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

package version

const MonitoringAsCode = "1.8.1"
const MonitoringAsCode = "1.8.2"

0 comments on commit 1ec37a2

Please sign in to comment.