Uploaded image for project: 'DC/OS'
  1. DC/OS
  2. DCOS_OSS-4949

Enable optional files in diagnostics-bundle

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: DC/OS 1.13.0
    • Component/s: dcos-diagnostics
    • Labels:
      None
    • Sprint:
      ClusterOps - FND Sprint 43
    • Story Points:
      5

      Description

      Currently w can specify commands, files and endpoints to fetch by diagnostics-bundle. For some installations it will be convinet to include optional files in the bundle e.g., masos archival logs or storage logs that may not exist on cluster.
      Optional file means when there is no such file then it content is empty and bundle is not marked as failed.

      We can add file parameter to prevent failures if file is marked as Optional

      https://github.com/dcos/dcos-diagnostics/blob/cd5a7d263b6af1dd88d001cdb08a7e91f62b8bbf/api/providers.go#L28
      https://github.com/dcos/dcos-diagnostics/blob/3138c75c4f165850725f102099f74bc263fa0910/api/diagnostics.go#L949-L961

      diff --git a/api/diagnostics.go b/api/diagnostics.go
      index 78873d7..e292dc9 100644
      --- a/api/diagnostics.go
      +++ b/api/diagnostics.go
      @@ -8,6 +8,7 @@ import (
              "errors"
              "fmt"
              "io"
      +       "io/ioutil"
              "net/http"
              "os"
              "path/filepath"
      @@ -957,7 +958,12 @@ func (j *DiagnosticsJob) dispatchLogs(ctx context.Context, provider, entity stri
                              return r, errors.New("Not allowed to read a file")
                      }
                      logrus.Debugf("Found a file %s", fileProvider.Location)
      -               return os.Open(fileProvider.Location)
      +
      +               file, err := os.Open(fileProvider.Location)
      +               if fileProvider.Optional && os.IsNotExist(err) {
      +                       return ioutil.NopCloser(bytes.NewReader(nil)), nil
      +               }
      +               return file, err
              }
              if provider == "cmds" {
                      logrus.Debugf("dispatching a command %s", entity)
      diff --git a/api/providers.go b/api/providers.go
      index 834407f..dd2500d 100644
      --- a/api/providers.go
      +++ b/api/providers.go
      @@ -28,6 +28,7 @@ type HTTPProvider struct {
       type FileProvider struct {
              Location string
              Role     []string
      +       Optional bool
       }
      

        Attachments

          Activity

            People

            • Assignee:
              tomaszjaniszewski Tomasz Janiszewski
              Reporter:
              tomaszjaniszewski Tomasz Janiszewski
              Team:
              Cluster Ops Team
              Watchers:
              Daniel Baker, Mergebot, Thorsten Ball (Inactive), Tomasz Janiszewski
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: