Skip to content

Commit

Permalink
FT-335 pick up the product integrated support bundle(drop auth.log) w…
Browse files Browse the repository at this point in the history
…hen the pf9ctl CLI operations fail. (#271)

* dropping auth.log

* now picking files from /var/opt/pf9

* checking for /var/opt while generating partial bundle
  • Loading branch information
Rohitrajak1807 authored Jan 31, 2022
1 parent c3ec065 commit 7c7303b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions pkg/supportBundle/supportBundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var (
fileloc string
err error
S3_Location string
authfile string
msgfile string
lockfile string
hostOS string
Expand Down Expand Up @@ -204,22 +203,20 @@ func GenSupportBundle(exec cmdexec.Executor, timestamp time.Time, isRemote bool)
zap.S().Debug("Dmesg files not Found!! ", errDmesg)
}

_, errOpt := exec.RunWithStdout("bash", "-c", fmt.Sprintf("stat %s", util.OptDir))
if errOpt != nil {
zap.S().Debug(fmt.Sprintf("%s directory not found!!", util.OptDir))
}

//Assign specific files according to the platform
if hostOS == "debian" {
authfile = util.AuthDeb
msgfile = util.MsgDeb
lockfile = util.LockDeb
} else {
authfile = util.AuthRed
msgfile = util.MsgRed
lockfile = util.LockRed
}

_, errAuth := exec.RunWithStdout("bash", "-c", fmt.Sprintf("stat %s", authfile))
if errEtc != nil {
zap.S().Debug("Auth files not Found!! ", errAuth)
}

_, errMsg := exec.RunWithStdout("bash", "-c", fmt.Sprintf("stat %s", msgfile))
if errEtc != nil {
zap.S().Debug("Auth files not Found!! ", errMsg)
Expand All @@ -243,10 +240,10 @@ func GenSupportBundle(exec cmdexec.Executor, timestamp time.Time, isRemote bool)

if isRemote {
// Generate supportBundle if any of Etc / var logs are present or both
if errEtc == nil || errVar == nil {
if errEtc == nil || errVar == nil || errOpt == nil {
// Generation of supportBundle in remote host case.
_, errbundle := exec.RunWithStdout("bash", "-c", fmt.Sprintf("tar -czf %s %s %s %s %s %s %s",
targetfile, util.VarDir, util.EtcDir, util.DmesgLog, authfile, msgfile, lockfile))
targetfile, util.VarDir, util.EtcDir, util.DmesgLog, msgfile, lockfile, util.OptDir))
if errbundle != nil {
zap.S().Debug("Failed to generate complete supportBundle, generated partial bundle (Remote Host)", errbundle)
}
Expand All @@ -262,7 +259,7 @@ func GenSupportBundle(exec cmdexec.Executor, timestamp time.Time, isRemote bool)
} else {
// Generation of supportBundle in local host case.
_, errbundle := exec.RunWithStdout("bash", "-c", fmt.Sprintf("tar czf %s --directory=%s %s %s %s %s %s %s %s",
targetfile, util.Pf9DirLoc, util.Pf9LogLoc, util.VarDir, util.EtcDir, util.DmesgLog, authfile, msgfile, lockfile))
targetfile, util.Pf9DirLoc, util.Pf9LogLoc, util.VarDir, util.EtcDir, util.DmesgLog, msgfile, lockfile, util.OptDir))
if errbundle != nil {
zap.S().Debug("Failed to generate complete supportBundle, generated partial bundle", errbundle)
return targetfile, ErrPartialBundle
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ var (
// before it starts with the operations.
WaitPeriod = time.Duration(60)

OptDir = "/var/opt/pf9"

//Location of ovf service file
OVFLoc = "/etc/systemd/system/ovf.service"
VarDir = "/var/log/pf9"
Expand All @@ -93,10 +95,8 @@ var (

//Auth,Dmesg,dpkg/yum files for Debian/Redhat
DmesgLog = "/var/log/dmesg"
AuthDeb = "/var/log/auth.log"
MsgDeb = "/var/log/syslog"
LockDeb = "/var/log/dpkg.log"
AuthRed = "/var/log/secure"
MsgRed = "/var/log/messages"
LockRed = "/var/log/yum.log"

Expand Down

0 comments on commit 7c7303b

Please sign in to comment.