From 387a4131ca54ab987ce058c46dde0d0006c6a64f Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Fri, 21 Jun 2019 17:15:23 +0530 Subject: [PATCH] Update heketi vendor dependency to v9.0.0 Fix# https://github.com/kubernetes/kubernetes/issues/79234 Signed-off-by: Humble Chirammal --- go.mod | 4 +- go.sum | 4 +- .../heketi/heketi/client/api/go-client/BUILD | 1 + .../heketi/heketi/client/api/go-client/db.go | 32 +++++ .../heketi/client/api/go-client/operations.go | 116 ++++++++++++++++++ .../heketi/client/api/go-client/state.go | 52 ++++++++ .../heketi/heketi/pkg/glusterfs/api/types.go | 79 ++++++++---- vendor/modules.txt | 2 +- 8 files changed, 264 insertions(+), 26 deletions(-) create mode 100644 vendor/github.com/heketi/heketi/client/api/go-client/state.go diff --git a/go.mod b/go.mod index 1be050ecc26..1c065ae1e46 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,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 @@ -297,7 +297,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 diff --git a/go.sum b/go.sum index 4730c589b9e..4a0dec123a8 100644 --- a/go.sum +++ b/go.sum @@ -212,8 +212,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= diff --git a/vendor/github.com/heketi/heketi/client/api/go-client/BUILD b/vendor/github.com/heketi/heketi/client/api/go-client/BUILD index 4cc7cec05c8..3eb068052ac 100644 --- a/vendor/github.com/heketi/heketi/client/api/go-client/BUILD +++ b/vendor/github.com/heketi/heketi/client/api/go-client/BUILD @@ -13,6 +13,7 @@ go_library( "logging.go", "node.go", "operations.go", + "state.go", "topology.go", "volume.go", ], diff --git a/vendor/github.com/heketi/heketi/client/api/go-client/db.go b/vendor/github.com/heketi/heketi/client/api/go-client/db.go index 72ed129b002..2d33a160ecd 100644 --- a/vendor/github.com/heketi/heketi/client/api/go-client/db.go +++ b/vendor/github.com/heketi/heketi/client/api/go-client/db.go @@ -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 +} diff --git a/vendor/github.com/heketi/heketi/client/api/go-client/operations.go b/vendor/github.com/heketi/heketi/client/api/go-client/operations.go index d641aea5007..a588b9eca54 100644 --- a/vendor/github.com/heketi/heketi/client/api/go-client/operations.go +++ b/vendor/github.com/heketi/heketi/client/api/go-client/operations.go @@ -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 +} diff --git a/vendor/github.com/heketi/heketi/client/api/go-client/state.go b/vendor/github.com/heketi/heketi/client/api/go-client/state.go new file mode 100644 index 00000000000..df2271935c6 --- /dev/null +++ b/vendor/github.com/heketi/heketi/client/api/go-client/state.go @@ -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 . +// +// 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 +} diff --git a/vendor/github.com/heketi/heketi/pkg/glusterfs/api/types.go b/vendor/github.com/heketi/heketi/pkg/glusterfs/api/types.go index 759fb9bda3a..c665607cdb7 100644 --- a/vendor/github.com/heketi/heketi/pkg/glusterfs/api/types.go +++ b/vendor/github.com/heketi/heketi/pkg/glusterfs/api/types.go @@ -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 +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f0708c86a1e..08a565e8f8a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -534,7 +534,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