Skip to content

Commit

Permalink
Merge pull request #24479 from Luap99/volume-ls-race
Browse files Browse the repository at this point in the history
volume ls: fix race that caused it to fail
  • Loading branch information
openshift-merge-bot[bot] authored Nov 6, 2024
2 parents c0e24c6 + 9a0c0b2 commit 5cbb630
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
3 changes: 3 additions & 0 deletions pkg/api/handlers/compat/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
for _, v := range vols {
mp, err := v.MountPoint()
if err != nil {
if errors.Is(err, define.ErrNoSuchVolume) {
continue
}
utils.InternalServerError(w, err)
return
}
Expand Down
26 changes: 3 additions & 23 deletions pkg/api/handlers/libpod/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,13 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
return
}

volumeFilters := []libpod.VolumeFilter{}
for filter, filterValues := range *filterMap {
filterFunc, err := filters.GenerateVolumeFilters(filter, filterValues, runtime)
if err != nil {
utils.InternalServerError(w, err)
return
}
volumeFilters = append(volumeFilters, filterFunc)
}

vols, err := runtime.Volumes(volumeFilters...)
ic := abi.ContainerEngine{Libpod: runtime}
volumeConfigs, err := ic.VolumeList(r.Context(), entities.VolumeListOptions{Filter: *filterMap})
if err != nil {
utils.InternalServerError(w, err)
return
}
volumeConfigs := make([]*entities.VolumeListReport, 0, len(vols))
for _, v := range vols {
inspectOut, err := v.Inspect()
if err != nil {
utils.InternalServerError(w, err)
return
}
config := entities.VolumeConfigResponse{
InspectVolumeData: *inspectOut,
}
volumeConfigs = append(volumeConfigs, &entities.VolumeListReport{VolumeConfigResponse: config})
}

utils.WriteResponse(w, http.StatusOK, volumeConfigs)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/domain/infra/abi/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeL
for _, v := range vols {
inspectOut, err := v.Inspect()
if err != nil {
if errors.Is(err, define.ErrNoSuchVolume) {
continue
}
return nil, err
}
config := entities.VolumeConfigResponse{
Expand Down

1 comment on commit 5cbb630

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.