update storageos vendor for FilteredDial change

This commit is contained in:
Matthew Cary
2020-06-10 01:02:40 +00:00
parent 2aa1cd25f3
commit 74dbf274d9
58 changed files with 239 additions and 193 deletions

View File

@@ -32,9 +32,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/github.com/coreos/go-systemd/journal:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/github.com/coreos/go-systemd/journal:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/github.com/coreos/go-systemd/journal:go_default_library",
],

View File

@@ -31,9 +31,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/golang.org/x/sys/unix:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/golang.org/x/sys/unix:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/golang.org/x/sys/unix:go_default_library",
],

4
vendor/github.com/miekg/dns/BUILD generated vendored
View File

@@ -77,10 +77,6 @@ go_library(
"//vendor/golang.org/x/net/ipv6:go_default_library",
"//vendor/golang.org/x/sys/unix:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/golang.org/x/net/ipv4:go_default_library",
"//vendor/golang.org/x/net/ipv6:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/golang.org/x/net/ipv4:go_default_library",
"//vendor/golang.org/x/net/ipv6:go_default_library",

3
vendor/github.com/moby/term/BUILD generated vendored
View File

@@ -31,9 +31,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/golang.org/x/sys/unix:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/golang.org/x/sys/unix:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/golang.org/x/sys/unix:go_default_library",
],

View File

@@ -10,7 +10,6 @@ go_library(
"output_interceptor_win.go",
"server.go",
"syscall_dup_linux_arm64.go",
"syscall_dup_linux_riscv64.go",
"syscall_dup_solaris.go",
"syscall_dup_unix.go",
],

View File

@@ -39,9 +39,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library",
],

View File

@@ -29,9 +29,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/github.com/opencontainers/runc/libcontainer/user:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/github.com/opencontainers/runc/libcontainer/user:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/github.com/opencontainers/runc/libcontainer/user:go_default_library",
],

View File

@@ -56,9 +56,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/github.com/prometheus/procfs:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/github.com/prometheus/procfs:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/github.com/prometheus/procfs:go_default_library",
],

View File

