Skip to content

Commit 2c748ec

Browse files
author
Mateus Oliveira
authored
fix: must-gather standards (#1726)
Signed-off-by: Mateus Oliveira <[email protected]>
1 parent d4ed05f commit 2c748ec

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

must-gather/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,33 @@ go mod verify
7575
## Deprecated folder
7676

7777
Scripts under `deprecated/` folder are for backwards compatibility with old OADP Must-gather shell script. Users should use new OADP Must-gather Go script, as highlighted in product documentation.
78+
79+
## Standards
80+
81+
OADP Must-gather must comply with https://github.com/openshift/enhancements/blob/995b620cb04c030bf62c908e188472fe7031a704/enhancements/oc/must-gather.md?plain=1#L94-L104
82+
83+
>1. Must have a zero-arg, executable file at `/usr/bin/gather` that does your default gathering
84+
85+
OADP Must-gather binary can be called without args. All OADP Must-gather binary args are optional
86+
87+
>2. Must produce data to be copied back at `/must-gather`. The data must not contain any sensitive data. We don't string PII information, only secret information.
88+
89+
OADP Must-gather collected data is stored at `/must-gather` folder in the same path the binary was called.
90+
91+
Most of the data is collected through `oc adm inspect` command (including Secrets). The other data are cluster information, OADP related information (CRDs and CRs) and storage information (StorageClasses, VolumeSnapshotClasses and CSIDrivers CRDs and CRs). These objects should not contain any sensitive data.
92+
93+
>3. Must produce a text `/must-gather/version` that indicates the product (first line) and the version (second line, `major.minor.micro-qualifier`),
94+
> so that programmatic analysis can be developed.
95+
96+
OADP Must-gather stores version information in `/must-gather/version` file
97+
98+
Example content of the file
99+
```txt
100+
OpenShift API for Data Protection (OADP) Must-gather
101+
master-branch
102+
```
103+
104+
>4. Should honor the user-provided values for `--since` and `--since-time`, which are passed to plugins via
105+
> environment variables named `MUST_GATHER_SINCE` and `MUST_GATHER_SINCE_TIME`, respectively.
106+
107+
TODO `oc adm inspect` command is called through Go code. But both `since` and `since-time` are private. Need to change this in https://github.com/openshift/oc/blob/ae1bd9e4a75b8ab617a569e5c8e1a0d7285a16f6/pkg/cli/admin/inspect/inspect.go#L118-L119 to allow usage in OADP Must-gather

must-gather/pkg/cli.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ For more information, check OADP must-gather documentation: https://docs.redhat.
345345
templates.ReplaceAvailableVolumeSnapshotClassesSection(outputPath, volumeSnapshotClassList)
346346
templates.ReplaceAvailableCSIDriversSection(outputPath, csiDriverList)
347347
templates.ReplaceCustomResourceDefinitionsSection(outputPath, clusterConfig)
348+
err = templates.WriteVersion(mustGatherVersion)
349+
if err != nil {
350+
fmt.Printf("Error occurred: %v\n", err)
351+
return err
352+
}
348353
// do not tar!
349354
err = templates.Write(outputPath)
350355
if err != nil {

must-gather/pkg/templates/summary.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,3 +1690,21 @@ func Write(outputPath string) error {
16901690
defer sumary.Close()
16911691
return nil
16921692
}
1693+
1694+
func WriteVersion(version string) error {
1695+
versionFileContent := fmt.Sprintf(
1696+
`OpenShift API for Data Protection (OADP) Must-gather
1697+
%s`,
1698+
version)
1699+
versionFilePath := "must-gather/version"
1700+
versionFile, err := os.Create(versionFilePath)
1701+
if err != nil {
1702+
return err
1703+
}
1704+
err = os.WriteFile(versionFilePath, []byte(versionFileContent), FilePermission)
1705+
if err != nil {
1706+
return err
1707+
}
1708+
defer versionFile.Close()
1709+
return nil
1710+
}

0 commit comments

Comments
 (0)