Skip to content

Commit

Permalink
admin: return additional info in admin API responses (minio#935)
Browse files Browse the repository at this point in the history
this enhances the admin API responses by returning additional
information
  • Loading branch information
Praveenrajmani authored Aug 28, 2024
1 parent a0b8eed commit 137e750
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 15 deletions.
2 changes: 2 additions & 0 deletions pkg/admin/cordon.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
type CordonResult struct {
NodeID directpvtypes.NodeID
DriveName directpvtypes.DriveName
DriveID directpvtypes.DriveID
}

// CordonArgs represents the args to Cordon the drive
Expand Down Expand Up @@ -104,6 +105,7 @@ func (client *Client) Cordon(ctx context.Context, args CordonArgs, log LogFunc)
results = append(results, CordonResult{
NodeID: result.Drive.GetNodeID(),
DriveName: result.Drive.GetDriveName(),
DriveID: result.Drive.GetDriveID(),
})
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/admin/label_drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (l Label) String() string {
type LabelDriveResult struct {
NodeID directpvtypes.NodeID
DriveName directpvtypes.DriveName
DriveID directpvtypes.DriveID
}

// LabelDriveArgs represents the arguments for adding/removing labels on/from the drives
Expand Down Expand Up @@ -116,11 +117,12 @@ func (client *Client) LabelDrives(ctx context.Context, args LabelDriveArgs, labe
FormattedMessage: fmt.Sprintf("Label '%s' successfully %s %v/%v\n", labels[i].String(), verb, drive.GetNodeID(), drive.GetDriveName()),
},
)
results = append(results, LabelDriveResult{
NodeID: drive.GetNodeID(),
DriveName: drive.GetDriveName(),
DriveID: drive.GetDriveID(),
})
}
results = append(results, LabelDriveResult{
NodeID: drive.GetNodeID(),
DriveName: drive.GetDriveName(),
})
return
}
retry.RetryOnConflict(retry.DefaultRetry, updateFunc)
Expand Down
8 changes: 4 additions & 4 deletions pkg/admin/label_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ func (client *Client) LabelVolumes(ctx context.Context, args LabelVolumeArgs, la
FormattedMessage: fmt.Sprintf("Label '%s' successfully %s %v\n", labels[i].String(), verb, volume.Name),
},
)
results = append(results, LabelVolumeResult{
NodeID: volume.GetNodeID(),
VolumeName: volume.Name,
})
}
results = append(results, LabelVolumeResult{
NodeID: volume.GetNodeID(),
VolumeName: volume.Name,
})
return
}
retry.RetryOnConflict(retry.DefaultRetry, updateFunc)
Expand Down
2 changes: 2 additions & 0 deletions pkg/admin/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type RemoveArgs struct {
type RemoveResult struct {
NodeID directpvtypes.NodeID
DriveName directpvtypes.DriveName
DriveID directpvtypes.DriveID
}

// Remove removes the initialized drive(s)
Expand Down Expand Up @@ -103,6 +104,7 @@ func (client *Client) Remove(ctx context.Context, args RemoveArgs, log LogFunc)
results = append(results, RemoveResult{
NodeID: result.Drive.GetNodeID(),
DriveName: result.Drive.GetDriveName(),
DriveID: result.Drive.GetDriveID(),
})
}
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/admin/repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ type RepairArgs struct {

// RepairResult represents result of repaired drive
type RepairResult struct {
JobName string
DriveID directpvtypes.DriveID
JobName string
DriveName directpvtypes.DriveName
DriveID directpvtypes.DriveID
}

type repairContainerParams struct {
Expand Down Expand Up @@ -229,7 +230,7 @@ func (client *Client) Repair(ctx context.Context, args RepairArgs, log LogFunc)
},
)

results = append(results, RepairResult{JobName: jobName, DriveID: result.Drive.GetDriveID()})
results = append(results, RepairResult{JobName: jobName, DriveName: result.Drive.GetDriveName(), DriveID: result.Drive.GetDriveID()})
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/admin/suspend_drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type SuspendDriveArgs struct {
type SuspendDriveResult struct {
NodeID directpvtypes.NodeID
DriveName directpvtypes.DriveName
DriveID directpvtypes.DriveID
Volumes []string
}

// SuspendDrives suspends the drive
Expand Down Expand Up @@ -103,6 +105,8 @@ func (client *Client) SuspendDrives(ctx context.Context, args SuspendDriveArgs,
results = append(results, SuspendDriveResult{
NodeID: result.Drive.GetNodeID(),
DriveName: result.Drive.GetDriveName(),
DriveID: result.Drive.GetDriveID(),
Volumes: result.Drive.GetVolumes(),
})
}

Expand Down
16 changes: 12 additions & 4 deletions pkg/admin/suspend_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ type SuspendVolumeArgs struct {

// SuspendVolumeResult represents the suspended volume
type SuspendVolumeResult struct {
NodeID directpvtypes.NodeID
VolumeName string
NodeID directpvtypes.NodeID
VolumeName string
DriveID directpvtypes.DriveID
DriveName directpvtypes.DriveName
PodName string
PodNamespace string
}

// SuspendVolumes suspends the volume
Expand Down Expand Up @@ -98,8 +102,12 @@ func (client *Client) SuspendVolumes(ctx context.Context, args SuspendVolumeArgs
)

results = append(results, SuspendVolumeResult{
NodeID: result.Volume.GetNodeID(),
VolumeName: result.Volume.Name,
NodeID: result.Volume.GetNodeID(),
VolumeName: result.Volume.Name,
DriveID: result.Volume.GetDriveID(),
DriveName: result.Volume.GetDriveName(),
PodName: result.Volume.GetPodName(),
PodNamespace: result.Volume.GetPodNS(),
})
}
if !processed {
Expand Down
1 change: 1 addition & 0 deletions pkg/admin/uncordon.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (client *Client) Uncordon(ctx context.Context, args UncordonArgs, log LogFu
results = append(results, UncordonResult{
NodeID: result.Drive.GetNodeID(),
DriveName: result.Drive.GetDriveName(),
DriveID: result.Drive.GetDriveID(),
})
}

Expand Down

0 comments on commit 137e750

Please sign in to comment.