@@ -4,7 +4,9 @@ go_library(
name = "go_default_library",
srcs = [
"client.go",
"cluster.go",
"health.go",
"licence.go",
"logger.go",
"login.go",
"namespace.go",

View File

@@ -44,6 +44,9 @@ var (
// ErrProxyNotSupported is returned when a client is unable to set a proxy for http requests.
ErrProxyNotSupported = errors.New("client does not support http proxy")
// ErrDialerNotSupported is returned when a client is unable to set a DialContext for http requests.
ErrDialerNotSupported = errors.New("client does not support setting DialContext")
// DefaultPort is the default API port.
DefaultPort = "5705"
@@ -107,6 +110,8 @@ type Dialer interface {
Dial(network, address string) (net.Conn, error)
}
type dialContext = func(ctx context.Context, network, address string) (net.Conn, error)
// NewClient returns a Client instance ready for communication with the given
// server endpoint. It will use the latest remote API version available in the
// server.
@@ -203,6 +208,36 @@ func (c *Client) SetTimeout(t time.Duration) {
}
}
// GetDialContext returns the current DialContext function, or nil if there is none.
func (c *Client) GetDialContext() dialContext {
c.configLock.RLock()
defer c.configLock.RUnlock()
if c.httpClient == nil {
return nil
}
transport, supported := c.httpClient.Transport.(*http.Transport)
if !supported {
return nil
}
return transport.DialContext
}
// SetDialContext uses the given dial function to establish TCP connections in the HTTPClient.
func (c *Client) SetDialContext(dial dialContext) error {
c.configLock.Lock()
defer c.configLock.Unlock()
if client := c.httpClient; client != nil {
transport, supported := client.Transport.(*http.Transport)
if !supported {
return ErrDialerNotSupported
}
transport.DialContext = dial
}
return nil
}
func (c *Client) checkAPIVersion() error {
serverAPIVersionString, err := c.getServerAPIVersionString()
if err != nil {
@@ -259,6 +294,8 @@ type doOptions struct {
forceJSON bool
force bool
unversioned bool
retryOn []int // http.status codes
}
func (c *Client) do(method, urlpath string, doOptions doOptions) (*http.Response, error) {
@@ -338,6 +375,7 @@ func (c *Client) do(method, urlpath string, doOptions doOptions) (*http.Response
resp, err := httpClient.Do(req.WithContext(ctx))
if err != nil {
// If it is a custom error, return it. It probably knows more than us
if serror.IsStorageOSError(err) {
switch serror.ErrorKind(err) {
@@ -366,6 +404,17 @@ func (c *Client) do(method, urlpath string, doOptions doOptions) (*http.Response
}
}
var shouldretry bool
if doOptions.retryOn != nil {
for _, code := range doOptions.retryOn {
if resp.StatusCode == code {
failedAddresses[address] = struct{}{}
shouldretry = true
}
}
}
// If we get to the point of response, we should move any failed
// addresses to the back.
failed := len(failedAddresses)
@@ -388,6 +437,10 @@ func (c *Client) do(method, urlpath string, doOptions doOptions) (*http.Response
c.addressLock.Unlock()
}
if shouldretry {
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
return nil, newError(resp) // These status codes are likely to be fatal
}

48
vendor/github.com/storageos/go-api/cluster.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package storageos
import (
"encoding/json"
"github.com/storageos/go-api/types"
)
var (
// ClusterMaintenanceAPIPrefix is a path to the HTTP endpoint for managing
// the cluster maintenance mode.
ClusterMaintenanceAPIPrefix = "cluster/maintenance"
)
// Maintenance returns the maintenance status of the cluster
func (c *Client) Maintenance() (*types.Maintenance, error) {
resp, err := c.do("GET", ClusterMaintenanceAPIPrefix, doOptions{})
if err != nil {
return nil, err
}
defer resp.Body.Close()
res := &types.Maintenance{}
if err := json.NewDecoder(resp.Body).Decode(res); err != nil {
return nil, err
}
return res, nil
}
// EnableMaintenance enables maintenance mode in the cluster
func (c *Client) EnableMaintenance() error {
resp, err := c.do("POST", ClusterMaintenanceAPIPrefix, doOptions{})
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}
// DisableMaintenance disables maintenance mode in the cluster
func (c *Client) DisableMaintenance() error {
resp, err := c.do("DELETE", ClusterMaintenanceAPIPrefix, doOptions{})
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}

View File

@@ -14,6 +14,22 @@ var (
HealthAPIPrefix = "health"
)
func (c *Client) ClusterHealth(ctx context.Context) ([]*types.ClusterHealthNode, error) {
status := []*types.ClusterHealthNode{}
url := fmt.Sprintf("/cluster/%s", HealthAPIPrefix)
resp, err := c.do("GET", url, doOptions{context: ctx, retryOn: []int{http.StatusNotFound}})
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := json.NewDecoder(resp.Body).Decode(&status); err != nil {
return nil, err
}
return status, nil
}
// CPHealth returns the health of the control plane server at a given url.
func (c *Client) CPHealth(ctx context.Context, hostname string) (*types.CPHealthStatus, error) {

43
vendor/github.com/storageos/go-api/licence.go generated vendored Normal file
View File

@@ -0,0 +1,43 @@
package storageos
import (
"encoding/json"
"github.com/storageos/go-api/types"
)
const (
// licenceAPIPrefix is a partial path to the HTTP endpoint.
licenceAPIPrefix = "licencing"
)
// Licence returns the current licence on the server.
func (c *Client) Licence() (*types.Licence, error) {
resp, err := c.do("GET", licenceAPIPrefix, doOptions{})
if err != nil {
return nil, err
}
defer resp.Body.Close()
licence := &types.Licence{}
if err := json.NewDecoder(resp.Body).Decode(&licence); err != nil {
return nil, err
}
return licence, nil
}
// LicenceApply applies a licence on the server.
func (c *Client) LicenceApply(licenceKey string) error {
_, err := c.do("POST", licenceAPIPrefix, doOptions{
data: &types.LicenceKeyContainer{Key: licenceKey},
})
return err
}
// LicenceDelete removes the current licence.
func (c *Client) LicenceDelete() error {
resp, err := c.do("DELETE", licenceAPIPrefix, doOptions{})
if err != nil {
return err
}
return resp.Body.Close()
}

View File

@@ -55,6 +55,12 @@ func AddressesFromNodes(nodes []string) ([]string, error) {
return nil, newInvalidNodeError(errInvalidHostName)
}
// Given input like "http://localhost:8080:8383", url.Parse() will
// return host as "localhost:8000", which isn't a vaild DNS name.
if strings.Contains(host, ":") {
return nil, newInvalidNodeError(errInvalidHostName)
}
port := url.Port()
if port == "" {
port = DefaultDialPort

View File

@@ -29,7 +29,7 @@ func (n *nopMarshaler) MarshalJSON() ([]byte, error) {
}
// PolicyCreate creates a policy on the server.
func (c *Client) PolicyCreate(jsonl []byte, ctx context.Context) error {
func (c *Client) PolicyCreate(ctx context.Context, jsonl []byte) error {
nopm := nopMarshaler(jsonl)
_, err := c.do("POST", PolicyAPIPrefix, doOptions{
data: &nopm,

View File

@@ -110,7 +110,7 @@ func (c *Client) PoolDelete(opts types.DeleteOptions) error {
return ErrPoolInUse
}
}
return nil
return err
}
defer resp.Body.Close()
return nil

View File

@@ -134,7 +134,7 @@ func (c *Client) RuleDelete(opts types.DeleteOptions) error {
return ErrRuleInUse
}
}
return nil
return err
}
defer resp.Body.Close()
return nil

View File

@@ -5,6 +5,7 @@ go_library(
srcs = [
"auth.go",
"capacity_stats.go",
"cluster.go",
"connectivity.go",
"delete_options.go",
"deployment.go",
@@ -12,6 +13,7 @@ go_library(
"error_response.go",
"events.go",
"health.go",
"licence.go",
"list_options.go",
"logger.go",
"namespace.go",

10
vendor/github.com/storageos/go-api/types/cluster.go generated vendored Normal file
View File

@@ -0,0 +1,10 @@
package types
import "time"
// Maintenance is used to place the cluster in maintenance mode.
type Maintenance struct {
Enabled bool `json:"enabled"`
UpdatedBy string `json:"updatedBy"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

@@ -14,6 +14,20 @@ type NamedSubModuleStatus struct {
SubModuleStatus
}
type ClusterHealthNode struct {
NodeID string `json:"nodeID"`
NodeName string `json:"nodeName"`
Submodules struct {
DirectFSInitiator SubModuleStatus `json:"directfs_initiator"`
Director SubModuleStatus `json:"director"`
KV SubModuleStatus `json:"kv"`
KVWrite SubModuleStatus `json:"kv_write"`
NATS SubModuleStatus `json:"nats"`
Presentation SubModuleStatus `json:"presentation"`
RDB SubModuleStatus `json:"rdb"`
} `json:"submodules"`
}
type CPHealthStatus struct {
KV SubModuleStatus
KVWrite SubModuleStatus

35
vendor/github.com/storageos/go-api/types/licence.go generated vendored Normal file
View File

@@ -0,0 +1,35 @@
package types
import "time"
// FeatureType store features types
type FeatureType string
const (
// HA means High Availability
HA = FeatureType("HA")
// DEV means developer licence
DEV = FeatureType("DEV")
// TRIAL means trial licence
TRIAL = FeatureType("TRIAL")
)
// Licence holds the information to be encoded in the licence key. It needs to be synced across
// the django server running on portal-API as well as the corresponding decoding package on the
// storageOS control plane
type Licence struct {
ArrayUUID string `json:"arrayUUID,omitempty"`
ClusterID string `json:"clusterID,omitempty"`
CustomerID string `json:"customerID"`
CustomerName string `json:"customerName"`
Storage int `json:"storage"`
ValidUntil time.Time `json:"validUntil"`
LicenceType string `json:"licenceType"`
Features map[FeatureType]bool `json:"features"`
Unregistered bool `json:"unregistered"`
}
// LicenceKeyContainer - stores a licence key
type LicenceKeyContainer struct {
Key string `json:"key"`
}

View File

@@ -12,7 +12,6 @@ import (
)
var (
// UserAPIPrefix is a partial path to the HTTP endpoint.
UserAPIPrefix = "users"
@@ -77,7 +76,7 @@ func (c *Client) UserCreate(opts types.UserCreateOptions) error {
}
// UserUpdate updates a user on the server.
func (c *Client) UserUpdate(user *types.User, ctx context.Context) error {
func (c *Client) UserUpdate(ctx context.Context, user *types.User) error {
var ref string
switch {
case user.UUID != "":

View File

@@ -75,9 +75,6 @@ go_library(
"@io_bazel_rules_go//go/platform:freebsd": [
"//vendor/github.com/vishvananda/netns:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//vendor/github.com/vishvananda/netns:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//vendor/github.com/vishvananda/netns:go_default_library",
],