Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
remove volume size/stats apis
Browse files Browse the repository at this point in the history
this is unused and implemented inefficiently; removing it as it's only
debt at the moment
  • Loading branch information
vito committed Jan 23, 2018
1 parent e8537c2 commit bf352f6
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 604 deletions.
1 change: 0 additions & 1 deletion api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func NewHandler(
baggageclaim.CreateVolumeAsyncCheck: http.HandlerFunc(volumeServer.CreateVolumeAsyncCheck),
baggageclaim.ListVolumes: http.HandlerFunc(volumeServer.ListVolumes),
baggageclaim.GetVolume: http.HandlerFunc(volumeServer.GetVolume),
baggageclaim.GetVolumeStats: http.HandlerFunc(volumeServer.GetVolumeStats),
baggageclaim.SetProperty: http.HandlerFunc(volumeServer.SetProperty),
baggageclaim.SetTTL: http.HandlerFunc(volumeServer.SetTTL),
baggageclaim.SetPrivileged: http.HandlerFunc(volumeServer.SetPrivileged),
Expand Down
30 changes: 0 additions & 30 deletions api/volume_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const httpUnprocessableEntity = 422

var ErrListVolumesFailed = errors.New("failed to list volumes")
var ErrGetVolumeFailed = errors.New("failed to get volume")
var ErrGetVolumeStatsFailed = errors.New("failed to get volume stats")
var ErrCreateVolumeFailed = errors.New("failed to create volume")
var ErrDestroyVolumeFailed = errors.New("failed to destroy volume")
var ErrSetPropertyFailed = errors.New("failed to set property on volume")
Expand Down Expand Up @@ -274,35 +273,6 @@ func (vs *VolumeServer) GetVolume(w http.ResponseWriter, req *http.Request) {
}
}

func (vs *VolumeServer) GetVolumeStats(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")

handle := rata.Param(req, "handle")

hLog := vs.logger.Session("get-volume-stats", lager.Data{
"volume": handle,
})

hLog.Debug("start")
defer hLog.Debug("done")

vol, found, err := vs.volumeRepo.GetVolumeStats(handle)
if err != nil {
hLog.Error("failed-to-get-volume-stats", err)
RespondWithError(w, ErrGetVolumeStatsFailed, http.StatusInternalServerError)
return
}

if !found {
RespondWithError(w, ErrGetVolumeStatsFailed, http.StatusNotFound)
return
}

if err := json.NewEncoder(w).Encode(vol); err != nil {
hLog.Error("failed-to-encode", err)
}
}

func (vs *VolumeServer) SetProperty(w http.ResponseWriter, req *http.Request) {
handle := rata.Param(req, "handle")
propertyName := rata.Param(req, "property")
Expand Down
56 changes: 0 additions & 56 deletions baggageclaimfakes/fake_volume.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions baggageclaimfakes/fake_volume_future.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ type Volume interface {
// be specified.
Release(*time.Duration)

// Size returns the exclusive size of the volume on disk in bytes
SizeInBytes() (int64, error)

// Destroy removes the volume and its contents. Note that it does not
// safeguard against child volumes being present. To safely remove a volume
// that may have children, set a TTL instead.
Expand Down
9 changes: 0 additions & 9 deletions client/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ func (cv *clientVolume) Path() string {
return cv.path
}

func (cv *clientVolume) SizeInBytes() (int64, error) {
stats, err := cv.bcClient.getVolumeStatsResponse(cv.logger, cv.handle)
if err != nil {
return 0, err
}

return stats.SizeInBytes, nil
}

func (cv *clientVolume) Properties() (baggageclaim.VolumeProperties, error) {
vr, found, err := cv.bcClient.getVolumeResponse(cv.logger, cv.handle)
if err != nil {
Expand Down
44 changes: 0 additions & 44 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,49 +572,5 @@ var _ = Describe("Baggage Claim Client", func() {
})
})
})

Describe("Getting volume stats", func() {
var vol baggageclaim.Volume
BeforeEach(func() {
bcServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/volumes-async"),
ghttp.RespondWithJSONEncoded(http.StatusCreated, baggageclaim.VolumeFutureResponse{
Handle: "some-handle",
}),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/volumes-async/some-handle"),
ghttp.RespondWithJSONEncoded(http.StatusOK, volume.Volume{
Handle: "some-handle",
Path: "some-path",
Properties: volume.Properties{},
TTL: volume.TTL(1),
ExpiresAt: time.Now().Add(time.Second),
}),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("PUT", "/volumes/some-handle/ttl"),
ghttp.RespondWith(http.StatusNoContent, ""),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("DELETE", "/volumes-async/some-handle"),
ghttp.RespondWith(http.StatusNoContent, ""),
),
)
var err error
vol, err = bcClient.CreateVolume(logger, "some-handle", baggageclaim.VolumeSpec{})
Expect(err).ToNot(HaveOccurred())
})

Context("when unexpected error occurs", func() {
It("returns error code and useful message", func() {
mockErrorResponse("GET", "/volumes/some-handle/stats", "lost baggage", http.StatusInternalServerError)
_, err := vol.SizeInBytes()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("lost baggage"))
})
})
})
})
})
Loading

0 comments on commit bf352f6

Please sign in to comment.