Skip to content

Commit c72e92e

Browse files
committed
SREP-3620: Add feature-testing evidence collection commands
- osdctl aws cloudtrail errors: surface AWS permission errors - osdctl cluster snapshot: capture cluster state - osdctl cluster diff: compare snapshots - osdctl evidence collect: all-in-one collection - Support ROSA Classic and HCP clusters - Add README documentation
1 parent 3676092 commit c72e92e

20 files changed

Lines changed: 2878 additions & 0 deletions

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,84 @@ Note : Here node-id refers to the node that has the unhealthy etcd member. This
635635
```
636636
osdctl swarm secondary
637637
```
638+
639+
### Feature Testing Evidence Collection
640+
641+
These commands help SRE teams collect evidence during feature validation testing (IAM policies, operators, etc.).
642+
643+
#### AWS CloudTrail Errors
644+
645+
Surface permission errors and other AWS API errors from CloudTrail. Useful when validating new IAM policies or features that interact with AWS APIs.
646+
647+
```bash
648+
# Get permission errors from the last hour
649+
osdctl aws cloudtrail errors -C <cluster-id> --since 1h
650+
651+
# Get errors from the last 30 minutes with JSON output
652+
osdctl aws cloudtrail errors -C <cluster-id> --since 30m --json
653+
654+
# Get errors with AWS console links
655+
osdctl aws cloudtrail errors -C <cluster-id> --since 2h --link
656+
657+
# Filter for specific error types
658+
osdctl aws cloudtrail errors -C <cluster-id> --since 1h --error-types AccessDenied,UnauthorizedOperation
659+
```
660+
661+
**Note:** For ROSA HCP clusters, CloudTrail events only show customer account activity. Control plane activity is in Red Hat's account and not visible.
662+
663+
#### Cluster Snapshot
664+
665+
Capture a point-in-time snapshot of cluster state for evidence collection. The snapshot includes nodes, ClusterOperators, and namespaces.
666+
667+
```bash
668+
# Capture cluster snapshot to a file
669+
osdctl cluster snapshot -C <cluster-id> -o before.yaml
670+
671+
# Capture snapshot with specific namespaces
672+
osdctl cluster snapshot -C <cluster-id> -o snapshot.yaml --namespaces openshift-monitoring,openshift-operators
673+
674+
# Capture additional resource types
675+
osdctl cluster snapshot -C <cluster-id> -o snapshot.yaml --resources pods,deployments,services
676+
```
677+
678+
#### Cluster Diff
679+
680+
Compare two cluster snapshots to identify changes. Useful for understanding what changed during feature testing.
681+
682+
```bash
683+
# Compare two snapshots
684+
osdctl cluster diff before.yaml after.yaml
685+
686+
# Compare snapshots with JSON output
687+
osdctl cluster diff before.yaml after.yaml --json
688+
```
689+
690+
Changes are categorized as:
691+
- `+` added: Resource exists in after but not in before
692+
- `-` removed: Resource exists in before but not in after
693+
- `~` modified: Resource exists in both but with different values
694+
695+
#### Evidence Collection (All-in-One)
696+
697+
Collect comprehensive evidence from a cluster and AWS for feature testing. This all-in-one command gathers cluster state, CloudTrail events, and optionally Kubernetes events and must-gather output.
698+
699+
```bash
700+
# Collect all evidence to a directory
701+
osdctl evidence collect -C <cluster-id> --output ./evidence/
702+
703+
# Collect evidence from the last 2 hours
704+
osdctl evidence collect -C <cluster-id> --output ./evidence/ --since 2h
705+
706+
# Collect evidence without CloudTrail (for non-AWS or limited access)
707+
osdctl evidence collect -C <cluster-id> --output ./evidence/ --skip-cloudtrail
708+
709+
# Include Kubernetes events in collection
710+
osdctl evidence collect -C <cluster-id> --output ./evidence/ --include-events
711+
712+
# Include must-gather output
713+
osdctl evidence collect -C <cluster-id> --output ./evidence/ --include-must-gather
714+
```
715+
716+
The collected evidence includes:
717+
- `evidence.yaml` - Main evidence file with cluster state and CloudTrail data
718+
- `summary.txt` - Human-readable summary of findings

cmd/aws/cloudtrail/cmd.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cloudtrail
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
// NewCmdCloudtrail returns the cloudtrail command group under aws
8+
func NewCmdCloudtrail() *cobra.Command {
9+
cloudtrailCmd := &cobra.Command{
10+
Use: "cloudtrail",
11+
Short: "AWS CloudTrail utilities for feature testing",
12+
Long: `AWS CloudTrail utilities for feature testing and evidence collection.
13+
14+
Use these commands to surface CloudTrail events, particularly permission
15+
errors that occur during feature validation testing.`,
16+
Run: func(cmd *cobra.Command, args []string) {
17+
_ = cmd.Help()
18+
},
19+
}
20+
21+
cloudtrailCmd.AddCommand(newCmdErrors())
22+
23+
return cloudtrailCmd
24+
}

0 commit comments

Comments
 (0)