Merge pull request #79273 from humblec/heketi-update

Update heketi vendor dependency to v9.0.0
This commit is contained in:
Kubernetes Prow Robot 2019-06-22 22:56:07 -07:00 committed by GitHub
commit 42b8b7d331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 264 additions and 26 deletions

4
go.mod
View File

@ -79,7 +79,7 @@ require (
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.7.0 // indirect
github.com/hashicorp/golang-lru v0.5.0
github.com/heketi/heketi v0.0.0-20181109135656-558b29266ce0
github.com/heketi/heketi v9.0.0+incompatible
github.com/heketi/rest v0.0.0-20180404230133-aa6a65207413 // indirect
github.com/heketi/tests v0.0.0-20151005000721-f3775cbcefd6 // indirect
github.com/heketi/utils v0.0.0-20170317161834-435bc5bdfa64 // indirect
@ -298,7 +298,7 @@ replace (
github.com/hashicorp/go-syslog => github.com/hashicorp/go-syslog v1.0.0
github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0
github.com/hashicorp/hcl => github.com/hashicorp/hcl v0.0.0-20160711231752-d8c773c4cba1
github.com/heketi/heketi => github.com/heketi/heketi v0.0.0-20181109135656-558b29266ce0
github.com/heketi/heketi => github.com/heketi/heketi v9.0.0+incompatible
github.com/heketi/rest => github.com/heketi/rest v0.0.0-20180404230133-aa6a65207413
github.com/heketi/tests => github.com/heketi/tests v0.0.0-20151005000721-f3775cbcefd6
github.com/heketi/utils => github.com/heketi/utils v0.0.0-20170317161834-435bc5bdfa64

4
go.sum
View File

@ -214,8 +214,8 @@ github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCO
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v0.0.0-20160711231752-d8c773c4cba1 h1:9j16AiR0R5hDbDBMzfUfIP9CUbbw6T8nYN4iZz3/wjg=
github.com/hashicorp/hcl v0.0.0-20160711231752-d8c773c4cba1/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
github.com/heketi/heketi v0.0.0-20181109135656-558b29266ce0 h1:de43cfdq2fOAilB2qxrDnIPxL+7U/7Di3IFX8Dd0TOc=
github.com/heketi/heketi v0.0.0-20181109135656-558b29266ce0/go.mod h1:bB9ly3RchcQqsQ9CpyaQwvva7RS5ytVoSoholZQON6o=
github.com/heketi/heketi v9.0.0+incompatible h1:B2ACAbYsCHkJXKozYVV7p2j+eEy/zNlLsicihMWCk30=
github.com/heketi/heketi v9.0.0+incompatible/go.mod h1:bB9ly3RchcQqsQ9CpyaQwvva7RS5ytVoSoholZQON6o=
github.com/heketi/rest v0.0.0-20180404230133-aa6a65207413 h1:nGZBOxRgSMbqjm2/FYDtO6BU4a+hfR7Om9VGQ9tbbSc=
github.com/heketi/rest v0.0.0-20180404230133-aa6a65207413/go.mod h1:BeS3M108VzVlmAue3lv2WcGuPAX94/KN63MUURzbYSI=
github.com/heketi/tests v0.0.0-20151005000721-f3775cbcefd6 h1:oJ/NLadJn5HoxvonA6VxG31lg0d6XOURNA09BTtM4fY=

View File

@ -13,6 +13,7 @@ go_library(
"logging.go",
"node.go",
"operations.go",
"state.go",
"topology.go",
"volume.go",
],

View File

@ -50,3 +50,35 @@ func (c *Client) DbDump() (string, error) {
respJSON := string(respBytes)
return respJSON, nil
}
// DbCheck provides a JSON summary of the DB check operation
func (c *Client) DbCheck() (string, error) {
req, err := http.NewRequest("GET", c.host+"/db/check", nil)
if err != nil {
return "", err
}
// Set token
err = c.setToken(req)
if err != nil {
return "", err
}
// Send request
r, err := c.do(req)
if err != nil {
return "", err
}
defer r.Body.Close()
if r.StatusCode != http.StatusOK {
return "", utils.GetErrorFromResponse(r)
}
respBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
return "", err
}
respJSON := string(respBytes)
return respJSON, nil
}

View File

@ -13,7 +13,10 @@
package client
import (
"bytes"
"encoding/json"
"net/http"
"time"
"github.com/heketi/heketi/pkg/glusterfs/api"
"github.com/heketi/heketi/pkg/utils"
@ -37,6 +40,9 @@ func (c *Client) OperationsInfo() (*api.OperationsInfo, error) {
if err != nil {
return nil, err
}
if r.StatusCode != http.StatusOK {
return nil, utils.GetErrorFromResponse(r)
}
var oi api.OperationsInfo
err = utils.GetJsonFromResponse(r, &oi)
if err != nil {
@ -44,3 +50,113 @@ func (c *Client) OperationsInfo() (*api.OperationsInfo, error) {
}
return &oi, nil
}
func (c *Client) PendingOperationList() (*api.PendingOperationListResponse, error) {
req, err := http.NewRequest("GET", c.host+"/operations/pending", nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
// Set token
err = c.setToken(req)
if err != nil {
return nil, err
}
// Send request
r, err := c.do(req)
if err != nil {
return nil, err
}
if r.StatusCode != http.StatusOK {
return nil, utils.GetErrorFromResponse(r)
}
var ol api.PendingOperationListResponse
err = utils.GetJsonFromResponse(r, &ol)
if err != nil {
return nil, err
}
return &ol, nil
}
func (c *Client) PendingOperationDetails(
id string) (*api.PendingOperationDetails, error) {
req, err := http.NewRequest("GET", c.host+"/operations/pending/"+id, nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
// Set token
err = c.setToken(req)
if err != nil {
return nil, err
}
// Send request
r, err := c.do(req)
if err != nil {
return nil, err
}
if r.StatusCode != http.StatusOK {
return nil, utils.GetErrorFromResponse(r)
}
var pd api.PendingOperationDetails
err = utils.GetJsonFromResponse(r, &pd)
if err != nil {
return nil, err
}
return &pd, nil
}
func (c *Client) PendingOperationCleanUp(
request *api.PendingOperationsCleanRequest) error {
buffer, err := json.Marshal(request)
if err != nil {
return err
}
req, err := http.NewRequest("POST",
c.host+"/operations/pending/cleanup",
bytes.NewBuffer(buffer))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
// Set token
err = c.setToken(req)
if err != nil {
return err
}
r, err := c.do(req)
if err != nil {
return err
}
defer r.Body.Close()
switch r.StatusCode {
case http.StatusAccepted: // expected
case http.StatusOK:
return nil
default:
return utils.GetErrorFromResponse(r)
}
// NOTE: I (jjm) wanted this to truly async at first. But in
// order to not deviate from the current model too much
// AND that the rest async framework in heketi needs to be
// polled in order to remove things from its map, the traditional
// poll server after request behavior is retained here.
r, err = c.waitForResponseWithTimer(r, time.Second)
if err != nil {
return err
}
if r.StatusCode != http.StatusNoContent {
return utils.GetErrorFromResponse(r)
}
return nil
}

View File

@ -0,0 +1,52 @@
//
// Copyright (c) 2018 The heketi Authors
//
// This file is licensed to you under your choice of the GNU Lesser
// General Public License, version 3 or any later version (LGPLv3 or
// later), as published by the Free Software Foundation,
// or under the Apache License, Version 2.0 <LICENSE-APACHE2 or
// http://www.apache.org/licenses/LICENSE-2.0>.
//
// You may not use this file except in compliance with those terms.
//
package client
import (
"io/ioutil"
"net/http"
"github.com/heketi/heketi/pkg/utils"
)
// StateExamineGluster provides a comparision of DB and Gluster
func (c *Client) StateExamineGluster() (string, error) {
req, err := http.NewRequest("GET", c.host+"/internal/state/examine/gluster", nil)
if err != nil {
return "", err
}
// Set token
err = c.setToken(req)
if err != nil {
return "", err
}
// Send request
r, err := c.do(req)
if err != nil {
return "", err
}
defer r.Body.Close()
if r.StatusCode != http.StatusOK {
return "", utils.GetErrorFromResponse(r)
}
respBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
return "", err
}
respJSON := string(respBytes)
return respJSON, nil
}

View File

@ -226,8 +226,10 @@ type ClusterFlags struct {
type Cluster struct {
Volumes []VolumeInfoResponse `json:"volumes"`
Nodes []NodeInfoResponse `json:"nodes"`
Id string `json:"id"`
//currently BlockVolumes will be used only for metrics
BlockVolumes []BlockVolumeInfoResponse `json:"blockvolumes,omitempty"`
Nodes []NodeInfoResponse `json:"nodes"`
Id string `json:"id"`
ClusterFlags
}
@ -535,23 +537,6 @@ func (v *VolumeInfoResponse) String() string {
s += fmt.Sprintf("Snapshot Factor: %.2f\n",
v.Snapshot.Factor)
}
/*
s += "\nBricks:\n"
for _, b := range v.Bricks {
s += fmt.Sprintf("Id: %v\n"+
"Path: %v\n"+
"Size (GiB): %v\n"+
"Node: %v\n"+
"Device: %v\n\n",
b.Id,
b.Path,
b.Size/(1024*1024),
b.NodeId,
b.DeviceId)
}
*/
return s
}
@ -611,8 +596,9 @@ type OperationsInfo struct {
Total uint64 `json:"total"`
InFlight uint64 `json:"in_flight"`
// state based counts:
Stale uint64 `json:"stale"`
New uint64 `json:"new"`
Stale uint64 `json:"stale"`
Failed uint64 `json:"failed"`
New uint64 `json:"new"`
}
type AdminState string
@ -641,3 +627,54 @@ type DeviceDeleteOptions struct {
// orphaning metadata on the node
ForceForget bool `json:"forceforget"`
}
// PendingOperationInfo contains metadata to summarize a pending
// operation.
type PendingOperationInfo struct {
Id string `json:"id"`
TypeName string `json:"type_name"`
Status string `json:"status"`
SubStatus string `json:"sub_status"`
// TODO label, timestamp?
}
type PendingChangeInfo struct {
Id string `json:"id"`
Description string `json:"description"`
}
type PendingOperationDetails struct {
PendingOperationInfo
Changes []PendingChangeInfo `json:"changes"`
}
type PendingOperationListResponse struct {
PendingOperations []PendingOperationInfo `json:"pendingoperations"`
}
type PendingOperationsCleanRequest struct {
Operations []string `json:"operations,omitempty"`
}
func (pocr PendingOperationsCleanRequest) Validate() error {
return validation.ValidateStruct(&pocr,
validation.Field(&pocr.Operations, validation.By(ValidateIds)),
)
}
func ValidateIds(v interface{}) error {
ids, ok := v.([]string)
if !ok {
return fmt.Errorf("must be a list of strings")
}
if len(ids) > 32 {
return fmt.Errorf("too many ids specified (%v), up to %v supported",
len(ids), 32)
}
for _, id := range ids {
if err := ValidateUUID(id); err != nil {
return err
}
}
return nil
}

2
vendor/modules.txt vendored
View File

@ -537,7 +537,7 @@ github.com/hashicorp/hcl/hcl/token
github.com/hashicorp/hcl/json/parser
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/json/token
# github.com/heketi/heketi v0.0.0-20181109135656-558b29266ce0 => github.com/heketi/heketi v0.0.0-20181109135656-558b29266ce0
# github.com/heketi/heketi v9.0.0+incompatible => github.com/heketi/heketi v9.0.0+incompatible
github.com/heketi/heketi/client/api/go-client
github.com/heketi/heketi/pkg/glusterfs/api
github.com/heketi/heketi/pkg/utils