diff --git a/cmd/resource-topology-exporter/main.go b/cmd/resource-topology-exporter/main.go index 593860e5d..fd6a0ca0b 100644 --- a/cmd/resource-topology-exporter/main.go +++ b/cmd/resource-topology-exporter/main.go @@ -57,10 +57,11 @@ func main() { klog.Fatalf("failed to get k8s client: %w", err) } - cli, err := podres.GetClient(parsedArgs.RTE.PodResourcesSocketPath) + cli, cleanup, err := podres.WaitForReady(podres.GetClient(parsedArgs.RTE.PodResourcesSocketPath)) if err != nil { klog.Fatalf("failed to get podresources client: %v", err) } + defer cleanup() cli = sharedcpuspool.NewFromLister(cli, parsedArgs.RTE.Debug, parsedArgs.RTE.ReferenceContainer) diff --git a/go.mod b/go.mod index 5a18e827a..cb266194a 100644 --- a/go.mod +++ b/go.mod @@ -23,13 +23,11 @@ require ( k8s.io/client-go v0.27.2 k8s.io/klog/v2 v2.90.1 k8s.io/kubelet v0.26.4 - k8s.io/kubernetes v1.26.4 sigs.k8s.io/controller-runtime v0.15.0 sigs.k8s.io/yaml v1.3.0 ) require ( - github.com/Microsoft/go-winio v0.4.17 // indirect github.com/OneOfOne/xxhash v1.2.9-0.20201014161131-8506fca4db5e // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect @@ -92,7 +90,6 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.0 // indirect - k8s.io/apiserver v0.26.4 // indirect k8s.io/component-base v0.27.2 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect diff --git a/go.sum b/go.sum index fb3bac91c..bac02b929 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Microsoft/go-winio v0.4.17 h1:iT12IBVClFevaf8PuVyi3UmZOVh4OqnaLxDTW2O6j3w= -github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.9-0.20201014161131-8506fca4db5e h1:Md6Mtmn7W2mppR3YHYqWe4/R/swzJK0WR/x1U+s+n7I= github.com/OneOfOne/xxhash v1.2.9-0.20201014161131-8506fca4db5e/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= @@ -124,7 +122,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -289,7 +286,6 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= @@ -307,7 +303,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -447,7 +442,6 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -467,7 +461,6 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -665,8 +658,6 @@ k8s.io/apiextensions-apiserver v0.26.4 h1:9D2RTxYGxrG5uYg6D7QZRcykXvavBvcA59j5kT k8s.io/apiextensions-apiserver v0.26.4/go.mod h1:cd4uGFGIgzEqUghWpRsr9KE8j2KNTjY8Ji8pnMMazyw= k8s.io/apimachinery v0.26.4 h1:rZccKdBLg9vP6J09JD+z8Yr99Ce8gk3Lbi9TCx05Jzs= k8s.io/apimachinery v0.26.4/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= -k8s.io/apiserver v0.26.4 h1:3Oq4mnJv0mzVX7BR/Nod+8KjlELf/3Ljvu9ZWDyLUoA= -k8s.io/apiserver v0.26.4/go.mod h1:yAY3O1vBM4/0OIGAGeWcdfzQvgdwJ188VirLcuSAVnw= k8s.io/client-go v0.26.4 h1:/7P/IbGBuT73A+G97trf44NTPSNqvuBREpOfdLbHvD4= k8s.io/client-go v0.26.4/go.mod h1:6qOItWm3EwxJdl/8p5t7FWtWUOwyMdA8N9ekbW4idpI= k8s.io/code-generator v0.26.4/go.mod h1:ryaiIKwfxEJEaywEzx3dhWOydpVctKYbqLajJf0O8dI= @@ -684,8 +675,6 @@ k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5F k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= k8s.io/kubelet v0.26.4 h1:SEQPfjN4lu4uL9O8NdeN7Aum3liQ4kOnp/yC3jMRMUo= k8s.io/kubelet v0.26.4/go.mod h1:ZMPGTCnrQ5UOlC7igXhbW9cgna1LtTRWLaHub4dA2FU= -k8s.io/kubernetes v1.26.4 h1:/c00/JjOltBwhNOBs+hO433Q3fRyeWWtyYF6z2xtmag= -k8s.io/kubernetes v1.26.4/go.mod h1:NxzR7U7mS+OGa3J/qweI86Pek//mlfHqDgt6NNGdz8g= k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= diff --git a/pkg/podres/client.go b/pkg/podres/client.go index 583a75711..5132a1741 100644 --- a/pkg/podres/client.go +++ b/pkg/podres/client.go @@ -1,25 +1,114 @@ +/* + * Copyright 2018 The Kubernetes Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package podres import ( + "context" "fmt" + "net" + "net/url" "time" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "k8s.io/klog/v2" podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1" - "k8s.io/kubernetes/pkg/kubelet/apis/podresources" ) const ( - // obtained the following values from node e2e tests : https://github.com/kubernetes/kubernetes/blob/82baa26905c94398a0d19e1b1ecf54eb8acb6029/test/e2e_node/util.go#L70 - defaultPodResourcesTimeout = 10 * time.Second - defaultPodResourcesMaxSize = 1024 * 1024 * 16 // 16 Mb + DefaultTimeout = 10 * time.Second + DefaultMaxMsgSize = 1024 * 1024 * 16 // 16 MiB + + UnixProtocol = "unix" ) -func GetClient(socketPath string) (podresourcesapi.PodResourcesListerClient, error) { - cli, _, err := podresources.GetV1Client(socketPath, defaultPodResourcesTimeout, defaultPodResourcesMaxSize) +type CleanupFunc func() error + +func GetClient(endpoint string) (podresourcesapi.PodResourcesListerClient, CleanupFunc, error) { + klog.Infof("creating a podresources client for endpoint %q", endpoint) + cli, cleanup, err := GetV1Client(endpoint, DefaultTimeout, DefaultMaxMsgSize) + if err != nil { + return nil, cleanup, fmt.Errorf("failed to create podresource client: %w", err) + } + klog.Infof("created a podresources client for endpoint %q", endpoint) + return cli, cleanup, nil +} + +func WaitForReady(cli podresourcesapi.PodResourcesListerClient, cleanup CleanupFunc, err error) (podresourcesapi.PodResourcesListerClient, CleanupFunc, error) { if err != nil { - return nil, fmt.Errorf("failed to create podresource client: %w", err) + return cli, cleanup, err } - klog.Infof("Connected to '%q'!", socketPath) - return cli, nil + // we use List because it's the oldest endpoint and the one guaranteed to be available. + // TODO: evaluate more lightweight option like GetAllocatableResources - we will discard + // the return value anyway. + _, listErr := cli.List(context.Background(), &podresourcesapi.ListPodResourcesRequest{}, grpc.WaitForReady(true)) + if listErr != nil { + return cli, cleanup, fmt.Errorf("WaitForReady failed: %w", listErr) + } + return cli, cleanup, nil +} + +func GetV1Client(endpoint string, connectionTimeout time.Duration, maxMsgSize int) (podresourcesapi.PodResourcesListerClient, CleanupFunc, error) { + path, err := ParseEndpoint(endpoint) + if err != nil { + return nil, nullCleanup, err + } + + ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout) + defer cancel() + + conn, err := grpc.DialContext(ctx, path, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithContextDialer(dialer), + grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)), + ) + if err != nil { + return nil, nullCleanup, fmt.Errorf("error dialing endpoint %q: %w", endpoint, err) + } + + cleanup := func() error { return conn.Close() } + return podresourcesapi.NewPodResourcesListerClient(conn), cleanup, nil +} + +type UnsupportedProtocolError struct { + proto string +} + +func (e UnsupportedProtocolError) Error() string { + return fmt.Sprintf("protocol %q not supported", e.proto) +} + +func ParseEndpoint(endpoint string) (string, error) { + u, err := url.Parse(endpoint) + if err != nil { + return "", err + } + if u.Scheme != UnixProtocol { + return "", UnsupportedProtocolError{proto: u.Scheme} + } + klog.Infof("endpoint %q -> protocol=%q path=%q", endpoint, u.Scheme, u.Path) + return u.Path, nil +} + +func dialer(ctx context.Context, addr string) (net.Conn, error) { + return (&net.Dialer{}).DialContext(ctx, UnixProtocol, addr) +} + +func nullCleanup() error { + return nil } diff --git a/pkg/podres/client_test.go b/pkg/podres/client_test.go new file mode 100644 index 000000000..2b580c7b4 --- /dev/null +++ b/pkg/podres/client_test.go @@ -0,0 +1,64 @@ +/* + * Copyright 2023 The Kubernetes Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package podres + +import ( + "errors" + "testing" +) + +func TestParseEndpoint(t *testing.T) { + type testCase struct { + name string + endpoint string + expectedPath string + expectedError error + } + + testCases := []testCase{ + { + name: "empty", + expectedError: UnsupportedProtocolError{}, + }, + { + name: "bad proto", + endpoint: "foobar:///path", + expectedError: UnsupportedProtocolError{proto: "foobar"}, + }, + { + name: "good proto", + endpoint: "unix://", + }, + { + name: "good proto, path given", + endpoint: "unix:///my/path", + expectedPath: "/my/path", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + got, err := ParseEndpoint(tc.endpoint) + if !errors.Is(err, tc.expectedError) { + t.Fatalf("ParseEndpoint failed err=%v expected=%v", err, tc.expectedError) + } + if got != tc.expectedPath { + t.Fatalf("ParseEndpoint failed path=%q expected=%q", got, tc.expectedPath) + } + }) + } +} diff --git a/vendor/github.com/Microsoft/go-winio/.gitignore b/vendor/github.com/Microsoft/go-winio/.gitignore deleted file mode 100644 index b883f1fdc..000000000 --- a/vendor/github.com/Microsoft/go-winio/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.exe diff --git a/vendor/github.com/Microsoft/go-winio/CODEOWNERS b/vendor/github.com/Microsoft/go-winio/CODEOWNERS deleted file mode 100644 index ae1b4942b..000000000 --- a/vendor/github.com/Microsoft/go-winio/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ - * @microsoft/containerplat diff --git a/vendor/github.com/Microsoft/go-winio/LICENSE b/vendor/github.com/Microsoft/go-winio/LICENSE deleted file mode 100644 index b8b569d77..000000000 --- a/vendor/github.com/Microsoft/go-winio/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/vendor/github.com/Microsoft/go-winio/README.md b/vendor/github.com/Microsoft/go-winio/README.md deleted file mode 100644 index 568001057..000000000 --- a/vendor/github.com/Microsoft/go-winio/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# go-winio - -This repository contains utilities for efficiently performing Win32 IO operations in -Go. Currently, this is focused on accessing named pipes and other file handles, and -for using named pipes as a net transport. - -This code relies on IO completion ports to avoid blocking IO on system threads, allowing Go -to reuse the thread to schedule another goroutine. This limits support to Windows Vista and -newer operating systems. This is similar to the implementation of network sockets in Go's net -package. - -Please see the LICENSE file for licensing information. - -This project has adopted the [Microsoft Open Source Code of -Conduct](https://opensource.microsoft.com/codeofconduct/). For more information -see the [Code of Conduct -FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact -[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional -questions or comments. - -Thanks to natefinch for the inspiration for this library. See https://github.com/natefinch/npipe -for another named pipe implementation. diff --git a/vendor/github.com/Microsoft/go-winio/backup.go b/vendor/github.com/Microsoft/go-winio/backup.go deleted file mode 100644 index 2be34af43..000000000 --- a/vendor/github.com/Microsoft/go-winio/backup.go +++ /dev/null @@ -1,280 +0,0 @@ -// +build windows - -package winio - -import ( - "encoding/binary" - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "runtime" - "syscall" - "unicode/utf16" -) - -//sys backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) = BackupRead -//sys backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) = BackupWrite - -const ( - BackupData = uint32(iota + 1) - BackupEaData - BackupSecurity - BackupAlternateData - BackupLink - BackupPropertyData - BackupObjectId - BackupReparseData - BackupSparseBlock - BackupTxfsData -) - -const ( - StreamSparseAttributes = uint32(8) -) - -const ( - WRITE_DAC = 0x40000 - WRITE_OWNER = 0x80000 - ACCESS_SYSTEM_SECURITY = 0x1000000 -) - -// BackupHeader represents a backup stream of a file. -type BackupHeader struct { - Id uint32 // The backup stream ID - Attributes uint32 // Stream attributes - Size int64 // The size of the stream in bytes - Name string // The name of the stream (for BackupAlternateData only). - Offset int64 // The offset of the stream in the file (for BackupSparseBlock only). -} - -type win32StreamId struct { - StreamId uint32 - Attributes uint32 - Size uint64 - NameSize uint32 -} - -// BackupStreamReader reads from a stream produced by the BackupRead Win32 API and produces a series -// of BackupHeader values. -type BackupStreamReader struct { - r io.Reader - bytesLeft int64 -} - -// NewBackupStreamReader produces a BackupStreamReader from any io.Reader. -func NewBackupStreamReader(r io.Reader) *BackupStreamReader { - return &BackupStreamReader{r, 0} -} - -// Next returns the next backup stream and prepares for calls to Read(). It skips the remainder of the current stream if -// it was not completely read. -func (r *BackupStreamReader) Next() (*BackupHeader, error) { - if r.bytesLeft > 0 { - if s, ok := r.r.(io.Seeker); ok { - // Make sure Seek on io.SeekCurrent sometimes succeeds - // before trying the actual seek. - if _, err := s.Seek(0, io.SeekCurrent); err == nil { - if _, err = s.Seek(r.bytesLeft, io.SeekCurrent); err != nil { - return nil, err - } - r.bytesLeft = 0 - } - } - if _, err := io.Copy(ioutil.Discard, r); err != nil { - return nil, err - } - } - var wsi win32StreamId - if err := binary.Read(r.r, binary.LittleEndian, &wsi); err != nil { - return nil, err - } - hdr := &BackupHeader{ - Id: wsi.StreamId, - Attributes: wsi.Attributes, - Size: int64(wsi.Size), - } - if wsi.NameSize != 0 { - name := make([]uint16, int(wsi.NameSize/2)) - if err := binary.Read(r.r, binary.LittleEndian, name); err != nil { - return nil, err - } - hdr.Name = syscall.UTF16ToString(name) - } - if wsi.StreamId == BackupSparseBlock { - if err := binary.Read(r.r, binary.LittleEndian, &hdr.Offset); err != nil { - return nil, err - } - hdr.Size -= 8 - } - r.bytesLeft = hdr.Size - return hdr, nil -} - -// Read reads from the current backup stream. -func (r *BackupStreamReader) Read(b []byte) (int, error) { - if r.bytesLeft == 0 { - return 0, io.EOF - } - if int64(len(b)) > r.bytesLeft { - b = b[:r.bytesLeft] - } - n, err := r.r.Read(b) - r.bytesLeft -= int64(n) - if err == io.EOF { - err = io.ErrUnexpectedEOF - } else if r.bytesLeft == 0 && err == nil { - err = io.EOF - } - return n, err -} - -// BackupStreamWriter writes a stream compatible with the BackupWrite Win32 API. -type BackupStreamWriter struct { - w io.Writer - bytesLeft int64 -} - -// NewBackupStreamWriter produces a BackupStreamWriter on top of an io.Writer. -func NewBackupStreamWriter(w io.Writer) *BackupStreamWriter { - return &BackupStreamWriter{w, 0} -} - -// WriteHeader writes the next backup stream header and prepares for calls to Write(). -func (w *BackupStreamWriter) WriteHeader(hdr *BackupHeader) error { - if w.bytesLeft != 0 { - return fmt.Errorf("missing %d bytes", w.bytesLeft) - } - name := utf16.Encode([]rune(hdr.Name)) - wsi := win32StreamId{ - StreamId: hdr.Id, - Attributes: hdr.Attributes, - Size: uint64(hdr.Size), - NameSize: uint32(len(name) * 2), - } - if hdr.Id == BackupSparseBlock { - // Include space for the int64 block offset - wsi.Size += 8 - } - if err := binary.Write(w.w, binary.LittleEndian, &wsi); err != nil { - return err - } - if len(name) != 0 { - if err := binary.Write(w.w, binary.LittleEndian, name); err != nil { - return err - } - } - if hdr.Id == BackupSparseBlock { - if err := binary.Write(w.w, binary.LittleEndian, hdr.Offset); err != nil { - return err - } - } - w.bytesLeft = hdr.Size - return nil -} - -// Write writes to the current backup stream. -func (w *BackupStreamWriter) Write(b []byte) (int, error) { - if w.bytesLeft < int64(len(b)) { - return 0, fmt.Errorf("too many bytes by %d", int64(len(b))-w.bytesLeft) - } - n, err := w.w.Write(b) - w.bytesLeft -= int64(n) - return n, err -} - -// BackupFileReader provides an io.ReadCloser interface on top of the BackupRead Win32 API. -type BackupFileReader struct { - f *os.File - includeSecurity bool - ctx uintptr -} - -// NewBackupFileReader returns a new BackupFileReader from a file handle. If includeSecurity is true, -// Read will attempt to read the security descriptor of the file. -func NewBackupFileReader(f *os.File, includeSecurity bool) *BackupFileReader { - r := &BackupFileReader{f, includeSecurity, 0} - return r -} - -// Read reads a backup stream from the file by calling the Win32 API BackupRead(). -func (r *BackupFileReader) Read(b []byte) (int, error) { - var bytesRead uint32 - err := backupRead(syscall.Handle(r.f.Fd()), b, &bytesRead, false, r.includeSecurity, &r.ctx) - if err != nil { - return 0, &os.PathError{"BackupRead", r.f.Name(), err} - } - runtime.KeepAlive(r.f) - if bytesRead == 0 { - return 0, io.EOF - } - return int(bytesRead), nil -} - -// Close frees Win32 resources associated with the BackupFileReader. It does not close -// the underlying file. -func (r *BackupFileReader) Close() error { - if r.ctx != 0 { - backupRead(syscall.Handle(r.f.Fd()), nil, nil, true, false, &r.ctx) - runtime.KeepAlive(r.f) - r.ctx = 0 - } - return nil -} - -// BackupFileWriter provides an io.WriteCloser interface on top of the BackupWrite Win32 API. -type BackupFileWriter struct { - f *os.File - includeSecurity bool - ctx uintptr -} - -// NewBackupFileWriter returns a new BackupFileWriter from a file handle. If includeSecurity is true, -// Write() will attempt to restore the security descriptor from the stream. -func NewBackupFileWriter(f *os.File, includeSecurity bool) *BackupFileWriter { - w := &BackupFileWriter{f, includeSecurity, 0} - return w -} - -// Write restores a portion of the file using the provided backup stream. -func (w *BackupFileWriter) Write(b []byte) (int, error) { - var bytesWritten uint32 - err := backupWrite(syscall.Handle(w.f.Fd()), b, &bytesWritten, false, w.includeSecurity, &w.ctx) - if err != nil { - return 0, &os.PathError{"BackupWrite", w.f.Name(), err} - } - runtime.KeepAlive(w.f) - if int(bytesWritten) != len(b) { - return int(bytesWritten), errors.New("not all bytes could be written") - } - return len(b), nil -} - -// Close frees Win32 resources associated with the BackupFileWriter. It does not -// close the underlying file. -func (w *BackupFileWriter) Close() error { - if w.ctx != 0 { - backupWrite(syscall.Handle(w.f.Fd()), nil, nil, true, false, &w.ctx) - runtime.KeepAlive(w.f) - w.ctx = 0 - } - return nil -} - -// OpenForBackup opens a file or directory, potentially skipping access checks if the backup -// or restore privileges have been acquired. -// -// If the file opened was a directory, it cannot be used with Readdir(). -func OpenForBackup(path string, access uint32, share uint32, createmode uint32) (*os.File, error) { - winPath, err := syscall.UTF16FromString(path) - if err != nil { - return nil, err - } - h, err := syscall.CreateFile(&winPath[0], access, share, nil, createmode, syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OPEN_REPARSE_POINT, 0) - if err != nil { - err = &os.PathError{Op: "open", Path: path, Err: err} - return nil, err - } - return os.NewFile(uintptr(h), path), nil -} diff --git a/vendor/github.com/Microsoft/go-winio/ea.go b/vendor/github.com/Microsoft/go-winio/ea.go deleted file mode 100644 index 4051c1b33..000000000 --- a/vendor/github.com/Microsoft/go-winio/ea.go +++ /dev/null @@ -1,137 +0,0 @@ -package winio - -import ( - "bytes" - "encoding/binary" - "errors" -) - -type fileFullEaInformation struct { - NextEntryOffset uint32 - Flags uint8 - NameLength uint8 - ValueLength uint16 -} - -var ( - fileFullEaInformationSize = binary.Size(&fileFullEaInformation{}) - - errInvalidEaBuffer = errors.New("invalid extended attribute buffer") - errEaNameTooLarge = errors.New("extended attribute name too large") - errEaValueTooLarge = errors.New("extended attribute value too large") -) - -// ExtendedAttribute represents a single Windows EA. -type ExtendedAttribute struct { - Name string - Value []byte - Flags uint8 -} - -func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) { - var info fileFullEaInformation - err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info) - if err != nil { - err = errInvalidEaBuffer - return - } - - nameOffset := fileFullEaInformationSize - nameLen := int(info.NameLength) - valueOffset := nameOffset + int(info.NameLength) + 1 - valueLen := int(info.ValueLength) - nextOffset := int(info.NextEntryOffset) - if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) { - err = errInvalidEaBuffer - return - } - - ea.Name = string(b[nameOffset : nameOffset+nameLen]) - ea.Value = b[valueOffset : valueOffset+valueLen] - ea.Flags = info.Flags - if info.NextEntryOffset != 0 { - nb = b[info.NextEntryOffset:] - } - return -} - -// DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION -// buffer retrieved from BackupRead, ZwQueryEaFile, etc. -func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) { - for len(b) != 0 { - ea, nb, err := parseEa(b) - if err != nil { - return nil, err - } - - eas = append(eas, ea) - b = nb - } - return -} - -func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error { - if int(uint8(len(ea.Name))) != len(ea.Name) { - return errEaNameTooLarge - } - if int(uint16(len(ea.Value))) != len(ea.Value) { - return errEaValueTooLarge - } - entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value)) - withPadding := (entrySize + 3) &^ 3 - nextOffset := uint32(0) - if !last { - nextOffset = withPadding - } - info := fileFullEaInformation{ - NextEntryOffset: nextOffset, - Flags: ea.Flags, - NameLength: uint8(len(ea.Name)), - ValueLength: uint16(len(ea.Value)), - } - - err := binary.Write(buf, binary.LittleEndian, &info) - if err != nil { - return err - } - - _, err = buf.Write([]byte(ea.Name)) - if err != nil { - return err - } - - err = buf.WriteByte(0) - if err != nil { - return err - } - - _, err = buf.Write(ea.Value) - if err != nil { - return err - } - - _, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize]) - if err != nil { - return err - } - - return nil -} - -// EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION -// buffer for use with BackupWrite, ZwSetEaFile, etc. -func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) { - var buf bytes.Buffer - for i := range eas { - last := false - if i == len(eas)-1 { - last = true - } - - err := writeEa(&buf, &eas[i], last) - if err != nil { - return nil, err - } - } - return buf.Bytes(), nil -} diff --git a/vendor/github.com/Microsoft/go-winio/file.go b/vendor/github.com/Microsoft/go-winio/file.go deleted file mode 100644 index 0385e4108..000000000 --- a/vendor/github.com/Microsoft/go-winio/file.go +++ /dev/null @@ -1,323 +0,0 @@ -// +build windows - -package winio - -import ( - "errors" - "io" - "runtime" - "sync" - "sync/atomic" - "syscall" - "time" -) - -//sys cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) = CancelIoEx -//sys createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) = CreateIoCompletionPort -//sys getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) = GetQueuedCompletionStatus -//sys setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) = SetFileCompletionNotificationModes -//sys wsaGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) = ws2_32.WSAGetOverlappedResult - -type atomicBool int32 - -func (b *atomicBool) isSet() bool { return atomic.LoadInt32((*int32)(b)) != 0 } -func (b *atomicBool) setFalse() { atomic.StoreInt32((*int32)(b), 0) } -func (b *atomicBool) setTrue() { atomic.StoreInt32((*int32)(b), 1) } -func (b *atomicBool) swap(new bool) bool { - var newInt int32 - if new { - newInt = 1 - } - return atomic.SwapInt32((*int32)(b), newInt) == 1 -} - -const ( - cFILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1 - cFILE_SKIP_SET_EVENT_ON_HANDLE = 2 -) - -var ( - ErrFileClosed = errors.New("file has already been closed") - ErrTimeout = &timeoutError{} -) - -type timeoutError struct{} - -func (e *timeoutError) Error() string { return "i/o timeout" } -func (e *timeoutError) Timeout() bool { return true } -func (e *timeoutError) Temporary() bool { return true } - -type timeoutChan chan struct{} - -var ioInitOnce sync.Once -var ioCompletionPort syscall.Handle - -// ioResult contains the result of an asynchronous IO operation -type ioResult struct { - bytes uint32 - err error -} - -// ioOperation represents an outstanding asynchronous Win32 IO -type ioOperation struct { - o syscall.Overlapped - ch chan ioResult -} - -func initIo() { - h, err := createIoCompletionPort(syscall.InvalidHandle, 0, 0, 0xffffffff) - if err != nil { - panic(err) - } - ioCompletionPort = h - go ioCompletionProcessor(h) -} - -// win32File implements Reader, Writer, and Closer on a Win32 handle without blocking in a syscall. -// It takes ownership of this handle and will close it if it is garbage collected. -type win32File struct { - handle syscall.Handle - wg sync.WaitGroup - wgLock sync.RWMutex - closing atomicBool - socket bool - readDeadline deadlineHandler - writeDeadline deadlineHandler -} - -type deadlineHandler struct { - setLock sync.Mutex - channel timeoutChan - channelLock sync.RWMutex - timer *time.Timer - timedout atomicBool -} - -// makeWin32File makes a new win32File from an existing file handle -func makeWin32File(h syscall.Handle) (*win32File, error) { - f := &win32File{handle: h} - ioInitOnce.Do(initIo) - _, err := createIoCompletionPort(h, ioCompletionPort, 0, 0xffffffff) - if err != nil { - return nil, err - } - err = setFileCompletionNotificationModes(h, cFILE_SKIP_COMPLETION_PORT_ON_SUCCESS|cFILE_SKIP_SET_EVENT_ON_HANDLE) - if err != nil { - return nil, err - } - f.readDeadline.channel = make(timeoutChan) - f.writeDeadline.channel = make(timeoutChan) - return f, nil -} - -func MakeOpenFile(h syscall.Handle) (io.ReadWriteCloser, error) { - // If we return the result of makeWin32File directly, it can result in an - // interface-wrapped nil, rather than a nil interface value. - f, err := makeWin32File(h) - if err != nil { - return nil, err - } - return f, nil -} - -// closeHandle closes the resources associated with a Win32 handle -func (f *win32File) closeHandle() { - f.wgLock.Lock() - // Atomically set that we are closing, releasing the resources only once. - if !f.closing.swap(true) { - f.wgLock.Unlock() - // cancel all IO and wait for it to complete - cancelIoEx(f.handle, nil) - f.wg.Wait() - // at this point, no new IO can start - syscall.Close(f.handle) - f.handle = 0 - } else { - f.wgLock.Unlock() - } -} - -// Close closes a win32File. -func (f *win32File) Close() error { - f.closeHandle() - return nil -} - -// prepareIo prepares for a new IO operation. -// The caller must call f.wg.Done() when the IO is finished, prior to Close() returning. -func (f *win32File) prepareIo() (*ioOperation, error) { - f.wgLock.RLock() - if f.closing.isSet() { - f.wgLock.RUnlock() - return nil, ErrFileClosed - } - f.wg.Add(1) - f.wgLock.RUnlock() - c := &ioOperation{} - c.ch = make(chan ioResult) - return c, nil -} - -// ioCompletionProcessor processes completed async IOs forever -func ioCompletionProcessor(h syscall.Handle) { - for { - var bytes uint32 - var key uintptr - var op *ioOperation - err := getQueuedCompletionStatus(h, &bytes, &key, &op, syscall.INFINITE) - if op == nil { - panic(err) - } - op.ch <- ioResult{bytes, err} - } -} - -// asyncIo processes the return value from ReadFile or WriteFile, blocking until -// the operation has actually completed. -func (f *win32File) asyncIo(c *ioOperation, d *deadlineHandler, bytes uint32, err error) (int, error) { - if err != syscall.ERROR_IO_PENDING { - return int(bytes), err - } - - if f.closing.isSet() { - cancelIoEx(f.handle, &c.o) - } - - var timeout timeoutChan - if d != nil { - d.channelLock.Lock() - timeout = d.channel - d.channelLock.Unlock() - } - - var r ioResult - select { - case r = <-c.ch: - err = r.err - if err == syscall.ERROR_OPERATION_ABORTED { - if f.closing.isSet() { - err = ErrFileClosed - } - } else if err != nil && f.socket { - // err is from Win32. Query the overlapped structure to get the winsock error. - var bytes, flags uint32 - err = wsaGetOverlappedResult(f.handle, &c.o, &bytes, false, &flags) - } - case <-timeout: - cancelIoEx(f.handle, &c.o) - r = <-c.ch - err = r.err - if err == syscall.ERROR_OPERATION_ABORTED { - err = ErrTimeout - } - } - - // runtime.KeepAlive is needed, as c is passed via native - // code to ioCompletionProcessor, c must remain alive - // until the channel read is complete. - runtime.KeepAlive(c) - return int(r.bytes), err -} - -// Read reads from a file handle. -func (f *win32File) Read(b []byte) (int, error) { - c, err := f.prepareIo() - if err != nil { - return 0, err - } - defer f.wg.Done() - - if f.readDeadline.timedout.isSet() { - return 0, ErrTimeout - } - - var bytes uint32 - err = syscall.ReadFile(f.handle, b, &bytes, &c.o) - n, err := f.asyncIo(c, &f.readDeadline, bytes, err) - runtime.KeepAlive(b) - - // Handle EOF conditions. - if err == nil && n == 0 && len(b) != 0 { - return 0, io.EOF - } else if err == syscall.ERROR_BROKEN_PIPE { - return 0, io.EOF - } else { - return n, err - } -} - -// Write writes to a file handle. -func (f *win32File) Write(b []byte) (int, error) { - c, err := f.prepareIo() - if err != nil { - return 0, err - } - defer f.wg.Done() - - if f.writeDeadline.timedout.isSet() { - return 0, ErrTimeout - } - - var bytes uint32 - err = syscall.WriteFile(f.handle, b, &bytes, &c.o) - n, err := f.asyncIo(c, &f.writeDeadline, bytes, err) - runtime.KeepAlive(b) - return n, err -} - -func (f *win32File) SetReadDeadline(deadline time.Time) error { - return f.readDeadline.set(deadline) -} - -func (f *win32File) SetWriteDeadline(deadline time.Time) error { - return f.writeDeadline.set(deadline) -} - -func (f *win32File) Flush() error { - return syscall.FlushFileBuffers(f.handle) -} - -func (f *win32File) Fd() uintptr { - return uintptr(f.handle) -} - -func (d *deadlineHandler) set(deadline time.Time) error { - d.setLock.Lock() - defer d.setLock.Unlock() - - if d.timer != nil { - if !d.timer.Stop() { - <-d.channel - } - d.timer = nil - } - d.timedout.setFalse() - - select { - case <-d.channel: - d.channelLock.Lock() - d.channel = make(chan struct{}) - d.channelLock.Unlock() - default: - } - - if deadline.IsZero() { - return nil - } - - timeoutIO := func() { - d.timedout.setTrue() - close(d.channel) - } - - now := time.Now() - duration := deadline.Sub(now) - if deadline.After(now) { - // Deadline is in the future, set a timer to wait - d.timer = time.AfterFunc(duration, timeoutIO) - } else { - // Deadline is in the past. Cancel all pending IO now. - timeoutIO() - } - return nil -} diff --git a/vendor/github.com/Microsoft/go-winio/fileinfo.go b/vendor/github.com/Microsoft/go-winio/fileinfo.go deleted file mode 100644 index 3ab6bff69..000000000 --- a/vendor/github.com/Microsoft/go-winio/fileinfo.go +++ /dev/null @@ -1,73 +0,0 @@ -// +build windows - -package winio - -import ( - "os" - "runtime" - "unsafe" - - "golang.org/x/sys/windows" -) - -// FileBasicInfo contains file access time and file attributes information. -type FileBasicInfo struct { - CreationTime, LastAccessTime, LastWriteTime, ChangeTime windows.Filetime - FileAttributes uint32 - pad uint32 // padding -} - -// GetFileBasicInfo retrieves times and attributes for a file. -func GetFileBasicInfo(f *os.File) (*FileBasicInfo, error) { - bi := &FileBasicInfo{} - if err := windows.GetFileInformationByHandleEx(windows.Handle(f.Fd()), windows.FileBasicInfo, (*byte)(unsafe.Pointer(bi)), uint32(unsafe.Sizeof(*bi))); err != nil { - return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err} - } - runtime.KeepAlive(f) - return bi, nil -} - -// SetFileBasicInfo sets times and attributes for a file. -func SetFileBasicInfo(f *os.File, bi *FileBasicInfo) error { - if err := windows.SetFileInformationByHandle(windows.Handle(f.Fd()), windows.FileBasicInfo, (*byte)(unsafe.Pointer(bi)), uint32(unsafe.Sizeof(*bi))); err != nil { - return &os.PathError{Op: "SetFileInformationByHandle", Path: f.Name(), Err: err} - } - runtime.KeepAlive(f) - return nil -} - -// FileStandardInfo contains extended information for the file. -// FILE_STANDARD_INFO in WinBase.h -// https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_standard_info -type FileStandardInfo struct { - AllocationSize, EndOfFile int64 - NumberOfLinks uint32 - DeletePending, Directory bool -} - -// GetFileStandardInfo retrieves ended information for the file. -func GetFileStandardInfo(f *os.File) (*FileStandardInfo, error) { - si := &FileStandardInfo{} - if err := windows.GetFileInformationByHandleEx(windows.Handle(f.Fd()), windows.FileStandardInfo, (*byte)(unsafe.Pointer(si)), uint32(unsafe.Sizeof(*si))); err != nil { - return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err} - } - runtime.KeepAlive(f) - return si, nil -} - -// FileIDInfo contains the volume serial number and file ID for a file. This pair should be -// unique on a system. -type FileIDInfo struct { - VolumeSerialNumber uint64 - FileID [16]byte -} - -// GetFileID retrieves the unique (volume, file ID) pair for a file. -func GetFileID(f *os.File) (*FileIDInfo, error) { - fileID := &FileIDInfo{} - if err := windows.GetFileInformationByHandleEx(windows.Handle(f.Fd()), windows.FileIdInfo, (*byte)(unsafe.Pointer(fileID)), uint32(unsafe.Sizeof(*fileID))); err != nil { - return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err} - } - runtime.KeepAlive(f) - return fileID, nil -} diff --git a/vendor/github.com/Microsoft/go-winio/hvsock.go b/vendor/github.com/Microsoft/go-winio/hvsock.go deleted file mode 100644 index b632f8f8b..000000000 --- a/vendor/github.com/Microsoft/go-winio/hvsock.go +++ /dev/null @@ -1,307 +0,0 @@ -// +build windows - -package winio - -import ( - "fmt" - "io" - "net" - "os" - "syscall" - "time" - "unsafe" - - "github.com/Microsoft/go-winio/pkg/guid" -) - -//sys bind(s syscall.Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socketError] = ws2_32.bind - -const ( - afHvSock = 34 // AF_HYPERV - - socketError = ^uintptr(0) -) - -// An HvsockAddr is an address for a AF_HYPERV socket. -type HvsockAddr struct { - VMID guid.GUID - ServiceID guid.GUID -} - -type rawHvsockAddr struct { - Family uint16 - _ uint16 - VMID guid.GUID - ServiceID guid.GUID -} - -// Network returns the address's network name, "hvsock". -func (addr *HvsockAddr) Network() string { - return "hvsock" -} - -func (addr *HvsockAddr) String() string { - return fmt.Sprintf("%s:%s", &addr.VMID, &addr.ServiceID) -} - -// VsockServiceID returns an hvsock service ID corresponding to the specified AF_VSOCK port. -func VsockServiceID(port uint32) guid.GUID { - g, _ := guid.FromString("00000000-facb-11e6-bd58-64006a7986d3") - g.Data1 = port - return g -} - -func (addr *HvsockAddr) raw() rawHvsockAddr { - return rawHvsockAddr{ - Family: afHvSock, - VMID: addr.VMID, - ServiceID: addr.ServiceID, - } -} - -func (addr *HvsockAddr) fromRaw(raw *rawHvsockAddr) { - addr.VMID = raw.VMID - addr.ServiceID = raw.ServiceID -} - -// HvsockListener is a socket listener for the AF_HYPERV address family. -type HvsockListener struct { - sock *win32File - addr HvsockAddr -} - -// HvsockConn is a connected socket of the AF_HYPERV address family. -type HvsockConn struct { - sock *win32File - local, remote HvsockAddr -} - -func newHvSocket() (*win32File, error) { - fd, err := syscall.Socket(afHvSock, syscall.SOCK_STREAM, 1) - if err != nil { - return nil, os.NewSyscallError("socket", err) - } - f, err := makeWin32File(fd) - if err != nil { - syscall.Close(fd) - return nil, err - } - f.socket = true - return f, nil -} - -// ListenHvsock listens for connections on the specified hvsock address. -func ListenHvsock(addr *HvsockAddr) (_ *HvsockListener, err error) { - l := &HvsockListener{addr: *addr} - sock, err := newHvSocket() - if err != nil { - return nil, l.opErr("listen", err) - } - sa := addr.raw() - err = bind(sock.handle, unsafe.Pointer(&sa), int32(unsafe.Sizeof(sa))) - if err != nil { - return nil, l.opErr("listen", os.NewSyscallError("socket", err)) - } - err = syscall.Listen(sock.handle, 16) - if err != nil { - return nil, l.opErr("listen", os.NewSyscallError("listen", err)) - } - return &HvsockListener{sock: sock, addr: *addr}, nil -} - -func (l *HvsockListener) opErr(op string, err error) error { - return &net.OpError{Op: op, Net: "hvsock", Addr: &l.addr, Err: err} -} - -// Addr returns the listener's network address. -func (l *HvsockListener) Addr() net.Addr { - return &l.addr -} - -// Accept waits for the next connection and returns it. -func (l *HvsockListener) Accept() (_ net.Conn, err error) { - sock, err := newHvSocket() - if err != nil { - return nil, l.opErr("accept", err) - } - defer func() { - if sock != nil { - sock.Close() - } - }() - c, err := l.sock.prepareIo() - if err != nil { - return nil, l.opErr("accept", err) - } - defer l.sock.wg.Done() - - // AcceptEx, per documentation, requires an extra 16 bytes per address. - const addrlen = uint32(16 + unsafe.Sizeof(rawHvsockAddr{})) - var addrbuf [addrlen * 2]byte - - var bytes uint32 - err = syscall.AcceptEx(l.sock.handle, sock.handle, &addrbuf[0], 0, addrlen, addrlen, &bytes, &c.o) - _, err = l.sock.asyncIo(c, nil, bytes, err) - if err != nil { - return nil, l.opErr("accept", os.NewSyscallError("acceptex", err)) - } - conn := &HvsockConn{ - sock: sock, - } - conn.local.fromRaw((*rawHvsockAddr)(unsafe.Pointer(&addrbuf[0]))) - conn.remote.fromRaw((*rawHvsockAddr)(unsafe.Pointer(&addrbuf[addrlen]))) - sock = nil - return conn, nil -} - -// Close closes the listener, causing any pending Accept calls to fail. -func (l *HvsockListener) Close() error { - return l.sock.Close() -} - -/* Need to finish ConnectEx handling -func DialHvsock(ctx context.Context, addr *HvsockAddr) (*HvsockConn, error) { - sock, err := newHvSocket() - if err != nil { - return nil, err - } - defer func() { - if sock != nil { - sock.Close() - } - }() - c, err := sock.prepareIo() - if err != nil { - return nil, err - } - defer sock.wg.Done() - var bytes uint32 - err = windows.ConnectEx(windows.Handle(sock.handle), sa, nil, 0, &bytes, &c.o) - _, err = sock.asyncIo(ctx, c, nil, bytes, err) - if err != nil { - return nil, err - } - conn := &HvsockConn{ - sock: sock, - remote: *addr, - } - sock = nil - return conn, nil -} -*/ - -func (conn *HvsockConn) opErr(op string, err error) error { - return &net.OpError{Op: op, Net: "hvsock", Source: &conn.local, Addr: &conn.remote, Err: err} -} - -func (conn *HvsockConn) Read(b []byte) (int, error) { - c, err := conn.sock.prepareIo() - if err != nil { - return 0, conn.opErr("read", err) - } - defer conn.sock.wg.Done() - buf := syscall.WSABuf{Buf: &b[0], Len: uint32(len(b))} - var flags, bytes uint32 - err = syscall.WSARecv(conn.sock.handle, &buf, 1, &bytes, &flags, &c.o, nil) - n, err := conn.sock.asyncIo(c, &conn.sock.readDeadline, bytes, err) - if err != nil { - if _, ok := err.(syscall.Errno); ok { - err = os.NewSyscallError("wsarecv", err) - } - return 0, conn.opErr("read", err) - } else if n == 0 { - err = io.EOF - } - return n, err -} - -func (conn *HvsockConn) Write(b []byte) (int, error) { - t := 0 - for len(b) != 0 { - n, err := conn.write(b) - if err != nil { - return t + n, err - } - t += n - b = b[n:] - } - return t, nil -} - -func (conn *HvsockConn) write(b []byte) (int, error) { - c, err := conn.sock.prepareIo() - if err != nil { - return 0, conn.opErr("write", err) - } - defer conn.sock.wg.Done() - buf := syscall.WSABuf{Buf: &b[0], Len: uint32(len(b))} - var bytes uint32 - err = syscall.WSASend(conn.sock.handle, &buf, 1, &bytes, 0, &c.o, nil) - n, err := conn.sock.asyncIo(c, &conn.sock.writeDeadline, bytes, err) - if err != nil { - if _, ok := err.(syscall.Errno); ok { - err = os.NewSyscallError("wsasend", err) - } - return 0, conn.opErr("write", err) - } - return n, err -} - -// Close closes the socket connection, failing any pending read or write calls. -func (conn *HvsockConn) Close() error { - return conn.sock.Close() -} - -func (conn *HvsockConn) shutdown(how int) error { - err := syscall.Shutdown(conn.sock.handle, syscall.SHUT_RD) - if err != nil { - return os.NewSyscallError("shutdown", err) - } - return nil -} - -// CloseRead shuts down the read end of the socket. -func (conn *HvsockConn) CloseRead() error { - err := conn.shutdown(syscall.SHUT_RD) - if err != nil { - return conn.opErr("close", err) - } - return nil -} - -// CloseWrite shuts down the write end of the socket, notifying the other endpoint that -// no more data will be written. -func (conn *HvsockConn) CloseWrite() error { - err := conn.shutdown(syscall.SHUT_WR) - if err != nil { - return conn.opErr("close", err) - } - return nil -} - -// LocalAddr returns the local address of the connection. -func (conn *HvsockConn) LocalAddr() net.Addr { - return &conn.local -} - -// RemoteAddr returns the remote address of the connection. -func (conn *HvsockConn) RemoteAddr() net.Addr { - return &conn.remote -} - -// SetDeadline implements the net.Conn SetDeadline method. -func (conn *HvsockConn) SetDeadline(t time.Time) error { - conn.SetReadDeadline(t) - conn.SetWriteDeadline(t) - return nil -} - -// SetReadDeadline implements the net.Conn SetReadDeadline method. -func (conn *HvsockConn) SetReadDeadline(t time.Time) error { - return conn.sock.SetReadDeadline(t) -} - -// SetWriteDeadline implements the net.Conn SetWriteDeadline method. -func (conn *HvsockConn) SetWriteDeadline(t time.Time) error { - return conn.sock.SetWriteDeadline(t) -} diff --git a/vendor/github.com/Microsoft/go-winio/pipe.go b/vendor/github.com/Microsoft/go-winio/pipe.go deleted file mode 100644 index 96700a73d..000000000 --- a/vendor/github.com/Microsoft/go-winio/pipe.go +++ /dev/null @@ -1,517 +0,0 @@ -// +build windows - -package winio - -import ( - "context" - "errors" - "fmt" - "io" - "net" - "os" - "runtime" - "syscall" - "time" - "unsafe" -) - -//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe -//sys createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateNamedPipeW -//sys createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateFileW -//sys getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) = GetNamedPipeInfo -//sys getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW -//sys localAlloc(uFlags uint32, length uint32) (ptr uintptr) = LocalAlloc -//sys ntCreateNamedPipeFile(pipe *syscall.Handle, access uint32, oa *objectAttributes, iosb *ioStatusBlock, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (status ntstatus) = ntdll.NtCreateNamedPipeFile -//sys rtlNtStatusToDosError(status ntstatus) (winerr error) = ntdll.RtlNtStatusToDosErrorNoTeb -//sys rtlDosPathNameToNtPathName(name *uint16, ntName *unicodeString, filePart uintptr, reserved uintptr) (status ntstatus) = ntdll.RtlDosPathNameToNtPathName_U -//sys rtlDefaultNpAcl(dacl *uintptr) (status ntstatus) = ntdll.RtlDefaultNpAcl - -type ioStatusBlock struct { - Status, Information uintptr -} - -type objectAttributes struct { - Length uintptr - RootDirectory uintptr - ObjectName *unicodeString - Attributes uintptr - SecurityDescriptor *securityDescriptor - SecurityQoS uintptr -} - -type unicodeString struct { - Length uint16 - MaximumLength uint16 - Buffer uintptr -} - -type securityDescriptor struct { - Revision byte - Sbz1 byte - Control uint16 - Owner uintptr - Group uintptr - Sacl uintptr - Dacl uintptr -} - -type ntstatus int32 - -func (status ntstatus) Err() error { - if status >= 0 { - return nil - } - return rtlNtStatusToDosError(status) -} - -const ( - cERROR_PIPE_BUSY = syscall.Errno(231) - cERROR_NO_DATA = syscall.Errno(232) - cERROR_PIPE_CONNECTED = syscall.Errno(535) - cERROR_SEM_TIMEOUT = syscall.Errno(121) - - cSECURITY_SQOS_PRESENT = 0x100000 - cSECURITY_ANONYMOUS = 0 - - cPIPE_TYPE_MESSAGE = 4 - - cPIPE_READMODE_MESSAGE = 2 - - cFILE_OPEN = 1 - cFILE_CREATE = 2 - - cFILE_PIPE_MESSAGE_TYPE = 1 - cFILE_PIPE_REJECT_REMOTE_CLIENTS = 2 - - cSE_DACL_PRESENT = 4 -) - -var ( - // ErrPipeListenerClosed is returned for pipe operations on listeners that have been closed. - // This error should match net.errClosing since docker takes a dependency on its text. - ErrPipeListenerClosed = errors.New("use of closed network connection") - - errPipeWriteClosed = errors.New("pipe has been closed for write") -) - -type win32Pipe struct { - *win32File - path string -} - -type win32MessageBytePipe struct { - win32Pipe - writeClosed bool - readEOF bool -} - -type pipeAddress string - -func (f *win32Pipe) LocalAddr() net.Addr { - return pipeAddress(f.path) -} - -func (f *win32Pipe) RemoteAddr() net.Addr { - return pipeAddress(f.path) -} - -func (f *win32Pipe) SetDeadline(t time.Time) error { - f.SetReadDeadline(t) - f.SetWriteDeadline(t) - return nil -} - -// CloseWrite closes the write side of a message pipe in byte mode. -func (f *win32MessageBytePipe) CloseWrite() error { - if f.writeClosed { - return errPipeWriteClosed - } - err := f.win32File.Flush() - if err != nil { - return err - } - _, err = f.win32File.Write(nil) - if err != nil { - return err - } - f.writeClosed = true - return nil -} - -// Write writes bytes to a message pipe in byte mode. Zero-byte writes are ignored, since -// they are used to implement CloseWrite(). -func (f *win32MessageBytePipe) Write(b []byte) (int, error) { - if f.writeClosed { - return 0, errPipeWriteClosed - } - if len(b) == 0 { - return 0, nil - } - return f.win32File.Write(b) -} - -// Read reads bytes from a message pipe in byte mode. A read of a zero-byte message on a message -// mode pipe will return io.EOF, as will all subsequent reads. -func (f *win32MessageBytePipe) Read(b []byte) (int, error) { - if f.readEOF { - return 0, io.EOF - } - n, err := f.win32File.Read(b) - if err == io.EOF { - // If this was the result of a zero-byte read, then - // it is possible that the read was due to a zero-size - // message. Since we are simulating CloseWrite with a - // zero-byte message, ensure that all future Read() calls - // also return EOF. - f.readEOF = true - } else if err == syscall.ERROR_MORE_DATA { - // ERROR_MORE_DATA indicates that the pipe's read mode is message mode - // and the message still has more bytes. Treat this as a success, since - // this package presents all named pipes as byte streams. - err = nil - } - return n, err -} - -func (s pipeAddress) Network() string { - return "pipe" -} - -func (s pipeAddress) String() string { - return string(s) -} - -// tryDialPipe attempts to dial the pipe at `path` until `ctx` cancellation or timeout. -func tryDialPipe(ctx context.Context, path *string, access uint32) (syscall.Handle, error) { - for { - - select { - case <-ctx.Done(): - return syscall.Handle(0), ctx.Err() - default: - h, err := createFile(*path, access, 0, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_OVERLAPPED|cSECURITY_SQOS_PRESENT|cSECURITY_ANONYMOUS, 0) - if err == nil { - return h, nil - } - if err != cERROR_PIPE_BUSY { - return h, &os.PathError{Err: err, Op: "open", Path: *path} - } - // Wait 10 msec and try again. This is a rather simplistic - // view, as we always try each 10 milliseconds. - time.Sleep(10 * time.Millisecond) - } - } -} - -// DialPipe connects to a named pipe by path, timing out if the connection -// takes longer than the specified duration. If timeout is nil, then we use -// a default timeout of 2 seconds. (We do not use WaitNamedPipe.) -func DialPipe(path string, timeout *time.Duration) (net.Conn, error) { - var absTimeout time.Time - if timeout != nil { - absTimeout = time.Now().Add(*timeout) - } else { - absTimeout = time.Now().Add(2 * time.Second) - } - ctx, _ := context.WithDeadline(context.Background(), absTimeout) - conn, err := DialPipeContext(ctx, path) - if err == context.DeadlineExceeded { - return nil, ErrTimeout - } - return conn, err -} - -// DialPipeContext attempts to connect to a named pipe by `path` until `ctx` -// cancellation or timeout. -func DialPipeContext(ctx context.Context, path string) (net.Conn, error) { - return DialPipeAccess(ctx, path, syscall.GENERIC_READ|syscall.GENERIC_WRITE) -} - -// DialPipeAccess attempts to connect to a named pipe by `path` with `access` until `ctx` -// cancellation or timeout. -func DialPipeAccess(ctx context.Context, path string, access uint32) (net.Conn, error) { - var err error - var h syscall.Handle - h, err = tryDialPipe(ctx, &path, access) - if err != nil { - return nil, err - } - - var flags uint32 - err = getNamedPipeInfo(h, &flags, nil, nil, nil) - if err != nil { - return nil, err - } - - f, err := makeWin32File(h) - if err != nil { - syscall.Close(h) - return nil, err - } - - // If the pipe is in message mode, return a message byte pipe, which - // supports CloseWrite(). - if flags&cPIPE_TYPE_MESSAGE != 0 { - return &win32MessageBytePipe{ - win32Pipe: win32Pipe{win32File: f, path: path}, - }, nil - } - return &win32Pipe{win32File: f, path: path}, nil -} - -type acceptResponse struct { - f *win32File - err error -} - -type win32PipeListener struct { - firstHandle syscall.Handle - path string - config PipeConfig - acceptCh chan (chan acceptResponse) - closeCh chan int - doneCh chan int -} - -func makeServerPipeHandle(path string, sd []byte, c *PipeConfig, first bool) (syscall.Handle, error) { - path16, err := syscall.UTF16FromString(path) - if err != nil { - return 0, &os.PathError{Op: "open", Path: path, Err: err} - } - - var oa objectAttributes - oa.Length = unsafe.Sizeof(oa) - - var ntPath unicodeString - if err := rtlDosPathNameToNtPathName(&path16[0], &ntPath, 0, 0).Err(); err != nil { - return 0, &os.PathError{Op: "open", Path: path, Err: err} - } - defer localFree(ntPath.Buffer) - oa.ObjectName = &ntPath - - // The security descriptor is only needed for the first pipe. - if first { - if sd != nil { - len := uint32(len(sd)) - sdb := localAlloc(0, len) - defer localFree(sdb) - copy((*[0xffff]byte)(unsafe.Pointer(sdb))[:], sd) - oa.SecurityDescriptor = (*securityDescriptor)(unsafe.Pointer(sdb)) - } else { - // Construct the default named pipe security descriptor. - var dacl uintptr - if err := rtlDefaultNpAcl(&dacl).Err(); err != nil { - return 0, fmt.Errorf("getting default named pipe ACL: %s", err) - } - defer localFree(dacl) - - sdb := &securityDescriptor{ - Revision: 1, - Control: cSE_DACL_PRESENT, - Dacl: dacl, - } - oa.SecurityDescriptor = sdb - } - } - - typ := uint32(cFILE_PIPE_REJECT_REMOTE_CLIENTS) - if c.MessageMode { - typ |= cFILE_PIPE_MESSAGE_TYPE - } - - disposition := uint32(cFILE_OPEN) - access := uint32(syscall.GENERIC_READ | syscall.GENERIC_WRITE | syscall.SYNCHRONIZE) - if first { - disposition = cFILE_CREATE - // By not asking for read or write access, the named pipe file system - // will put this pipe into an initially disconnected state, blocking - // client connections until the next call with first == false. - access = syscall.SYNCHRONIZE - } - - timeout := int64(-50 * 10000) // 50ms - - var ( - h syscall.Handle - iosb ioStatusBlock - ) - err = ntCreateNamedPipeFile(&h, access, &oa, &iosb, syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE, disposition, 0, typ, 0, 0, 0xffffffff, uint32(c.InputBufferSize), uint32(c.OutputBufferSize), &timeout).Err() - if err != nil { - return 0, &os.PathError{Op: "open", Path: path, Err: err} - } - - runtime.KeepAlive(ntPath) - return h, nil -} - -func (l *win32PipeListener) makeServerPipe() (*win32File, error) { - h, err := makeServerPipeHandle(l.path, nil, &l.config, false) - if err != nil { - return nil, err - } - f, err := makeWin32File(h) - if err != nil { - syscall.Close(h) - return nil, err - } - return f, nil -} - -func (l *win32PipeListener) makeConnectedServerPipe() (*win32File, error) { - p, err := l.makeServerPipe() - if err != nil { - return nil, err - } - - // Wait for the client to connect. - ch := make(chan error) - go func(p *win32File) { - ch <- connectPipe(p) - }(p) - - select { - case err = <-ch: - if err != nil { - p.Close() - p = nil - } - case <-l.closeCh: - // Abort the connect request by closing the handle. - p.Close() - p = nil - err = <-ch - if err == nil || err == ErrFileClosed { - err = ErrPipeListenerClosed - } - } - return p, err -} - -func (l *win32PipeListener) listenerRoutine() { - closed := false - for !closed { - select { - case <-l.closeCh: - closed = true - case responseCh := <-l.acceptCh: - var ( - p *win32File - err error - ) - for { - p, err = l.makeConnectedServerPipe() - // If the connection was immediately closed by the client, try - // again. - if err != cERROR_NO_DATA { - break - } - } - responseCh <- acceptResponse{p, err} - closed = err == ErrPipeListenerClosed - } - } - syscall.Close(l.firstHandle) - l.firstHandle = 0 - // Notify Close() and Accept() callers that the handle has been closed. - close(l.doneCh) -} - -// PipeConfig contain configuration for the pipe listener. -type PipeConfig struct { - // SecurityDescriptor contains a Windows security descriptor in SDDL format. - SecurityDescriptor string - - // MessageMode determines whether the pipe is in byte or message mode. In either - // case the pipe is read in byte mode by default. The only practical difference in - // this implementation is that CloseWrite() is only supported for message mode pipes; - // CloseWrite() is implemented as a zero-byte write, but zero-byte writes are only - // transferred to the reader (and returned as io.EOF in this implementation) - // when the pipe is in message mode. - MessageMode bool - - // InputBufferSize specifies the size of the input buffer, in bytes. - InputBufferSize int32 - - // OutputBufferSize specifies the size of the output buffer, in bytes. - OutputBufferSize int32 -} - -// ListenPipe creates a listener on a Windows named pipe path, e.g. \\.\pipe\mypipe. -// The pipe must not already exist. -func ListenPipe(path string, c *PipeConfig) (net.Listener, error) { - var ( - sd []byte - err error - ) - if c == nil { - c = &PipeConfig{} - } - if c.SecurityDescriptor != "" { - sd, err = SddlToSecurityDescriptor(c.SecurityDescriptor) - if err != nil { - return nil, err - } - } - h, err := makeServerPipeHandle(path, sd, c, true) - if err != nil { - return nil, err - } - l := &win32PipeListener{ - firstHandle: h, - path: path, - config: *c, - acceptCh: make(chan (chan acceptResponse)), - closeCh: make(chan int), - doneCh: make(chan int), - } - go l.listenerRoutine() - return l, nil -} - -func connectPipe(p *win32File) error { - c, err := p.prepareIo() - if err != nil { - return err - } - defer p.wg.Done() - - err = connectNamedPipe(p.handle, &c.o) - _, err = p.asyncIo(c, nil, 0, err) - if err != nil && err != cERROR_PIPE_CONNECTED { - return err - } - return nil -} - -func (l *win32PipeListener) Accept() (net.Conn, error) { - ch := make(chan acceptResponse) - select { - case l.acceptCh <- ch: - response := <-ch - err := response.err - if err != nil { - return nil, err - } - if l.config.MessageMode { - return &win32MessageBytePipe{ - win32Pipe: win32Pipe{win32File: response.f, path: l.path}, - }, nil - } - return &win32Pipe{win32File: response.f, path: l.path}, nil - case <-l.doneCh: - return nil, ErrPipeListenerClosed - } -} - -func (l *win32PipeListener) Close() error { - select { - case l.closeCh <- 1: - <-l.doneCh - case <-l.doneCh: - } - return nil -} - -func (l *win32PipeListener) Addr() net.Addr { - return pipeAddress(l.path) -} diff --git a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go b/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go deleted file mode 100644 index f497c0e39..000000000 --- a/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go +++ /dev/null @@ -1,237 +0,0 @@ -// +build windows - -// Package guid provides a GUID type. The backing structure for a GUID is -// identical to that used by the golang.org/x/sys/windows GUID type. -// There are two main binary encodings used for a GUID, the big-endian encoding, -// and the Windows (mixed-endian) encoding. See here for details: -// https://en.wikipedia.org/wiki/Universally_unique_identifier#Encoding -package guid - -import ( - "crypto/rand" - "crypto/sha1" - "encoding" - "encoding/binary" - "fmt" - "strconv" - - "golang.org/x/sys/windows" -) - -// Variant specifies which GUID variant (or "type") of the GUID. It determines -// how the entirety of the rest of the GUID is interpreted. -type Variant uint8 - -// The variants specified by RFC 4122. -const ( - // VariantUnknown specifies a GUID variant which does not conform to one of - // the variant encodings specified in RFC 4122. - VariantUnknown Variant = iota - VariantNCS - VariantRFC4122 - VariantMicrosoft - VariantFuture -) - -// Version specifies how the bits in the GUID were generated. For instance, a -// version 4 GUID is randomly generated, and a version 5 is generated from the -// hash of an input string. -type Version uint8 - -var _ = (encoding.TextMarshaler)(GUID{}) -var _ = (encoding.TextUnmarshaler)(&GUID{}) - -// GUID represents a GUID/UUID. It has the same structure as -// golang.org/x/sys/windows.GUID so that it can be used with functions expecting -// that type. It is defined as its own type so that stringification and -// marshaling can be supported. The representation matches that used by native -// Windows code. -type GUID windows.GUID - -// NewV4 returns a new version 4 (pseudorandom) GUID, as defined by RFC 4122. -func NewV4() (GUID, error) { - var b [16]byte - if _, err := rand.Read(b[:]); err != nil { - return GUID{}, err - } - - g := FromArray(b) - g.setVersion(4) // Version 4 means randomly generated. - g.setVariant(VariantRFC4122) - - return g, nil -} - -// NewV5 returns a new version 5 (generated from a string via SHA-1 hashing) -// GUID, as defined by RFC 4122. The RFC is unclear on the encoding of the name, -// and the sample code treats it as a series of bytes, so we do the same here. -// -// Some implementations, such as those found on Windows, treat the name as a -// big-endian UTF16 stream of bytes. If that is desired, the string can be -// encoded as such before being passed to this function. -func NewV5(namespace GUID, name []byte) (GUID, error) { - b := sha1.New() - namespaceBytes := namespace.ToArray() - b.Write(namespaceBytes[:]) - b.Write(name) - - a := [16]byte{} - copy(a[:], b.Sum(nil)) - - g := FromArray(a) - g.setVersion(5) // Version 5 means generated from a string. - g.setVariant(VariantRFC4122) - - return g, nil -} - -func fromArray(b [16]byte, order binary.ByteOrder) GUID { - var g GUID - g.Data1 = order.Uint32(b[0:4]) - g.Data2 = order.Uint16(b[4:6]) - g.Data3 = order.Uint16(b[6:8]) - copy(g.Data4[:], b[8:16]) - return g -} - -func (g GUID) toArray(order binary.ByteOrder) [16]byte { - b := [16]byte{} - order.PutUint32(b[0:4], g.Data1) - order.PutUint16(b[4:6], g.Data2) - order.PutUint16(b[6:8], g.Data3) - copy(b[8:16], g.Data4[:]) - return b -} - -// FromArray constructs a GUID from a big-endian encoding array of 16 bytes. -func FromArray(b [16]byte) GUID { - return fromArray(b, binary.BigEndian) -} - -// ToArray returns an array of 16 bytes representing the GUID in big-endian -// encoding. -func (g GUID) ToArray() [16]byte { - return g.toArray(binary.BigEndian) -} - -// FromWindowsArray constructs a GUID from a Windows encoding array of bytes. -func FromWindowsArray(b [16]byte) GUID { - return fromArray(b, binary.LittleEndian) -} - -// ToWindowsArray returns an array of 16 bytes representing the GUID in Windows -// encoding. -func (g GUID) ToWindowsArray() [16]byte { - return g.toArray(binary.LittleEndian) -} - -func (g GUID) String() string { - return fmt.Sprintf( - "%08x-%04x-%04x-%04x-%012x", - g.Data1, - g.Data2, - g.Data3, - g.Data4[:2], - g.Data4[2:]) -} - -// FromString parses a string containing a GUID and returns the GUID. The only -// format currently supported is the `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` -// format. -func FromString(s string) (GUID, error) { - if len(s) != 36 { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - - var g GUID - - data1, err := strconv.ParseUint(s[0:8], 16, 32) - if err != nil { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - g.Data1 = uint32(data1) - - data2, err := strconv.ParseUint(s[9:13], 16, 16) - if err != nil { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - g.Data2 = uint16(data2) - - data3, err := strconv.ParseUint(s[14:18], 16, 16) - if err != nil { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - g.Data3 = uint16(data3) - - for i, x := range []int{19, 21, 24, 26, 28, 30, 32, 34} { - v, err := strconv.ParseUint(s[x:x+2], 16, 8) - if err != nil { - return GUID{}, fmt.Errorf("invalid GUID %q", s) - } - g.Data4[i] = uint8(v) - } - - return g, nil -} - -func (g *GUID) setVariant(v Variant) { - d := g.Data4[0] - switch v { - case VariantNCS: - d = (d & 0x7f) - case VariantRFC4122: - d = (d & 0x3f) | 0x80 - case VariantMicrosoft: - d = (d & 0x1f) | 0xc0 - case VariantFuture: - d = (d & 0x0f) | 0xe0 - case VariantUnknown: - fallthrough - default: - panic(fmt.Sprintf("invalid variant: %d", v)) - } - g.Data4[0] = d -} - -// Variant returns the GUID variant, as defined in RFC 4122. -func (g GUID) Variant() Variant { - b := g.Data4[0] - if b&0x80 == 0 { - return VariantNCS - } else if b&0xc0 == 0x80 { - return VariantRFC4122 - } else if b&0xe0 == 0xc0 { - return VariantMicrosoft - } else if b&0xe0 == 0xe0 { - return VariantFuture - } - return VariantUnknown -} - -func (g *GUID) setVersion(v Version) { - g.Data3 = (g.Data3 & 0x0fff) | (uint16(v) << 12) -} - -// Version returns the GUID version, as defined in RFC 4122. -func (g GUID) Version() Version { - return Version((g.Data3 & 0xF000) >> 12) -} - -// MarshalText returns the textual representation of the GUID. -func (g GUID) MarshalText() ([]byte, error) { - return []byte(g.String()), nil -} - -// UnmarshalText takes the textual representation of a GUID, and unmarhals it -// into this GUID. -func (g *GUID) UnmarshalText(text []byte) error { - g2, err := FromString(string(text)) - if err != nil { - return err - } - *g = g2 - return nil -} diff --git a/vendor/github.com/Microsoft/go-winio/privilege.go b/vendor/github.com/Microsoft/go-winio/privilege.go deleted file mode 100644 index 9c83d36fe..000000000 --- a/vendor/github.com/Microsoft/go-winio/privilege.go +++ /dev/null @@ -1,202 +0,0 @@ -// +build windows - -package winio - -import ( - "bytes" - "encoding/binary" - "fmt" - "runtime" - "sync" - "syscall" - "unicode/utf16" - - "golang.org/x/sys/windows" -) - -//sys adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) [true] = advapi32.AdjustTokenPrivileges -//sys impersonateSelf(level uint32) (err error) = advapi32.ImpersonateSelf -//sys revertToSelf() (err error) = advapi32.RevertToSelf -//sys openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) = advapi32.OpenThreadToken -//sys getCurrentThread() (h syscall.Handle) = GetCurrentThread -//sys lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) = advapi32.LookupPrivilegeValueW -//sys lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) = advapi32.LookupPrivilegeNameW -//sys lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) = advapi32.LookupPrivilegeDisplayNameW - -const ( - SE_PRIVILEGE_ENABLED = 2 - - ERROR_NOT_ALL_ASSIGNED syscall.Errno = 1300 - - SeBackupPrivilege = "SeBackupPrivilege" - SeRestorePrivilege = "SeRestorePrivilege" -) - -const ( - securityAnonymous = iota - securityIdentification - securityImpersonation - securityDelegation -) - -var ( - privNames = make(map[string]uint64) - privNameMutex sync.Mutex -) - -// PrivilegeError represents an error enabling privileges. -type PrivilegeError struct { - privileges []uint64 -} - -func (e *PrivilegeError) Error() string { - s := "" - if len(e.privileges) > 1 { - s = "Could not enable privileges " - } else { - s = "Could not enable privilege " - } - for i, p := range e.privileges { - if i != 0 { - s += ", " - } - s += `"` - s += getPrivilegeName(p) - s += `"` - } - return s -} - -// RunWithPrivilege enables a single privilege for a function call. -func RunWithPrivilege(name string, fn func() error) error { - return RunWithPrivileges([]string{name}, fn) -} - -// RunWithPrivileges enables privileges for a function call. -func RunWithPrivileges(names []string, fn func() error) error { - privileges, err := mapPrivileges(names) - if err != nil { - return err - } - runtime.LockOSThread() - defer runtime.UnlockOSThread() - token, err := newThreadToken() - if err != nil { - return err - } - defer releaseThreadToken(token) - err = adjustPrivileges(token, privileges, SE_PRIVILEGE_ENABLED) - if err != nil { - return err - } - return fn() -} - -func mapPrivileges(names []string) ([]uint64, error) { - var privileges []uint64 - privNameMutex.Lock() - defer privNameMutex.Unlock() - for _, name := range names { - p, ok := privNames[name] - if !ok { - err := lookupPrivilegeValue("", name, &p) - if err != nil { - return nil, err - } - privNames[name] = p - } - privileges = append(privileges, p) - } - return privileges, nil -} - -// EnableProcessPrivileges enables privileges globally for the process. -func EnableProcessPrivileges(names []string) error { - return enableDisableProcessPrivilege(names, SE_PRIVILEGE_ENABLED) -} - -// DisableProcessPrivileges disables privileges globally for the process. -func DisableProcessPrivileges(names []string) error { - return enableDisableProcessPrivilege(names, 0) -} - -func enableDisableProcessPrivilege(names []string, action uint32) error { - privileges, err := mapPrivileges(names) - if err != nil { - return err - } - - p, _ := windows.GetCurrentProcess() - var token windows.Token - err = windows.OpenProcessToken(p, windows.TOKEN_ADJUST_PRIVILEGES|windows.TOKEN_QUERY, &token) - if err != nil { - return err - } - - defer token.Close() - return adjustPrivileges(token, privileges, action) -} - -func adjustPrivileges(token windows.Token, privileges []uint64, action uint32) error { - var b bytes.Buffer - binary.Write(&b, binary.LittleEndian, uint32(len(privileges))) - for _, p := range privileges { - binary.Write(&b, binary.LittleEndian, p) - binary.Write(&b, binary.LittleEndian, action) - } - prevState := make([]byte, b.Len()) - reqSize := uint32(0) - success, err := adjustTokenPrivileges(token, false, &b.Bytes()[0], uint32(len(prevState)), &prevState[0], &reqSize) - if !success { - return err - } - if err == ERROR_NOT_ALL_ASSIGNED { - return &PrivilegeError{privileges} - } - return nil -} - -func getPrivilegeName(luid uint64) string { - var nameBuffer [256]uint16 - bufSize := uint32(len(nameBuffer)) - err := lookupPrivilegeName("", &luid, &nameBuffer[0], &bufSize) - if err != nil { - return fmt.Sprintf("", luid) - } - - var displayNameBuffer [256]uint16 - displayBufSize := uint32(len(displayNameBuffer)) - var langID uint32 - err = lookupPrivilegeDisplayName("", &nameBuffer[0], &displayNameBuffer[0], &displayBufSize, &langID) - if err != nil { - return fmt.Sprintf("", string(utf16.Decode(nameBuffer[:bufSize]))) - } - - return string(utf16.Decode(displayNameBuffer[:displayBufSize])) -} - -func newThreadToken() (windows.Token, error) { - err := impersonateSelf(securityImpersonation) - if err != nil { - return 0, err - } - - var token windows.Token - err = openThreadToken(getCurrentThread(), syscall.TOKEN_ADJUST_PRIVILEGES|syscall.TOKEN_QUERY, false, &token) - if err != nil { - rerr := revertToSelf() - if rerr != nil { - panic(rerr) - } - return 0, err - } - return token, nil -} - -func releaseThreadToken(h windows.Token) { - err := revertToSelf() - if err != nil { - panic(err) - } - h.Close() -} diff --git a/vendor/github.com/Microsoft/go-winio/reparse.go b/vendor/github.com/Microsoft/go-winio/reparse.go deleted file mode 100644 index fc1ee4d3a..000000000 --- a/vendor/github.com/Microsoft/go-winio/reparse.go +++ /dev/null @@ -1,128 +0,0 @@ -package winio - -import ( - "bytes" - "encoding/binary" - "fmt" - "strings" - "unicode/utf16" - "unsafe" -) - -const ( - reparseTagMountPoint = 0xA0000003 - reparseTagSymlink = 0xA000000C -) - -type reparseDataBuffer struct { - ReparseTag uint32 - ReparseDataLength uint16 - Reserved uint16 - SubstituteNameOffset uint16 - SubstituteNameLength uint16 - PrintNameOffset uint16 - PrintNameLength uint16 -} - -// ReparsePoint describes a Win32 symlink or mount point. -type ReparsePoint struct { - Target string - IsMountPoint bool -} - -// UnsupportedReparsePointError is returned when trying to decode a non-symlink or -// mount point reparse point. -type UnsupportedReparsePointError struct { - Tag uint32 -} - -func (e *UnsupportedReparsePointError) Error() string { - return fmt.Sprintf("unsupported reparse point %x", e.Tag) -} - -// DecodeReparsePoint decodes a Win32 REPARSE_DATA_BUFFER structure containing either a symlink -// or a mount point. -func DecodeReparsePoint(b []byte) (*ReparsePoint, error) { - tag := binary.LittleEndian.Uint32(b[0:4]) - return DecodeReparsePointData(tag, b[8:]) -} - -func DecodeReparsePointData(tag uint32, b []byte) (*ReparsePoint, error) { - isMountPoint := false - switch tag { - case reparseTagMountPoint: - isMountPoint = true - case reparseTagSymlink: - default: - return nil, &UnsupportedReparsePointError{tag} - } - nameOffset := 8 + binary.LittleEndian.Uint16(b[4:6]) - if !isMountPoint { - nameOffset += 4 - } - nameLength := binary.LittleEndian.Uint16(b[6:8]) - name := make([]uint16, nameLength/2) - err := binary.Read(bytes.NewReader(b[nameOffset:nameOffset+nameLength]), binary.LittleEndian, &name) - if err != nil { - return nil, err - } - return &ReparsePoint{string(utf16.Decode(name)), isMountPoint}, nil -} - -func isDriveLetter(c byte) bool { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') -} - -// EncodeReparsePoint encodes a Win32 REPARSE_DATA_BUFFER structure describing a symlink or -// mount point. -func EncodeReparsePoint(rp *ReparsePoint) []byte { - // Generate an NT path and determine if this is a relative path. - var ntTarget string - relative := false - if strings.HasPrefix(rp.Target, `\\?\`) { - ntTarget = `\??\` + rp.Target[4:] - } else if strings.HasPrefix(rp.Target, `\\`) { - ntTarget = `\??\UNC\` + rp.Target[2:] - } else if len(rp.Target) >= 2 && isDriveLetter(rp.Target[0]) && rp.Target[1] == ':' { - ntTarget = `\??\` + rp.Target - } else { - ntTarget = rp.Target - relative = true - } - - // The paths must be NUL-terminated even though they are counted strings. - target16 := utf16.Encode([]rune(rp.Target + "\x00")) - ntTarget16 := utf16.Encode([]rune(ntTarget + "\x00")) - - size := int(unsafe.Sizeof(reparseDataBuffer{})) - 8 - size += len(ntTarget16)*2 + len(target16)*2 - - tag := uint32(reparseTagMountPoint) - if !rp.IsMountPoint { - tag = reparseTagSymlink - size += 4 // Add room for symlink flags - } - - data := reparseDataBuffer{ - ReparseTag: tag, - ReparseDataLength: uint16(size), - SubstituteNameOffset: 0, - SubstituteNameLength: uint16((len(ntTarget16) - 1) * 2), - PrintNameOffset: uint16(len(ntTarget16) * 2), - PrintNameLength: uint16((len(target16) - 1) * 2), - } - - var b bytes.Buffer - binary.Write(&b, binary.LittleEndian, &data) - if !rp.IsMountPoint { - flags := uint32(0) - if relative { - flags |= 1 - } - binary.Write(&b, binary.LittleEndian, flags) - } - - binary.Write(&b, binary.LittleEndian, ntTarget16) - binary.Write(&b, binary.LittleEndian, target16) - return b.Bytes() -} diff --git a/vendor/github.com/Microsoft/go-winio/sd.go b/vendor/github.com/Microsoft/go-winio/sd.go deleted file mode 100644 index db1b370a1..000000000 --- a/vendor/github.com/Microsoft/go-winio/sd.go +++ /dev/null @@ -1,98 +0,0 @@ -// +build windows - -package winio - -import ( - "syscall" - "unsafe" -) - -//sys lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) = advapi32.LookupAccountNameW -//sys convertSidToStringSid(sid *byte, str **uint16) (err error) = advapi32.ConvertSidToStringSidW -//sys convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) = advapi32.ConvertStringSecurityDescriptorToSecurityDescriptorW -//sys convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) = advapi32.ConvertSecurityDescriptorToStringSecurityDescriptorW -//sys localFree(mem uintptr) = LocalFree -//sys getSecurityDescriptorLength(sd uintptr) (len uint32) = advapi32.GetSecurityDescriptorLength - -const ( - cERROR_NONE_MAPPED = syscall.Errno(1332) -) - -type AccountLookupError struct { - Name string - Err error -} - -func (e *AccountLookupError) Error() string { - if e.Name == "" { - return "lookup account: empty account name specified" - } - var s string - switch e.Err { - case cERROR_NONE_MAPPED: - s = "not found" - default: - s = e.Err.Error() - } - return "lookup account " + e.Name + ": " + s -} - -type SddlConversionError struct { - Sddl string - Err error -} - -func (e *SddlConversionError) Error() string { - return "convert " + e.Sddl + ": " + e.Err.Error() -} - -// LookupSidByName looks up the SID of an account by name -func LookupSidByName(name string) (sid string, err error) { - if name == "" { - return "", &AccountLookupError{name, cERROR_NONE_MAPPED} - } - - var sidSize, sidNameUse, refDomainSize uint32 - err = lookupAccountName(nil, name, nil, &sidSize, nil, &refDomainSize, &sidNameUse) - if err != nil && err != syscall.ERROR_INSUFFICIENT_BUFFER { - return "", &AccountLookupError{name, err} - } - sidBuffer := make([]byte, sidSize) - refDomainBuffer := make([]uint16, refDomainSize) - err = lookupAccountName(nil, name, &sidBuffer[0], &sidSize, &refDomainBuffer[0], &refDomainSize, &sidNameUse) - if err != nil { - return "", &AccountLookupError{name, err} - } - var strBuffer *uint16 - err = convertSidToStringSid(&sidBuffer[0], &strBuffer) - if err != nil { - return "", &AccountLookupError{name, err} - } - sid = syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(strBuffer))[:]) - localFree(uintptr(unsafe.Pointer(strBuffer))) - return sid, nil -} - -func SddlToSecurityDescriptor(sddl string) ([]byte, error) { - var sdBuffer uintptr - err := convertStringSecurityDescriptorToSecurityDescriptor(sddl, 1, &sdBuffer, nil) - if err != nil { - return nil, &SddlConversionError{sddl, err} - } - defer localFree(sdBuffer) - sd := make([]byte, getSecurityDescriptorLength(sdBuffer)) - copy(sd, (*[0xffff]byte)(unsafe.Pointer(sdBuffer))[:len(sd)]) - return sd, nil -} - -func SecurityDescriptorToSddl(sd []byte) (string, error) { - var sddl *uint16 - // The returned string length seems to including an aribtrary number of terminating NULs. - // Don't use it. - err := convertSecurityDescriptorToStringSecurityDescriptor(&sd[0], 1, 0xff, &sddl, nil) - if err != nil { - return "", err - } - defer localFree(uintptr(unsafe.Pointer(sddl))) - return syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(sddl))[:]), nil -} diff --git a/vendor/github.com/Microsoft/go-winio/syscall.go b/vendor/github.com/Microsoft/go-winio/syscall.go deleted file mode 100644 index 5955c99fd..000000000 --- a/vendor/github.com/Microsoft/go-winio/syscall.go +++ /dev/null @@ -1,3 +0,0 @@ -package winio - -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go file.go pipe.go sd.go fileinfo.go privilege.go backup.go hvsock.go diff --git a/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go b/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go deleted file mode 100644 index 176ff75e3..000000000 --- a/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go +++ /dev/null @@ -1,427 +0,0 @@ -// Code generated by 'go generate'; DO NOT EDIT. - -package winio - -import ( - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -var _ unsafe.Pointer - -// Do the interface allocations only once for common -// Errno values. -const ( - errnoERROR_IO_PENDING = 997 -) - -var ( - errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) - errERROR_EINVAL error = syscall.EINVAL -) - -// errnoErr returns common boxed Errno values, to prevent -// allocations at runtime. -func errnoErr(e syscall.Errno) error { - switch e { - case 0: - return errERROR_EINVAL - case errnoERROR_IO_PENDING: - return errERROR_IO_PENDING - } - // TODO: add more here, after collecting data on the common - // error values see on Windows. (perhaps when running - // all.bat?) - return e -} - -var ( - modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") - modkernel32 = windows.NewLazySystemDLL("kernel32.dll") - modntdll = windows.NewLazySystemDLL("ntdll.dll") - modws2_32 = windows.NewLazySystemDLL("ws2_32.dll") - - procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") - procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW") - procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") - procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW") - procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength") - procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") - procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") - procLookupPrivilegeDisplayNameW = modadvapi32.NewProc("LookupPrivilegeDisplayNameW") - procLookupPrivilegeNameW = modadvapi32.NewProc("LookupPrivilegeNameW") - procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") - procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") - procRevertToSelf = modadvapi32.NewProc("RevertToSelf") - procBackupRead = modkernel32.NewProc("BackupRead") - procBackupWrite = modkernel32.NewProc("BackupWrite") - procCancelIoEx = modkernel32.NewProc("CancelIoEx") - procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe") - procCreateFileW = modkernel32.NewProc("CreateFileW") - procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") - procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW") - procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") - procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW") - procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo") - procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") - procLocalAlloc = modkernel32.NewProc("LocalAlloc") - procLocalFree = modkernel32.NewProc("LocalFree") - procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") - procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile") - procRtlDefaultNpAcl = modntdll.NewProc("RtlDefaultNpAcl") - procRtlDosPathNameToNtPathName_U = modntdll.NewProc("RtlDosPathNameToNtPathName_U") - procRtlNtStatusToDosErrorNoTeb = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb") - procWSAGetOverlappedResult = modws2_32.NewProc("WSAGetOverlappedResult") - procbind = modws2_32.NewProc("bind") -) - -func adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) { - var _p0 uint32 - if releaseAll { - _p0 = 1 - } - r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize))) - success = r0 != 0 - if true { - err = errnoErr(e1) - } - return -} - -func convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func convertSidToStringSid(sid *byte, str **uint16) (err error) { - r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(str) - if err != nil { - return - } - return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size) -} - -func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd *uintptr, size *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func getSecurityDescriptorLength(sd uintptr) (len uint32) { - r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(sd), 0, 0) - len = uint32(r0) - return -} - -func impersonateSelf(level uint32) (err error) { - r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(accountName) - if err != nil { - return - } - return _lookupAccountName(systemName, _p0, sid, sidSize, refDomain, refDomainSize, sidNameUse) -} - -func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(systemName) - if err != nil { - return - } - return _lookupPrivilegeDisplayName(_p0, name, buffer, size, languageId) -} - -func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procLookupPrivilegeDisplayNameW.Addr(), 5, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(systemName) - if err != nil { - return - } - return _lookupPrivilegeName(_p0, luid, buffer, size) -} - -func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procLookupPrivilegeNameW.Addr(), 4, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(systemName) - if err != nil { - return - } - var _p1 *uint16 - _p1, err = syscall.UTF16PtrFromString(name) - if err != nil { - return - } - return _lookupPrivilegeValue(_p0, _p1, luid) -} - -func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err error) { - r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) { - var _p0 uint32 - if openAsSelf { - _p0 = 1 - } - r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func revertToSelf() (err error) { - r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) { - var _p0 *byte - if len(b) > 0 { - _p0 = &b[0] - } - var _p1 uint32 - if abort { - _p1 = 1 - } - var _p2 uint32 - if processSecurity { - _p2 = 1 - } - r1, _, e1 := syscall.Syscall9(procBackupRead.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) { - var _p0 *byte - if len(b) > 0 { - _p0 = &b[0] - } - var _p1 uint32 - if abort { - _p1 = 1 - } - var _p2 uint32 - if processSecurity { - _p2 = 1 - } - r1, _, e1 := syscall.Syscall9(procBackupWrite.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) { - r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) { - r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(name) - if err != nil { - return - } - return _createFile(_p0, access, mode, sa, createmode, attrs, templatefile) -} - -func _createFile(name *uint16, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) { - r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0) - handle = syscall.Handle(r0) - if handle == syscall.InvalidHandle { - err = errnoErr(e1) - } - return -} - -func createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) { - r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(file), uintptr(port), uintptr(key), uintptr(threadCount), 0, 0) - newport = syscall.Handle(r0) - if newport == 0 { - err = errnoErr(e1) - } - return -} - -func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) { - var _p0 *uint16 - _p0, err = syscall.UTF16PtrFromString(name) - if err != nil { - return - } - return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa) -} - -func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) { - r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0) - handle = syscall.Handle(r0) - if handle == syscall.InvalidHandle { - err = errnoErr(e1) - } - return -} - -func getCurrentThread() (h syscall.Handle) { - r0, _, _ := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0) - h = syscall.Handle(r0) - return -} - -func getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func localAlloc(uFlags uint32, length uint32) (ptr uintptr) { - r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(uFlags), uintptr(length), 0) - ptr = uintptr(r0) - return -} - -func localFree(mem uintptr) { - syscall.Syscall(procLocalFree.Addr(), 1, uintptr(mem), 0, 0) - return -} - -func setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) { - r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func ntCreateNamedPipeFile(pipe *syscall.Handle, access uint32, oa *objectAttributes, iosb *ioStatusBlock, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (status ntstatus) { - r0, _, _ := syscall.Syscall15(procNtCreateNamedPipeFile.Addr(), 14, uintptr(unsafe.Pointer(pipe)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(share), uintptr(disposition), uintptr(options), uintptr(typ), uintptr(readMode), uintptr(completionMode), uintptr(maxInstances), uintptr(inboundQuota), uintptr(outputQuota), uintptr(unsafe.Pointer(timeout)), 0) - status = ntstatus(r0) - return -} - -func rtlDefaultNpAcl(dacl *uintptr) (status ntstatus) { - r0, _, _ := syscall.Syscall(procRtlDefaultNpAcl.Addr(), 1, uintptr(unsafe.Pointer(dacl)), 0, 0) - status = ntstatus(r0) - return -} - -func rtlDosPathNameToNtPathName(name *uint16, ntName *unicodeString, filePart uintptr, reserved uintptr) (status ntstatus) { - r0, _, _ := syscall.Syscall6(procRtlDosPathNameToNtPathName_U.Addr(), 4, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(ntName)), uintptr(filePart), uintptr(reserved), 0, 0) - status = ntstatus(r0) - return -} - -func rtlNtStatusToDosError(status ntstatus) (winerr error) { - r0, _, _ := syscall.Syscall(procRtlNtStatusToDosErrorNoTeb.Addr(), 1, uintptr(status), 0, 0) - if r0 != 0 { - winerr = syscall.Errno(r0) - } - return -} - -func wsaGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) { - var _p0 uint32 - if wait { - _p0 = 1 - } - r1, _, e1 := syscall.Syscall6(procWSAGetOverlappedResult.Addr(), 5, uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)), 0) - if r1 == 0 { - err = errnoErr(e1) - } - return -} - -func bind(s syscall.Handle, name unsafe.Pointer, namelen int32) (err error) { - r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) - if r1 == socketError { - err = errnoErr(e1) - } - return -} diff --git a/vendor/k8s.io/apiserver/LICENSE b/vendor/k8s.io/apiserver/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/k8s.io/apiserver/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/k8s.io/apiserver/pkg/features/OWNERS b/vendor/k8s.io/apiserver/pkg/features/OWNERS deleted file mode 100644 index 3e1dd9f08..000000000 --- a/vendor/k8s.io/apiserver/pkg/features/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: - - feature-approvers diff --git a/vendor/k8s.io/apiserver/pkg/features/kube_features.go b/vendor/k8s.io/apiserver/pkg/features/kube_features.go deleted file mode 100644 index aa903587d..000000000 --- a/vendor/k8s.io/apiserver/pkg/features/kube_features.go +++ /dev/null @@ -1,252 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package features - -import ( - "k8s.io/apimachinery/pkg/util/runtime" - - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/component-base/featuregate" -) - -const ( - // Every feature gate should add method here following this template: - // - // // owner: @username - // // alpha: v1.4 - // MyFeature featuregate.Feature = "MyFeature" - // - // Feature gates should be listed in alphabetical, case-sensitive - // (upper before any lower case character) order. This reduces the risk - // of code conflicts because changes are more likely to be scattered - // across the file. - - // owner: @jefftree @alexzielenski - // alpha: v1.26 - // - // Enables an single HTTP endpoint /discovery/ which supports native HTTP - // caching with ETags containing all APIResources known to the apiserver. - AggregatedDiscoveryEndpoint featuregate.Feature = "AggregatedDiscoveryEndpoint" - - // owner: @smarterclayton - // alpha: v1.8 - // beta: v1.9 - // - // Allow API clients to retrieve resource lists in chunks rather than - // all at once. - APIListChunking featuregate.Feature = "APIListChunking" - - // owner: @MikeSpreitzer @yue9944882 - // alpha: v1.18 - // beta: v1.20 - // - // Enables managing request concurrency with prioritization and fairness at each server. - // The FeatureGate was introduced in release 1.15 but the feature - // was not really implemented before 1.18. - APIPriorityAndFairness featuregate.Feature = "APIPriorityAndFairness" - - // owner: @ilackams - // alpha: v1.7 - // beta: v1.16 - // - // Enables compression of REST responses (GET and LIST only) - APIResponseCompression featuregate.Feature = "APIResponseCompression" - - // owner: @roycaihw - // alpha: v1.20 - // - // Assigns each kube-apiserver an ID in a cluster. - APIServerIdentity featuregate.Feature = "APIServerIdentity" - - // owner: @dashpole - // alpha: v1.22 - // - // Add support for distributed tracing in the API Server - APIServerTracing featuregate.Feature = "APIServerTracing" - - // owner: @tallclair - // alpha: v1.7 - // beta: v1.8 - // GA: v1.12 - // - // AdvancedAuditing enables a much more general API auditing pipeline, which includes support for - // pluggable output backends and an audit policy specifying how different requests should be - // audited. - AdvancedAuditing featuregate.Feature = "AdvancedAuditing" - - // owner: @cici37 @jpbetz - // kep: http://kep.k8s.io/3488 - // alpha: v1.26 - // - // Enables expression validation in Admission Control - ValidatingAdmissionPolicy featuregate.Feature = "ValidatingAdmissionPolicy" - - // owner: @cici37 - // kep: https://kep.k8s.io/2876 - // alpha: v1.23 - // beta: v1.25 - // - // Enables expression validation for Custom Resource - CustomResourceValidationExpressions featuregate.Feature = "CustomResourceValidationExpressions" - - // owner: @apelisse - // alpha: v1.12 - // beta: v1.13 - // stable: v1.18 - // - // Allow requests to be processed but not stored, so that - // validation, merging, mutation can be tested without - // committing. - DryRun featuregate.Feature = "DryRun" - - // owner: @wojtek-t - // alpha: v1.20 - // beta: v1.21 - // GA: v1.24 - // - // Allows for updating watchcache resource version with progress notify events. - EfficientWatchResumption featuregate.Feature = "EfficientWatchResumption" - - // owner: @aramase - // kep: https://kep.k8s.io/3299 - // alpha: v1.25 - // - // Enables KMS v2 API for encryption at rest. - KMSv2 featuregate.Feature = "KMSv2" - - // owner: @jiahuif - // kep: https://kep.k8s.io/2887 - // alpha: v1.23 - // beta: v1.24 - // - // Enables populating "enum" field of OpenAPI schemas - // in the spec returned from kube-apiserver. - OpenAPIEnums featuregate.Feature = "OpenAPIEnums" - - // owner: @jefftree - // kep: https://kep.k8s.io/2896 - // alpha: v1.23 - // beta: v1.24 - // - // Enables kubernetes to publish OpenAPI v3 - OpenAPIV3 featuregate.Feature = "OpenAPIV3" - - // owner: @caesarxuchao - // alpha: v1.15 - // beta: v1.16 - // - // Allow apiservers to show a count of remaining items in the response - // to a chunking list request. - RemainingItemCount featuregate.Feature = "RemainingItemCount" - - // owner: @wojtek-t - // alpha: v1.16 - // beta: v1.20 - // GA: v1.24 - // - // Deprecates and removes SelfLink from ObjectMeta and ListMeta. - RemoveSelfLink featuregate.Feature = "RemoveSelfLink" - - // owner: @apelisse, @lavalamp - // alpha: v1.14 - // beta: v1.16 - // stable: v1.22 - // - // Server-side apply. Merging happens on the server. - ServerSideApply featuregate.Feature = "ServerSideApply" - - // owner: @kevindelgado - // kep: https://kep.k8s.io/2885 - // alpha: v1.23 - // beta: v1.24 - // - // Enables server-side field validation. - ServerSideFieldValidation featuregate.Feature = "ServerSideFieldValidation" - - // owner: @caesarxuchao @roycaihw - // alpha: v1.20 - // - // Enable the storage version API. - StorageVersionAPI featuregate.Feature = "StorageVersionAPI" - - // owner: @caesarxuchao - // alpha: v1.14 - // beta: v1.15 - // - // Allow apiservers to expose the storage version hash in the discovery - // document. - StorageVersionHash featuregate.Feature = "StorageVersionHash" - - // owner: @wojtek-t - // alpha: v1.15 - // beta: v1.16 - // GA: v1.17 - // - // Enables support for watch bookmark events. - WatchBookmark featuregate.Feature = "WatchBookmark" -) - -func init() { - runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)) -} - -// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys. -// To add a new feature, define a key for it above and add it here. The features will be -// available throughout Kubernetes binaries. -var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ - AggregatedDiscoveryEndpoint: {Default: false, PreRelease: featuregate.Alpha}, - - APIListChunking: {Default: true, PreRelease: featuregate.Beta}, - - APIPriorityAndFairness: {Default: true, PreRelease: featuregate.Beta}, - - APIResponseCompression: {Default: true, PreRelease: featuregate.Beta}, - - APIServerIdentity: {Default: true, PreRelease: featuregate.Beta}, - - APIServerTracing: {Default: false, PreRelease: featuregate.Alpha}, - - AdvancedAuditing: {Default: true, PreRelease: featuregate.GA}, - - ValidatingAdmissionPolicy: {Default: false, PreRelease: featuregate.Alpha}, - - CustomResourceValidationExpressions: {Default: true, PreRelease: featuregate.Beta}, - - DryRun: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - EfficientWatchResumption: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, - - KMSv2: {Default: false, PreRelease: featuregate.Alpha}, - - OpenAPIEnums: {Default: true, PreRelease: featuregate.Beta}, - - OpenAPIV3: {Default: true, PreRelease: featuregate.Beta}, - - RemainingItemCount: {Default: true, PreRelease: featuregate.Beta}, - - RemoveSelfLink: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, - - ServerSideApply: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.29 - - ServerSideFieldValidation: {Default: true, PreRelease: featuregate.Beta}, - - StorageVersionAPI: {Default: false, PreRelease: featuregate.Alpha}, - - StorageVersionHash: {Default: true, PreRelease: featuregate.Beta}, - - WatchBookmark: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, -} diff --git a/vendor/k8s.io/apiserver/pkg/util/feature/feature_gate.go b/vendor/k8s.io/apiserver/pkg/util/feature/feature_gate.go deleted file mode 100644 index 5911b7568..000000000 --- a/vendor/k8s.io/apiserver/pkg/util/feature/feature_gate.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package feature - -import ( - "k8s.io/component-base/featuregate" -) - -var ( - // DefaultMutableFeatureGate is a mutable version of DefaultFeatureGate. - // Only top-level commands/options setup and the k8s.io/component-base/featuregate/testing package should make use of this. - // Tests that need to modify feature gates for the duration of their test should use: - // defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features., )() - DefaultMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate() - - // DefaultFeatureGate is a shared global FeatureGate. - // Top-level commands/options setup that needs to modify this feature gate should use DefaultMutableFeatureGate. - DefaultFeatureGate featuregate.FeatureGate = DefaultMutableFeatureGate -) diff --git a/vendor/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.pb.go b/vendor/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.pb.go deleted file mode 100644 index e4ebb4839..000000000 --- a/vendor/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.pb.go +++ /dev/null @@ -1,1400 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: api.proto - -package v1alpha1 - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" - reflect "reflect" - strings "strings" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// ListPodResourcesRequest is the request made to the PodResourcesLister service -type ListPodResourcesRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListPodResourcesRequest) Reset() { *m = ListPodResourcesRequest{} } -func (*ListPodResourcesRequest) ProtoMessage() {} -func (*ListPodResourcesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{0} -} -func (m *ListPodResourcesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ListPodResourcesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ListPodResourcesRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ListPodResourcesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListPodResourcesRequest.Merge(m, src) -} -func (m *ListPodResourcesRequest) XXX_Size() int { - return m.Size() -} -func (m *ListPodResourcesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListPodResourcesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListPodResourcesRequest proto.InternalMessageInfo - -// ListPodResourcesResponse is the response returned by List function -type ListPodResourcesResponse struct { - PodResources []*PodResources `protobuf:"bytes,1,rep,name=pod_resources,json=podResources,proto3" json:"pod_resources,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListPodResourcesResponse) Reset() { *m = ListPodResourcesResponse{} } -func (*ListPodResourcesResponse) ProtoMessage() {} -func (*ListPodResourcesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{1} -} -func (m *ListPodResourcesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ListPodResourcesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ListPodResourcesResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ListPodResourcesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListPodResourcesResponse.Merge(m, src) -} -func (m *ListPodResourcesResponse) XXX_Size() int { - return m.Size() -} -func (m *ListPodResourcesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListPodResourcesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListPodResourcesResponse proto.InternalMessageInfo - -func (m *ListPodResourcesResponse) GetPodResources() []*PodResources { - if m != nil { - return m.PodResources - } - return nil -} - -// PodResources contains information about the node resources assigned to a pod -type PodResources struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` - Containers []*ContainerResources `protobuf:"bytes,3,rep,name=containers,proto3" json:"containers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PodResources) Reset() { *m = PodResources{} } -func (*PodResources) ProtoMessage() {} -func (*PodResources) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{2} -} -func (m *PodResources) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PodResources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PodResources.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PodResources) XXX_Merge(src proto.Message) { - xxx_messageInfo_PodResources.Merge(m, src) -} -func (m *PodResources) XXX_Size() int { - return m.Size() -} -func (m *PodResources) XXX_DiscardUnknown() { - xxx_messageInfo_PodResources.DiscardUnknown(m) -} - -var xxx_messageInfo_PodResources proto.InternalMessageInfo - -func (m *PodResources) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *PodResources) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *PodResources) GetContainers() []*ContainerResources { - if m != nil { - return m.Containers - } - return nil -} - -// ContainerResources contains information about the resources assigned to a container -type ContainerResources struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Devices []*ContainerDevices `protobuf:"bytes,2,rep,name=devices,proto3" json:"devices,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ContainerResources) Reset() { *m = ContainerResources{} } -func (*ContainerResources) ProtoMessage() {} -func (*ContainerResources) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{3} -} -func (m *ContainerResources) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ContainerResources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ContainerResources.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ContainerResources) XXX_Merge(src proto.Message) { - xxx_messageInfo_ContainerResources.Merge(m, src) -} -func (m *ContainerResources) XXX_Size() int { - return m.Size() -} -func (m *ContainerResources) XXX_DiscardUnknown() { - xxx_messageInfo_ContainerResources.DiscardUnknown(m) -} - -var xxx_messageInfo_ContainerResources proto.InternalMessageInfo - -func (m *ContainerResources) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *ContainerResources) GetDevices() []*ContainerDevices { - if m != nil { - return m.Devices - } - return nil -} - -// ContainerDevices contains information about the devices assigned to a container -type ContainerDevices struct { - ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3" json:"resource_name,omitempty"` - DeviceIds []string `protobuf:"bytes,2,rep,name=device_ids,json=deviceIds,proto3" json:"device_ids,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ContainerDevices) Reset() { *m = ContainerDevices{} } -func (*ContainerDevices) ProtoMessage() {} -func (*ContainerDevices) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{4} -} -func (m *ContainerDevices) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ContainerDevices) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ContainerDevices.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ContainerDevices) XXX_Merge(src proto.Message) { - xxx_messageInfo_ContainerDevices.Merge(m, src) -} -func (m *ContainerDevices) XXX_Size() int { - return m.Size() -} -func (m *ContainerDevices) XXX_DiscardUnknown() { - xxx_messageInfo_ContainerDevices.DiscardUnknown(m) -} - -var xxx_messageInfo_ContainerDevices proto.InternalMessageInfo - -func (m *ContainerDevices) GetResourceName() string { - if m != nil { - return m.ResourceName - } - return "" -} - -func (m *ContainerDevices) GetDeviceIds() []string { - if m != nil { - return m.DeviceIds - } - return nil -} - -func init() { - proto.RegisterType((*ListPodResourcesRequest)(nil), "v1alpha1.ListPodResourcesRequest") - proto.RegisterType((*ListPodResourcesResponse)(nil), "v1alpha1.ListPodResourcesResponse") - proto.RegisterType((*PodResources)(nil), "v1alpha1.PodResources") - proto.RegisterType((*ContainerResources)(nil), "v1alpha1.ContainerResources") - proto.RegisterType((*ContainerDevices)(nil), "v1alpha1.ContainerDevices") -} - -func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) } - -var fileDescriptor_00212fb1f9d3bf1c = []byte{ - // 343 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0xad, 0xdb, 0x0a, 0xc8, 0xd1, 0x4a, 0xc8, 0x03, 0x84, 0xaa, 0x58, 0xc5, 0x2c, 0x5d, 0x48, - 0xd5, 0xc2, 0x06, 0x13, 0xb0, 0x20, 0x21, 0x40, 0x19, 0x60, 0xa3, 0x4a, 0x13, 0xd3, 0x46, 0xa2, - 0xb1, 0x89, 0x93, 0x8e, 0x88, 0x4f, 0xe0, 0xb3, 0x3a, 0x32, 0x32, 0xd2, 0xf0, 0x23, 0x28, 0xb6, - 0xac, 0x04, 0x5a, 0x98, 0x7c, 0x77, 0xef, 0x9d, 0xdf, 0xf3, 0x9d, 0xc1, 0xf2, 0x44, 0xe8, 0x88, - 0x98, 0x27, 0x1c, 0x6f, 0xcc, 0xfa, 0xde, 0x93, 0x98, 0x78, 0xfd, 0xd6, 0xe1, 0x38, 0x4c, 0x26, - 0xe9, 0xc8, 0xf1, 0xf9, 0xb4, 0x37, 0xe6, 0x63, 0xde, 0x53, 0x84, 0x51, 0xfa, 0xa8, 0x32, 0x95, - 0xa8, 0x48, 0x37, 0xd2, 0x5d, 0xd8, 0xb9, 0x0a, 0x65, 0x72, 0xcb, 0x03, 0x97, 0x49, 0x9e, 0xc6, - 0x3e, 0x93, 0x2e, 0x7b, 0x4e, 0x99, 0x4c, 0xe8, 0x3d, 0xd8, 0xcb, 0x90, 0x14, 0x3c, 0x92, 0x0c, - 0x9f, 0x40, 0x53, 0xf0, 0x60, 0x18, 0x1b, 0xc0, 0x46, 0x9d, 0x5a, 0x77, 0x73, 0xb0, 0xed, 0x18, - 0x1f, 0xce, 0x8f, 0xb6, 0x86, 0x28, 0x65, 0xf4, 0x05, 0x1a, 0x65, 0x14, 0x63, 0xa8, 0x47, 0xde, - 0x94, 0xd9, 0xa8, 0x83, 0xba, 0x96, 0xab, 0x62, 0xdc, 0x06, 0x2b, 0x3f, 0xa5, 0xf0, 0x7c, 0x66, - 0x57, 0x15, 0x50, 0x14, 0xf0, 0x29, 0x80, 0xcf, 0xa3, 0xc4, 0x0b, 0x23, 0x16, 0x4b, 0xbb, 0xa6, - 0xb4, 0xdb, 0x85, 0xf6, 0xb9, 0xc1, 0x0a, 0x07, 0x25, 0x3e, 0x7d, 0x00, 0xbc, 0xcc, 0x58, 0xe9, - 0xe2, 0x18, 0xd6, 0x03, 0x36, 0x0b, 0xf3, 0x07, 0x56, 0x95, 0x48, 0x6b, 0x85, 0xc8, 0x85, 0x66, - 0xb8, 0x86, 0x4a, 0xef, 0x60, 0xeb, 0x37, 0x88, 0x0f, 0xa0, 0x69, 0x86, 0x35, 0x2c, 0xc9, 0x34, - 0x4c, 0xf1, 0x3a, 0x97, 0xdb, 0x03, 0xd0, 0x77, 0x0c, 0xc3, 0x40, 0x2b, 0x5a, 0xae, 0xa5, 0x2b, - 0x97, 0x81, 0x1c, 0x30, 0xc0, 0xe5, 0xb9, 0xe5, 0xcb, 0x61, 0x31, 0xbe, 0x81, 0x7a, 0x1e, 0xe1, - 0xfd, 0xc2, 0xda, 0x1f, 0x1b, 0x6d, 0xd1, 0xff, 0x28, 0x7a, 0xb3, 0xb4, 0x72, 0xd6, 0x9e, 0x2f, - 0x08, 0xfa, 0x58, 0x90, 0xca, 0x6b, 0x46, 0xd0, 0x3c, 0x23, 0xe8, 0x3d, 0x23, 0xe8, 0x33, 0x23, - 0xe8, 0xed, 0x8b, 0x54, 0x46, 0x6b, 0xea, 0xdf, 0x1c, 0x7d, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc0, - 0xce, 0xf2, 0x80, 0x7d, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// PodResourcesListerClient is the client API for PodResourcesLister service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type PodResourcesListerClient interface { - List(ctx context.Context, in *ListPodResourcesRequest, opts ...grpc.CallOption) (*ListPodResourcesResponse, error) -} - -type podResourcesListerClient struct { - cc *grpc.ClientConn -} - -func NewPodResourcesListerClient(cc *grpc.ClientConn) PodResourcesListerClient { - return &podResourcesListerClient{cc} -} - -func (c *podResourcesListerClient) List(ctx context.Context, in *ListPodResourcesRequest, opts ...grpc.CallOption) (*ListPodResourcesResponse, error) { - out := new(ListPodResourcesResponse) - err := c.cc.Invoke(ctx, "/v1alpha1.PodResourcesLister/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PodResourcesListerServer is the server API for PodResourcesLister service. -type PodResourcesListerServer interface { - List(context.Context, *ListPodResourcesRequest) (*ListPodResourcesResponse, error) -} - -// UnimplementedPodResourcesListerServer can be embedded to have forward compatible implementations. -type UnimplementedPodResourcesListerServer struct { -} - -func (*UnimplementedPodResourcesListerServer) List(ctx context.Context, req *ListPodResourcesRequest) (*ListPodResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterPodResourcesListerServer(s *grpc.Server, srv PodResourcesListerServer) { - s.RegisterService(&_PodResourcesLister_serviceDesc, srv) -} - -func _PodResourcesLister_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPodResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PodResourcesListerServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/v1alpha1.PodResourcesLister/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PodResourcesListerServer).List(ctx, req.(*ListPodResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _PodResourcesLister_serviceDesc = grpc.ServiceDesc{ - ServiceName: "v1alpha1.PodResourcesLister", - HandlerType: (*PodResourcesListerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "List", - Handler: _PodResourcesLister_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "api.proto", -} - -func (m *ListPodResourcesRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ListPodResourcesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ListPodResourcesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *ListPodResourcesResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ListPodResourcesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ListPodResourcesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PodResources) > 0 { - for iNdEx := len(m.PodResources) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PodResources[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintApi(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *PodResources) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PodResources) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PodResources) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Containers) > 0 { - for iNdEx := len(m.Containers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Containers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintApi(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Namespace) > 0 { - i -= len(m.Namespace) - copy(dAtA[i:], m.Namespace) - i = encodeVarintApi(dAtA, i, uint64(len(m.Namespace))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintApi(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ContainerResources) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ContainerResources) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ContainerResources) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Devices) > 0 { - for iNdEx := len(m.Devices) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Devices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintApi(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintApi(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ContainerDevices) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ContainerDevices) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ContainerDevices) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DeviceIds) > 0 { - for iNdEx := len(m.DeviceIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.DeviceIds[iNdEx]) - copy(dAtA[i:], m.DeviceIds[iNdEx]) - i = encodeVarintApi(dAtA, i, uint64(len(m.DeviceIds[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.ResourceName) > 0 { - i -= len(m.ResourceName) - copy(dAtA[i:], m.ResourceName) - i = encodeVarintApi(dAtA, i, uint64(len(m.ResourceName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintApi(dAtA []byte, offset int, v uint64) int { - offset -= sovApi(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ListPodResourcesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *ListPodResourcesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PodResources) > 0 { - for _, e := range m.PodResources { - l = e.Size() - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func (m *PodResources) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.Namespace) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - if len(m.Containers) > 0 { - for _, e := range m.Containers { - l = e.Size() - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func (m *ContainerResources) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - if len(m.Devices) > 0 { - for _, e := range m.Devices { - l = e.Size() - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func (m *ContainerDevices) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ResourceName) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - if len(m.DeviceIds) > 0 { - for _, s := range m.DeviceIds { - l = len(s) - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func sovApi(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozApi(x uint64) (n int) { - return sovApi(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *ListPodResourcesRequest) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&ListPodResourcesRequest{`, - `}`, - }, "") - return s -} -func (this *ListPodResourcesResponse) String() string { - if this == nil { - return "nil" - } - repeatedStringForPodResources := "[]*PodResources{" - for _, f := range this.PodResources { - repeatedStringForPodResources += strings.Replace(f.String(), "PodResources", "PodResources", 1) + "," - } - repeatedStringForPodResources += "}" - s := strings.Join([]string{`&ListPodResourcesResponse{`, - `PodResources:` + repeatedStringForPodResources + `,`, - `}`, - }, "") - return s -} -func (this *PodResources) String() string { - if this == nil { - return "nil" - } - repeatedStringForContainers := "[]*ContainerResources{" - for _, f := range this.Containers { - repeatedStringForContainers += strings.Replace(f.String(), "ContainerResources", "ContainerResources", 1) + "," - } - repeatedStringForContainers += "}" - s := strings.Join([]string{`&PodResources{`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`, - `Containers:` + repeatedStringForContainers + `,`, - `}`, - }, "") - return s -} -func (this *ContainerResources) String() string { - if this == nil { - return "nil" - } - repeatedStringForDevices := "[]*ContainerDevices{" - for _, f := range this.Devices { - repeatedStringForDevices += strings.Replace(f.String(), "ContainerDevices", "ContainerDevices", 1) + "," - } - repeatedStringForDevices += "}" - s := strings.Join([]string{`&ContainerResources{`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `Devices:` + repeatedStringForDevices + `,`, - `}`, - }, "") - return s -} -func (this *ContainerDevices) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&ContainerDevices{`, - `ResourceName:` + fmt.Sprintf("%v", this.ResourceName) + `,`, - `DeviceIds:` + fmt.Sprintf("%v", this.DeviceIds) + `,`, - `}`, - }, "") - return s -} -func valueToStringApi(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *ListPodResourcesRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ListPodResourcesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ListPodResourcesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ListPodResourcesResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ListPodResourcesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ListPodResourcesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PodResources", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PodResources = append(m.PodResources, &PodResources{}) - if err := m.PodResources[len(m.PodResources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PodResources) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PodResources: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PodResources: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Namespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Containers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Containers = append(m.Containers, &ContainerResources{}) - if err := m.Containers[len(m.Containers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ContainerResources) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ContainerResources: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ContainerResources: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Devices", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Devices = append(m.Devices, &ContainerDevices{}) - if err := m.Devices[len(m.Devices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ContainerDevices) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ContainerDevices: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ContainerDevices: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeviceIds", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DeviceIds = append(m.DeviceIds, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipApi(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowApi - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowApi - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowApi - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthApi - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupApi - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthApi - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthApi = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupApi = fmt.Errorf("proto: unexpected end of group") -) diff --git a/vendor/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto b/vendor/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto deleted file mode 100644 index 782ac714b..000000000 --- a/vendor/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto +++ /dev/null @@ -1,48 +0,0 @@ -// To regenerate api.pb.go run hack/update-generated-pod-resources.sh -syntax = "proto3"; - -package v1alpha1; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.stringer_all) = true; -option (gogoproto.goproto_getters_all) = true; -option (gogoproto.marshaler_all) = true; -option (gogoproto.sizer_all) = true; -option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unrecognized_all) = false; - - -// PodResourcesLister is a service provided by the kubelet that provides information about the -// node resources consumed by pods and containers on the node -service PodResourcesLister { - rpc List(ListPodResourcesRequest) returns (ListPodResourcesResponse) {} -} - -// ListPodResourcesRequest is the request made to the PodResourcesLister service -message ListPodResourcesRequest {} - -// ListPodResourcesResponse is the response returned by List function -message ListPodResourcesResponse { - repeated PodResources pod_resources = 1; -} - -// PodResources contains information about the node resources assigned to a pod -message PodResources { - string name = 1; - string namespace = 2; - repeated ContainerResources containers = 3; -} - -// ContainerResources contains information about the resources assigned to a container -message ContainerResources { - string name = 1; - repeated ContainerDevices devices = 2; -} - -// ContainerDevices contains information about the devices assigned to a container -message ContainerDevices { - string resource_name = 1; - repeated string device_ids = 2; -} \ No newline at end of file diff --git a/vendor/k8s.io/kubernetes/LICENSE b/vendor/k8s.io/kubernetes/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/k8s.io/kubernetes/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/k8s.io/kubernetes/pkg/features/OWNERS b/vendor/k8s.io/kubernetes/pkg/features/OWNERS deleted file mode 100644 index 3e1dd9f08..000000000 --- a/vendor/k8s.io/kubernetes/pkg/features/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: - - feature-approvers diff --git a/vendor/k8s.io/kubernetes/pkg/features/kube_features.go b/vendor/k8s.io/kubernetes/pkg/features/kube_features.go deleted file mode 100644 index 2ad904d6f..000000000 --- a/vendor/k8s.io/kubernetes/pkg/features/kube_features.go +++ /dev/null @@ -1,1190 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package features - -import ( - "k8s.io/apimachinery/pkg/util/runtime" - genericfeatures "k8s.io/apiserver/pkg/features" - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/component-base/featuregate" -) - -const ( - // Every feature gate should add method here following this template: - // - // // owner: @username - // // kep: https://kep.k8s.io/NNN - // // alpha: v1.X - // MyFeature featuregate.Feature = "MyFeature" - // - // Feature gates should be listed in alphabetical, case-sensitive - // (upper before any lower case character) order. This reduces the risk - // of code conflicts because changes are more likely to be scattered - // across the file. - - // owner: @ttakahashi21 @mkimuram - // kep: https://kep.k8s.io/3294 - // alpha: v1.26 - // - // Enable usage of Provision of PVCs from snapshots in other namespaces - CrossNamespaceVolumeDataSource featuregate.Feature = "CrossNamespaceVolumeDataSource" - - // owner: @bswartz - // alpha: v1.18 - // beta: v1.24 - // - // Enables usage of any object for volume data source in PVCs - AnyVolumeDataSource featuregate.Feature = "AnyVolumeDataSource" - - // owner: @nabokihms - // alpha: v1.26 - // - // Enables API to get self subject attributes after authentication. - APISelfSubjectReview featuregate.Feature = "APISelfSubjectReview" - - // owner: @tallclair - // beta: v1.4 - AppArmor featuregate.Feature = "AppArmor" - - // owner: @szuecs - // alpha: v1.12 - // - // Enable nodes to change CPUCFSQuotaPeriod - CPUCFSQuotaPeriod featuregate.Feature = "CustomCPUCFSQuotaPeriod" - - // owner: @ConnorDoyle, @fromanirh (only for GA graduation) - // alpha: v1.8 - // beta: v1.10 - // GA: v1.26 - // - // Alternative container-level CPU affinity policies. - CPUManager featuregate.Feature = "CPUManager" - - // owner: @fromanirh - // alpha: v1.23 - // beta: see below. - // - // Allow fine-tuning of cpumanager policies, experimental, alpha-quality options - // Per https://groups.google.com/g/kubernetes-sig-architecture/c/Nxsc7pfe5rw/m/vF2djJh0BAAJ - // We want to avoid a proliferation of feature gates. This feature gate: - // - will guard *a group* of cpumanager options whose quality level is alpha. - // - will never graduate to beta or stable. - // See https://groups.google.com/g/kubernetes-sig-architecture/c/Nxsc7pfe5rw/m/vF2djJh0BAAJ - // for details about the removal of this feature gate. - CPUManagerPolicyAlphaOptions featuregate.Feature = "CPUManagerPolicyAlphaOptions" - - // owner: @fromanirh - // beta: v1.23 - // beta: see below. - // - // Allow fine-tuning of cpumanager policies, experimental, beta-quality options - // Per https://groups.google.com/g/kubernetes-sig-architecture/c/Nxsc7pfe5rw/m/vF2djJh0BAAJ - // We want to avoid a proliferation of feature gates. This feature gate: - // - will guard *a group* of cpumanager options whose quality level is beta. - // - is thus *introduced* as beta - // - will never graduate to stable. - // See https://groups.google.com/g/kubernetes-sig-architecture/c/Nxsc7pfe5rw/m/vF2djJh0BAAJ - // for details about the removal of this feature gate. - CPUManagerPolicyBetaOptions featuregate.Feature = "CPUManagerPolicyBetaOptions" - - // owner: @fromanirh - // alpha: v1.22 - // beta: v1.23 - // - // Allow the usage of options to fine-tune the cpumanager policies. - CPUManagerPolicyOptions featuregate.Feature = "CPUManagerPolicyOptions" - - // owner: @pohly - // alpha: v1.14 - // beta: v1.16 - // GA: v1.25 - // - // Enables CSI Inline volumes support for pods - CSIInlineVolume featuregate.Feature = "CSIInlineVolume" - - // owner: @davidz627 - // alpha: v1.14 - // beta: v1.17 - // - // Enables the in-tree storage to CSI Plugin migration feature. - CSIMigration featuregate.Feature = "CSIMigration" - - // owner: @leakingtapan - // alpha: v1.14 - // beta: v1.17 - // GA: v1.25 - // - // Enables the AWS EBS in-tree driver to AWS EBS CSI Driver migration feature. - CSIMigrationAWS featuregate.Feature = "CSIMigrationAWS" - - // owner: @andyzhangx - // alpha: v1.15 - // beta: v1.19 - // GA: v1.24 - // - // Enables the Azure Disk in-tree driver to Azure Disk Driver migration feature. - CSIMigrationAzureDisk featuregate.Feature = "CSIMigrationAzureDisk" - - // owner: @andyzhangx - // alpha: v1.15 - // beta: v1.21 - // GA: v1.26 - // - // Enables the Azure File in-tree driver to Azure File Driver migration feature. - CSIMigrationAzureFile featuregate.Feature = "CSIMigrationAzureFile" - - // owner: @davidz627 - // alpha: v1.14 - // beta: v1.17 - // GA: 1.25 - // - // Enables the GCE PD in-tree driver to GCE CSI Driver migration feature. - CSIMigrationGCE featuregate.Feature = "CSIMigrationGCE" - - // owner: @trierra - // alpha: v1.23 - // - // Enables the Portworx in-tree driver to Portworx migration feature. - CSIMigrationPortworx featuregate.Feature = "CSIMigrationPortworx" - - // owner: @humblec - // alpha: v1.23 - // - // Enables the RBD in-tree driver to RBD CSI Driver migration feature. - CSIMigrationRBD featuregate.Feature = "CSIMigrationRBD" - - // owner: @divyenpatel - // beta: v1.19 (requires: vSphere vCenter/ESXi Version: 7.0u2, HW Version: VM version 15) - // GA: 1.26 - // Enables the vSphere in-tree driver to vSphere CSI Driver migration feature. - CSIMigrationvSphere featuregate.Feature = "CSIMigrationvSphere" - - // owner: @humblec, @zhucan - // kep: https://kep.k8s.io/3171 - // alpha: v1.25 - // - // Enables SecretRef field in CSI NodeExpandVolume request. - CSINodeExpandSecret featuregate.Feature = "CSINodeExpandSecret" - - // owner: @pohly - // alpha: v1.19 - // beta: v1.21 - // GA: v1.24 - // - // Enables tracking of available storage capacity that CSI drivers provide. - CSIStorageCapacity featuregate.Feature = "CSIStorageCapacity" - - // owner: @fengzixu - // alpha: v1.21 - // - // Enables kubelet to detect CSI volume condition and send the event of the abnormal volume to the corresponding pod that is using it. - CSIVolumeHealth featuregate.Feature = "CSIVolumeHealth" - - // owner: @adrianreber - // kep: https://kep.k8s.io/2008 - // alpha: v1.25 - // - // Enables container Checkpoint support in the kubelet - ContainerCheckpoint featuregate.Feature = "ContainerCheckpoint" - - // owner: @bhcleek @wzshiming - // GA: v1.25 - // - // Normalize HttpGet URL and Header passing for lifecycle handlers with probers. - ConsistentHTTPGetHandlers featuregate.Feature = "ConsistentHTTPGetHandlers" - - // owner: @jiahuif - // alpha: v1.21 - // beta: v1.22 - // GA: v1.24 - // - // Enables Leader Migration for kube-controller-manager and cloud-controller-manager - ControllerManagerLeaderMigration featuregate.Feature = "ControllerManagerLeaderMigration" - - // owner: @deejross, @soltysh - // kep: https://kep.k8s.io/3140 - // alpha: v1.24 - // beta: v1.25 - // - // Enables support for time zones in CronJobs. - CronJobTimeZone featuregate.Feature = "CronJobTimeZone" - - // owner: @smarterclayton - // alpha: v1.21 - // beta: v1.22 - // GA: v1.25 - // DaemonSets allow workloads to maintain availability during update per node - DaemonSetUpdateSurge featuregate.Feature = "DaemonSetUpdateSurge" - - // owner: @gnufied, @verult, @bertinatto - // alpha: v1.22 - // beta: v1.23 - // GA: v1.26 - // If supported by the CSI driver, delegates the role of applying FSGroup to - // the driver by passing FSGroup through the NodeStageVolume and - // NodePublishVolume calls. - DelegateFSGroupToCSIDriver featuregate.Feature = "DelegateFSGroupToCSIDriver" - - // owner: @jiayingz, @swatisehgal (for GA graduation) - // alpha: v1.8 - // beta: v1.10 - // GA: v1.26 - // - // Enables support for Device Plugins - DevicePlugins featuregate.Feature = "DevicePlugins" - - // owner: @RenaudWasTaken @dashpole - // alpha: v1.19 - // beta: v1.20 - // ga: v1.25 - // - // Disables Accelerator Metrics Collected by Kubelet - DisableAcceleratorUsageMetrics featuregate.Feature = "DisableAcceleratorUsageMetrics" - - // owner: @andrewsykim - // alpha: v1.22 - // - // Disable any functionality in kube-apiserver, kube-controller-manager and kubelet related to the `--cloud-provider` component flag. - DisableCloudProviders featuregate.Feature = "DisableCloudProviders" - - // owner: @andrewsykim - // alpha: v1.23 - // - // Disable in-tree functionality in kubelet to authenticate to cloud provider container registries for image pull credentials. - DisableKubeletCloudCredentialProviders featuregate.Feature = "DisableKubeletCloudCredentialProviders" - - // owner: @derekwaynecarr - // alpha: v1.20 - // beta: v1.21 (off by default until 1.22) - // - // Enables usage of hugepages- in downward API. - DownwardAPIHugePages featuregate.Feature = "DownwardAPIHugePages" - - // owner: @pohly - // kep: http://kep.k8s.io/3063 - // alpha: v1.26 - // - // Enables support for resources with custom parameters and a lifecycle - // that is independent of a Pod. - DynamicResourceAllocation featuregate.Feature = "DynamicResourceAllocation" - - // owner: @andrewsykim - // kep: https://kep.k8s.io/1672 - // alpha: v1.20 - // beta: v1.22 - // GA: v1.26 - // - // Enable Terminating condition in Endpoint Slices. - EndpointSliceTerminatingCondition featuregate.Feature = "EndpointSliceTerminatingCondition" - - // owner: @verb - // alpha: v1.16 - // beta: v1.23 - // GA: v1.25 - // - // Allows running an ephemeral container in pod namespaces to troubleshoot a running pod. - EphemeralContainers featuregate.Feature = "EphemeralContainers" - - // owner: @harche - // kep: http://kep.k8s.io/3386 - // alpha: v1.25 - // - // Allows using event-driven PLEG (pod lifecycle event generator) through kubelet - // which avoids frequent relisting of containers which helps optimize performance. - EventedPLEG featuregate.Feature = "EventedPLEG" - - // owner: @andrewsykim @SergeyKanzhelev - // GA: v1.20 - // - // Ensure kubelet respects exec probe timeouts. Feature gate exists in-case existing workloads - // may depend on old behavior where exec probe timeouts were ignored. - // Lock to default and remove after v1.22 based on user feedback that should be reflected in KEP #1972 update - ExecProbeTimeout featuregate.Feature = "ExecProbeTimeout" - - // owner: @gnufied - // alpha: v1.14 - // beta: v1.16 - // GA: 1.24 - // Ability to expand CSI volumes - ExpandCSIVolumes featuregate.Feature = "ExpandCSIVolumes" - - // owner: @mlmhl @gnufied - // beta: v1.15 - // GA: 1.24 - // Ability to expand persistent volumes' file system without unmounting volumes. - ExpandInUsePersistentVolumes featuregate.Feature = "ExpandInUsePersistentVolumes" - - // owner: @gnufied - // beta: v1.11 - // GA: 1.24 - // Ability to Expand persistent volumes - ExpandPersistentVolumes featuregate.Feature = "ExpandPersistentVolumes" - - // owner: @gjkim42 - // kep: https://kep.k8s.io/2595 - // alpha: v1.22 - // beta: v1.26 - // - // Enables apiserver and kubelet to allow up to 32 DNSSearchPaths and up to 2048 DNSSearchListChars. - ExpandedDNSConfig featuregate.Feature = "ExpandedDNSConfig" - - // owner: @pweil- - // alpha: v1.5 - // - // Default userns=host for containers that are using other host namespaces, host mounts, the pod - // contains a privileged container, or specific non-namespaced capabilities (MKNOD, SYS_MODULE, - // SYS_TIME). This should only be enabled if user namespace remapping is enabled in the docker daemon. - ExperimentalHostUserNamespaceDefaultingGate featuregate.Feature = "ExperimentalHostUserNamespaceDefaulting" - - // owner: @yuzhiquan, @bowei, @PxyUp, @SergeyKanzhelev - // kep: https://kep.k8s.io/2727 - // alpha: v1.23 - // beta: v1.24 - // - // Enables GRPC probe method for {Liveness,Readiness,Startup}Probe. - GRPCContainerProbe featuregate.Feature = "GRPCContainerProbe" - - // owner: @bobbypage - // alpha: v1.20 - // beta: v1.21 - // Adds support for kubelet to detect node shutdown and gracefully terminate pods prior to the node being shutdown. - GracefulNodeShutdown featuregate.Feature = "GracefulNodeShutdown" - - // owner: @wzshiming - // alpha: v1.23 - // beta: v1.24 - // Make the kubelet use shutdown configuration based on pod priority values for graceful shutdown. - GracefulNodeShutdownBasedOnPodPriority featuregate.Feature = "GracefulNodeShutdownBasedOnPodPriority" - - // owner: @arjunrn @mwielgus @josephburnett - // alpha: v1.20 - // - // Add support for the HPA to scale based on metrics from individual containers - // in target pods - HPAContainerMetrics featuregate.Feature = "HPAContainerMetrics" - - // owner: @dxist - // alpha: v1.16 - // - // Enables support of HPA scaling to zero pods when an object or custom metric is configured. - HPAScaleToZero featuregate.Feature = "HPAScaleToZero" - - // owner: @deepakkinni @xing-yang - // kep: https://kep.k8s.io/2680 - // alpha: v1.23 - // - // Honor Persistent Volume Reclaim Policy when it is "Delete" irrespective of PV-PVC - // deletion ordering. - HonorPVReclaimPolicy featuregate.Feature = "HonorPVReclaimPolicy" - - // owner: @ravig - // alpha: v1.23 - // beta: v1.24 - // GA: v1.25 - // IdentifyPodOS allows user to specify OS on which they'd like the Pod run. The user should still set the nodeSelector - // with appropriate `kubernetes.io/os` label for scheduler to identify appropriate node for the pod to run. - IdentifyPodOS featuregate.Feature = "IdentifyPodOS" - - // owner: @leakingtapan - // alpha: v1.21 - // - // Disables the AWS EBS in-tree driver. - InTreePluginAWSUnregister featuregate.Feature = "InTreePluginAWSUnregister" - - // owner: @andyzhangx - // alpha: v1.21 - // - // Disables the Azure Disk in-tree driver. - InTreePluginAzureDiskUnregister featuregate.Feature = "InTreePluginAzureDiskUnregister" - - // owner: @andyzhangx - // alpha: v1.21 - // - // Disables the Azure File in-tree driver. - InTreePluginAzureFileUnregister featuregate.Feature = "InTreePluginAzureFileUnregister" - - // owner: @Jiawei0227 - // alpha: v1.21 - // - // Disables the GCE PD in-tree driver. - InTreePluginGCEUnregister featuregate.Feature = "InTreePluginGCEUnregister" - - // owner: @adisky - // alpha: v1.21 - // - // Disables the OpenStack Cinder in-tree driver. - InTreePluginOpenStackUnregister featuregate.Feature = "InTreePluginOpenStackUnregister" - - // owner: @trierra - // alpha: v1.23 - // - // Disables the Portworx in-tree driver. - InTreePluginPortworxUnregister featuregate.Feature = "InTreePluginPortworxUnregister" - - // owner: @humblec - // alpha: v1.23 - // - // Disables the RBD in-tree driver. - InTreePluginRBDUnregister featuregate.Feature = "InTreePluginRBDUnregister" - - // owner: @divyenpatel - // alpha: v1.21 - // - // Disables the vSphere in-tree driver. - InTreePluginvSphereUnregister featuregate.Feature = "InTreePluginvSphereUnregister" - - // owner: @danwinship - // kep: https://kep.k8s.io/3178 - // alpha: v1.25 - // - // Causes kubelet to no longer create legacy IPTables rules - IPTablesOwnershipCleanup featuregate.Feature = "IPTablesOwnershipCleanup" - - // owner: @mimowo - // kep: https://kep.k8s.io/3329 - // alpha: v1.25 - // beta: v1.26 - // - // Allow users to specify handling of pod failures based on container exit codes - // and pod conditions. - JobPodFailurePolicy featuregate.Feature = "JobPodFailurePolicy" - - // owner: @ahg - // beta: v1.23 - // - // Allow updating node scheduling directives in the pod template of jobs. Specifically, - // node affinity, selector and tolerations. This is allowed only for suspended jobs - // that have never been unsuspended before. - JobMutableNodeSchedulingDirectives featuregate.Feature = "JobMutableNodeSchedulingDirectives" - - // owner: @alculquicondor - // alpha: v1.23 - // beta: v1.24 - // - // Track the number of pods with Ready condition in the Job status. - JobReadyPods featuregate.Feature = "JobReadyPods" - - // owner: @alculquicondor - // alpha: v1.22 - // beta: v1.23 - // stable: v1.26 - // - // Track Job completion without relying on Pod remaining in the cluster - // indefinitely. Pod finalizers, in addition to a field in the Job status - // allow the Job controller to keep track of Pods that it didn't account for - // yet. - JobTrackingWithFinalizers featuregate.Feature = "JobTrackingWithFinalizers" - - // owner: @andrewsykim @adisky @ndixita - // alpha: v1.20 - // beta: v1.24 - // GA: v1.26 - // - // Enable kubelet exec plugins for image pull credentials. - KubeletCredentialProviders featuregate.Feature = "KubeletCredentialProviders" - - // owner: @AkihiroSuda - // alpha: v1.22 - // - // Enables support for running kubelet in a user namespace. - // The user namespace has to be created before running kubelet. - // All the node components such as CRI need to be running in the same user namespace. - KubeletInUserNamespace featuregate.Feature = "KubeletInUserNamespace" - - // owner: @dashpole - // alpha: v1.13 - // beta: v1.15 - // - // Enables the kubelet's pod resources grpc endpoint - KubeletPodResources featuregate.Feature = "KubeletPodResources" - - // owner: @fromanirh - // alpha: v1.21 - // beta: v1.23 - // Enable POD resources API to return allocatable resources - KubeletPodResourcesGetAllocatable featuregate.Feature = "KubeletPodResourcesGetAllocatable" - - // owner: @sallyom - // kep: https://kep.k8s.io/2832 - // alpha: v1.25 - // - // Add support for distributed tracing in the kubelet - KubeletTracing featuregate.Feature = "KubeletTracing" - - // owner: @zshihang - // kep: https://kep.k8s.io/2800 - // beta: v1.24 - // - // Stop auto-generation of secret-based service account tokens. - LegacyServiceAccountTokenNoAutoGeneration featuregate.Feature = "LegacyServiceAccountTokenNoAutoGeneration" - - // owner: @zshihang - // kep: http://kep.k8s.io/2800 - // alpha: v1.25 - // - // Enables tracking of secret-based service account tokens usage. - LegacyServiceAccountTokenTracking featuregate.Feature = "LegacyServiceAccountTokenTracking" - - // owner: @jinxu - // beta: v1.10 - // stable: v1.25 - // - // Support local ephemeral storage types for local storage capacity isolation feature. - LocalStorageCapacityIsolation featuregate.Feature = "LocalStorageCapacityIsolation" - - // owner: @RobertKrawitz - // alpha: v1.15 - // - // Allow use of filesystems for ephemeral storage monitoring. - // Only applies if LocalStorageCapacityIsolation is set. - LocalStorageCapacityIsolationFSQuotaMonitoring featuregate.Feature = "LocalStorageCapacityIsolationFSQuotaMonitoring" - - // owner: @damemi - // alpha: v1.21 - // beta: v1.22 - // - // Enables scaling down replicas via logarithmic comparison of creation/ready timestamps - LogarithmicScaleDown featuregate.Feature = "LogarithmicScaleDown" - - // owner: @denkensk - // kep: https://kep.k8s.io/3243 - // alpha: v1.25 - // - // Enable MatchLabelKeys in PodTopologySpread. - MatchLabelKeysInPodTopologySpread featuregate.Feature = "MatchLabelKeysInPodTopologySpread" - - // owner: @krmayankk - // alpha: v1.24 - // - // Enables maxUnavailable for StatefulSet - MaxUnavailableStatefulSet featuregate.Feature = "MaxUnavailableStatefulSet" - - // owner: @cynepco3hahue(alukiano) @cezaryzukowski @k-wiatrzyk - // alpha: v1.21 - // beta: v1.22 - // Allows setting memory affinity for a container based on NUMA topology - MemoryManager featuregate.Feature = "MemoryManager" - - // owner: @xiaoxubeii - // kep: https://kep.k8s.io/2570 - // alpha: v1.22 - // - // Enables kubelet to support memory QoS with cgroups v2. - MemoryQoS featuregate.Feature = "MemoryQoS" - - // owner: @sanposhiho - // kep: https://kep.k8s.io/3022 - // alpha: v1.24 - // beta: v1.25 - // - // Enable MinDomains in Pod Topology Spread. - MinDomainsInPodTopologySpread featuregate.Feature = "MinDomainsInPodTopologySpread" - - // owner: @danwinship - // kep: http://kep.k8s.io/3453 - // alpha: v1.26 - // - // Enables new performance-improving code in kube-proxy iptables mode - MinimizeIPTablesRestore featuregate.Feature = "MinimizeIPTablesRestore" - - // owner: @janosi @bridgetkromhout - // kep: https://kep.k8s.io/1435 - // alpha: v1.20 - // beta: v1.24 - // ga: v1.26 - // - // Enables the usage of different protocols in the same Service with type=LoadBalancer - MixedProtocolLBService featuregate.Feature = "MixedProtocolLBService" - - // owner: @sarveshr7 - // kep: https://kep.k8s.io/2593 - // alpha: v1.25 - // - // Enables the MultiCIDR Range allocator. - MultiCIDRRangeAllocator featuregate.Feature = "MultiCIDRRangeAllocator" - - // owner: @rikatz - // kep: https://kep.k8s.io/2079 - // alpha: v1.21 - // beta: v1.22 - // ga: v1.25 - // - // Enables the endPort field in NetworkPolicy to enable a Port Range behavior in Network Policies. - NetworkPolicyEndPort featuregate.Feature = "NetworkPolicyEndPort" - - // owner: @rikatz - // kep: https://kep.k8s.io/2943 - // alpha: v1.24 - // - // Enables NetworkPolicy status subresource - NetworkPolicyStatus featuregate.Feature = "NetworkPolicyStatus" - - // owner: @xing-yang @sonasingh46 - // kep: https://kep.k8s.io/2268 - // alpha: v1.24 - // beta: v1.26 - // - // Allow pods to failover to a different node in case of non graceful node shutdown - NodeOutOfServiceVolumeDetach featuregate.Feature = "NodeOutOfServiceVolumeDetach" - - // owner: @ehashman - // alpha: v1.22 - // - // Permits kubelet to run with swap enabled - NodeSwap featuregate.Feature = "NodeSwap" - - // owner: @mortent, @atiratree, @ravig - // kep: http://kep.k8s.io/3018 - // alpha: v1.26 - // - // Enables PDBUnhealthyPodEvictionPolicy for PodDisruptionBudgets - PDBUnhealthyPodEvictionPolicy featuregate.Feature = "PDBUnhealthyPodEvictionPolicy" - - // owner: @haircommander - // kep: https://kep.k8s.io/2364 - // alpha: v1.23 - // - // Configures the Kubelet to use the CRI to populate pod and container stats, instead of supplimenting with stats from cAdvisor. - // Requires the CRI implementation supports supplying the required stats. - PodAndContainerStatsFromCRI featuregate.Feature = "PodAndContainerStatsFromCRI" - - // owner: @ahg-g - // alpha: v1.21 - // beta: v1.22 - // - // Enables controlling pod ranking on replicaset scale-down. - PodDeletionCost featuregate.Feature = "PodDeletionCost" - - // owner: @mimowo - // kep: https://kep.k8s.io/3329 - // alpha: v1.25 - // beta: v1.26 - // - // Enables support for appending a dedicated pod condition indicating that - // the pod is being deleted due to a disruption. - PodDisruptionConditions featuregate.Feature = "PodDisruptionConditions" - - // owner: @ddebroy - // alpha: v1.25 - // - // Enables reporting of PodHasNetwork condition in pod status after pod - // sandbox creation and network configuration completes successfully - PodHasNetworkCondition featuregate.Feature = "PodHasNetworkCondition" - - // owner: @Huang-Wei - // kep: https://kep.k8s.io/3521 - // alpha: v1.26 - // - // Enable users to specify when a Pod is ready for scheduling. - PodSchedulingReadiness featuregate.Feature = "PodSchedulingReadiness" - - // owner: @liggitt, @tallclair, sig-auth - // alpha: v1.22 - // beta: v1.23 - // ga: v1.25 - // - // Enables the PodSecurity admission plugin - PodSecurity featuregate.Feature = "PodSecurity" - - // owner: @ehashman - // alpha: v1.21 - // beta: v1.22 - // - // Allows user to override pod-level terminationGracePeriod for probes - ProbeTerminationGracePeriod featuregate.Feature = "ProbeTerminationGracePeriod" - - // owner: @jessfraz - // alpha: v1.12 - // - // Enables control over ProcMountType for containers. - ProcMountType featuregate.Feature = "ProcMountType" - - // owner: @andrewsykim - // kep: https://kep.k8s.io/1669 - // alpha: v1.22 - // beta: v1.26 - // - // Enable kube-proxy to handle terminating ednpoints when externalTrafficPolicy=Local - ProxyTerminatingEndpoints featuregate.Feature = "ProxyTerminatingEndpoints" - - // owner: @sjenning - // alpha: v1.11 - // - // Allows resource reservations at the QoS level preventing pods at lower QoS levels from - // bursting into resources requested at higher QoS levels (memory only for now) - QOSReserved featuregate.Feature = "QOSReserved" - - // owner: @chrishenzie - // alpha: v1.22 - // - // Enables usage of the ReadWriteOncePod PersistentVolume access mode. - ReadWriteOncePod featuregate.Feature = "ReadWriteOncePod" - - // owner: @gnufied - // kep: https://kep.k8s.io/1790 - // alpha: v1.23 - // - // Allow users to recover from volume expansion failure - RecoverVolumeExpansionFailure featuregate.Feature = "RecoverVolumeExpansionFailure" - - // owner: @RomanBednar - // kep: https://kep.k8s.io/3333 - // alpha: v1.25 - // - // Allow assigning StorageClass to unbound PVCs retroactively - RetroactiveDefaultStorageClass featuregate.Feature = "RetroactiveDefaultStorageClass" - - // owner: @mikedanese - // alpha: v1.7 - // beta: v1.12 - // - // Gets a server certificate for the kubelet from the Certificate Signing - // Request API instead of generating one self signed and auto rotates the - // certificate as expiration approaches. - RotateKubeletServerCertificate featuregate.Feature = "RotateKubeletServerCertificate" - - // owner: @saschagrunert - // kep: https://kep.k8s.io/2413 - // alpha: v1.22 - // beta: v1.25 - // - // Enables the use of `RuntimeDefault` as the default seccomp profile for all workloads. - SeccompDefault featuregate.Feature = "SeccompDefault" - - // owner: @maplain @andrewsykim - // kep: https://kep.k8s.io/2086 - // alpha: v1.21 - // beta: v1.22 - // GA: v1.26 - // - // Enables node-local routing for Service internal traffic - ServiceInternalTrafficPolicy featuregate.Feature = "ServiceInternalTrafficPolicy" - - // owner: @aojea - // kep: https://kep.k8s.io/3070 - // alpha: v1.24 - // beta: v1.25 - // ga: v1.26 - // - // Subdivide the ClusterIP range for dynamic and static IP allocation. - ServiceIPStaticSubrange featuregate.Feature = "ServiceIPStaticSubrange" - - // owner: @derekwaynecarr - // alpha: v1.20 - // beta: v1.22 - // - // Enables kubelet support to size memory backed volumes - SizeMemoryBackedVolumes featuregate.Feature = "SizeMemoryBackedVolumes" - - // owner: @mattcary - // alpha: v1.22 - // - // Enables policies controlling deletion of PVCs created by a StatefulSet. - StatefulSetAutoDeletePVC featuregate.Feature = "StatefulSetAutoDeletePVC" - - // owner: @ravig - // kep: https://kep.k8s.io/2607 - // alpha: v1.22 - // beta: v1.23 - // GA: v1.25 - // StatefulSetMinReadySeconds allows minReadySeconds to be respected by StatefulSet controller - StatefulSetMinReadySeconds featuregate.Feature = "StatefulSetMinReadySeconds" - - // owner: @psch - // alpha: v1.26 - // - // Enables a StatefulSet to start from an arbitrary non zero ordinal - StatefulSetStartOrdinal featuregate.Feature = "StatefulSetStartOrdinal" - - // owner: @robscott - // kep: https://kep.k8s.io/2433 - // alpha: v1.21 - // beta: v1.23 - // - // Enables topology aware hints for EndpointSlices - TopologyAwareHints featuregate.Feature = "TopologyAwareHints" - - // owner: @lmdaly - // alpha: v1.16 - // beta: v1.18 - // - // Enable resource managers to make NUMA aligned decisions - TopologyManager featuregate.Feature = "TopologyManager" - - // owner: @PiotrProkop - // kep: https://kep.k8s.io/3545 - // alpha: v1.26 - // - // Allow fine-tuning of topology manager policies with alpha options. - // This feature gate: - // - will guard *a group* of topology manager options whose quality level is alpha. - // - will never graduate to beta or stable. - TopologyManagerPolicyAlphaOptions featuregate.Feature = "TopologyManagerPolicyAlphaOptions" - - // owner: @PiotrProkop - // kep: https://kep.k8s.io/3545 - // alpha: v1.26 - // - // Allow fine-tuning of topology manager policies with beta options. - // This feature gate: - // - will guard *a group* of topology manager options whose quality level is beta. - // - is thus *introduced* as beta - // - will never graduate to stable. - TopologyManagerPolicyBetaOptions featuregate.Feature = "TopologyManagerPolicyBetaOptions" - - // owner: @PiotrProkop - // kep: https://kep.k8s.io/3545 - // alpha: v1.26 - // - // Allow the usage of options to fine-tune the topology manager policies. - TopologyManagerPolicyOptions featuregate.Feature = "TopologyManagerPolicyOptions" - - // owner: @rata, @giuseppe - // kep: https://kep.k8s.io/127 - // alpha: v1.25 - // - // Enables user namespace support for stateless pods. - UserNamespacesStatelessPodsSupport featuregate.Feature = "UserNamespacesStatelessPodsSupport" - - // owner: @cofyc - // alpha: v1.21 - VolumeCapacityPriority featuregate.Feature = "VolumeCapacityPriority" - - // owner: @ksubrmnn - // alpha: v1.14 - // - // Allows kube-proxy to create DSR loadbalancers for Windows - WinDSR featuregate.Feature = "WinDSR" - - // owner: @ksubrmnn - // alpha: v1.14 - // beta: v1.20 - // - // Allows kube-proxy to run in Overlay mode for Windows - WinOverlay featuregate.Feature = "WinOverlay" - - // owner: @marosset - // kep: https://kep.k8s.io/3503 - // alpha: v1.26 - // - // Enables support for joining Windows containers to a hosts' network namespace. - WindowsHostNetwork featuregate.Feature = "WindowsHostNetwork" - - // owner: @marosset - // alpha: v1.22 - // beta: v1.23 - // GA: v1.26 - // - // Enables support for 'HostProcess' containers on Windows nodes. - WindowsHostProcessContainers featuregate.Feature = "WindowsHostProcessContainers" - - // owner: @kerthcet - // kep: https://kep.k8s.io/3094 - // alpha: v1.25 - // beta: v1.26 - // - // Allow users to specify whether to take nodeAffinity/nodeTaint into consideration when - // calculating pod topology spread skew. - NodeInclusionPolicyInPodTopologySpread featuregate.Feature = "NodeInclusionPolicyInPodTopologySpread" - - // owner: @jsafrane - // kep: https://kep.k8s.io/1710 - // alpha: v1.25 - // Speed up container startup by mounting volumes with the correct SELinux label - // instead of changing each file on the volumes recursively. - // Initial implementation focused on ReadWriteOncePod volumes. - SELinuxMountReadWriteOncePod featuregate.Feature = "SELinuxMountReadWriteOncePod" -) - -func init() { - runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)) -} - -// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys. -// To add a new feature, define a key for it above and add it here. The features will be -// available throughout Kubernetes binaries. -// -// Entries are separated from each other with blank lines to avoid sweeping gofmt changes -// when adding or removing one entry. -var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ - CrossNamespaceVolumeDataSource: {Default: false, PreRelease: featuregate.Alpha}, - - AnyVolumeDataSource: {Default: true, PreRelease: featuregate.Beta}, // on by default in 1.24 - - APISelfSubjectReview: {Default: false, PreRelease: featuregate.Alpha}, - - AppArmor: {Default: true, PreRelease: featuregate.Beta}, - - CPUCFSQuotaPeriod: {Default: false, PreRelease: featuregate.Alpha}, - - CPUManager: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // GA in 1.26 - - CPUManagerPolicyAlphaOptions: {Default: false, PreRelease: featuregate.Alpha}, - - CPUManagerPolicyBetaOptions: {Default: true, PreRelease: featuregate.Beta}, - - CPUManagerPolicyOptions: {Default: true, PreRelease: featuregate.Beta}, - - CSIInlineVolume: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - CSIMigration: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - CSIMigrationAWS: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - CSIMigrationAzureDisk: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26 - - CSIMigrationAzureFile: {Default: true, PreRelease: featuregate.GA}, // remove in 1.28 - - CSIMigrationGCE: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - CSIMigrationPortworx: {Default: false, PreRelease: featuregate.Beta}, // Off by default (requires Portworx CSI driver) - - CSIMigrationRBD: {Default: false, PreRelease: featuregate.Alpha}, // Off by default (requires RBD CSI driver) - - CSIMigrationvSphere: {Default: true, PreRelease: featuregate.GA}, // LockToDefault when CSI driver with GA support for Windows, raw block and xfs features are available - - CSINodeExpandSecret: {Default: false, PreRelease: featuregate.Alpha}, - - CSIStorageCapacity: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26 - - CSIVolumeHealth: {Default: false, PreRelease: featuregate.Alpha}, - - ContainerCheckpoint: {Default: false, PreRelease: featuregate.Alpha}, - - ConsistentHTTPGetHandlers: {Default: true, PreRelease: featuregate.GA}, - - ControllerManagerLeaderMigration: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26 - - CronJobTimeZone: {Default: true, PreRelease: featuregate.Beta}, - - DaemonSetUpdateSurge: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - DelegateFSGroupToCSIDriver: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - DevicePlugins: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // GA in 1.26 - - DisableAcceleratorUsageMetrics: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, - - DisableCloudProviders: {Default: false, PreRelease: featuregate.Alpha}, - - DisableKubeletCloudCredentialProviders: {Default: false, PreRelease: featuregate.Alpha}, - - DownwardAPIHugePages: {Default: true, PreRelease: featuregate.Beta}, // on by default in 1.22 - - EndpointSliceTerminatingCondition: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in v1.28 - - DynamicResourceAllocation: {Default: false, PreRelease: featuregate.Alpha}, - - EphemeralContainers: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - EventedPLEG: {Default: false, PreRelease: featuregate.Alpha}, - - ExecProbeTimeout: {Default: true, PreRelease: featuregate.GA}, // lock to default and remove after v1.22 based on KEP #1972 update - - ExpandCSIVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.26 - - ExpandInUsePersistentVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.26 - - ExpandPersistentVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.26 - - ExpandedDNSConfig: {Default: true, PreRelease: featuregate.Beta}, - - ExperimentalHostUserNamespaceDefaultingGate: {Default: false, PreRelease: featuregate.Beta}, - - GRPCContainerProbe: {Default: true, PreRelease: featuregate.Beta}, - - GracefulNodeShutdown: {Default: true, PreRelease: featuregate.Beta}, - - GracefulNodeShutdownBasedOnPodPriority: {Default: true, PreRelease: featuregate.Beta}, - - HPAContainerMetrics: {Default: false, PreRelease: featuregate.Alpha}, - - HonorPVReclaimPolicy: {Default: false, PreRelease: featuregate.Alpha}, - - IdentifyPodOS: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - InTreePluginAWSUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginAzureDiskUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginAzureFileUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginGCEUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginOpenStackUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginPortworxUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginRBDUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - InTreePluginvSphereUnregister: {Default: false, PreRelease: featuregate.Alpha}, - - IPTablesOwnershipCleanup: {Default: false, PreRelease: featuregate.Alpha}, - - JobPodFailurePolicy: {Default: true, PreRelease: featuregate.Beta}, - - JobMutableNodeSchedulingDirectives: {Default: true, PreRelease: featuregate.Beta}, - - JobReadyPods: {Default: true, PreRelease: featuregate.Beta}, - - JobTrackingWithFinalizers: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - KubeletCredentialProviders: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - KubeletInUserNamespace: {Default: false, PreRelease: featuregate.Alpha}, - - KubeletPodResources: {Default: true, PreRelease: featuregate.Beta}, - - KubeletPodResourcesGetAllocatable: {Default: true, PreRelease: featuregate.Beta}, - - KubeletTracing: {Default: false, PreRelease: featuregate.Alpha}, - - LegacyServiceAccountTokenNoAutoGeneration: {Default: true, PreRelease: featuregate.GA}, - - LegacyServiceAccountTokenTracking: {Default: false, PreRelease: featuregate.Alpha}, - - LocalStorageCapacityIsolation: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - LocalStorageCapacityIsolationFSQuotaMonitoring: {Default: false, PreRelease: featuregate.Alpha}, - - LogarithmicScaleDown: {Default: true, PreRelease: featuregate.Beta}, - - MatchLabelKeysInPodTopologySpread: {Default: false, PreRelease: featuregate.Alpha}, - - MaxUnavailableStatefulSet: {Default: false, PreRelease: featuregate.Alpha}, - - MemoryManager: {Default: true, PreRelease: featuregate.Beta}, - - MemoryQoS: {Default: false, PreRelease: featuregate.Alpha}, - - MinDomainsInPodTopologySpread: {Default: false, PreRelease: featuregate.Beta}, - - MinimizeIPTablesRestore: {Default: false, PreRelease: featuregate.Alpha}, - - MixedProtocolLBService: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - MultiCIDRRangeAllocator: {Default: false, PreRelease: featuregate.Alpha}, - - NetworkPolicyEndPort: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - NetworkPolicyStatus: {Default: false, PreRelease: featuregate.Alpha}, - - NodeOutOfServiceVolumeDetach: {Default: true, PreRelease: featuregate.Beta}, - - NodeSwap: {Default: false, PreRelease: featuregate.Alpha}, - - PDBUnhealthyPodEvictionPolicy: {Default: false, PreRelease: featuregate.Alpha}, - - PodAndContainerStatsFromCRI: {Default: false, PreRelease: featuregate.Alpha}, - - PodDeletionCost: {Default: true, PreRelease: featuregate.Beta}, - - PodDisruptionConditions: {Default: true, PreRelease: featuregate.Beta}, - - PodHasNetworkCondition: {Default: false, PreRelease: featuregate.Alpha}, - - PodSchedulingReadiness: {Default: false, PreRelease: featuregate.Alpha}, - - PodSecurity: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, - - ProbeTerminationGracePeriod: {Default: true, PreRelease: featuregate.Beta}, // Default to true in beta 1.25 - - ProcMountType: {Default: false, PreRelease: featuregate.Alpha}, - - ProxyTerminatingEndpoints: {Default: true, PreRelease: featuregate.Beta}, - - QOSReserved: {Default: false, PreRelease: featuregate.Alpha}, - - ReadWriteOncePod: {Default: false, PreRelease: featuregate.Alpha}, - - RecoverVolumeExpansionFailure: {Default: false, PreRelease: featuregate.Alpha}, - - RetroactiveDefaultStorageClass: {Default: true, PreRelease: featuregate.Beta}, - - RotateKubeletServerCertificate: {Default: true, PreRelease: featuregate.Beta}, - - SeccompDefault: {Default: true, PreRelease: featuregate.Beta}, - - ServiceIPStaticSubrange: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - ServiceInternalTrafficPolicy: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - SizeMemoryBackedVolumes: {Default: true, PreRelease: featuregate.Beta}, - - StatefulSetAutoDeletePVC: {Default: false, PreRelease: featuregate.Alpha}, - - StatefulSetMinReadySeconds: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.27 - - StatefulSetStartOrdinal: {Default: false, PreRelease: featuregate.Alpha}, - - TopologyAwareHints: {Default: true, PreRelease: featuregate.Beta}, - - TopologyManager: {Default: true, PreRelease: featuregate.Beta}, - - TopologyManagerPolicyAlphaOptions: {Default: false, PreRelease: featuregate.Alpha}, - - TopologyManagerPolicyBetaOptions: {Default: false, PreRelease: featuregate.Beta}, - - TopologyManagerPolicyOptions: {Default: false, PreRelease: featuregate.Alpha}, - - VolumeCapacityPriority: {Default: false, PreRelease: featuregate.Alpha}, - - UserNamespacesStatelessPodsSupport: {Default: false, PreRelease: featuregate.Alpha}, - - WinDSR: {Default: false, PreRelease: featuregate.Alpha}, - - WinOverlay: {Default: true, PreRelease: featuregate.Beta}, - - WindowsHostNetwork: {Default: true, PreRelease: featuregate.Alpha}, - - WindowsHostProcessContainers: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - NodeInclusionPolicyInPodTopologySpread: {Default: true, PreRelease: featuregate.Beta}, - - SELinuxMountReadWriteOncePod: {Default: false, PreRelease: featuregate.Alpha}, - - // inherited features from generic apiserver, relisted here to get a conflict if it is changed - // unintentionally on either side: - - genericfeatures.AggregatedDiscoveryEndpoint: {Default: false, PreRelease: featuregate.Alpha}, - - genericfeatures.APIListChunking: {Default: true, PreRelease: featuregate.Beta}, - - genericfeatures.APIPriorityAndFairness: {Default: true, PreRelease: featuregate.Beta}, - - genericfeatures.APIResponseCompression: {Default: true, PreRelease: featuregate.Beta}, - - genericfeatures.AdvancedAuditing: {Default: true, PreRelease: featuregate.GA}, - - genericfeatures.ValidatingAdmissionPolicy: {Default: false, PreRelease: featuregate.Alpha}, - - genericfeatures.CustomResourceValidationExpressions: {Default: true, PreRelease: featuregate.Beta}, - - genericfeatures.DryRun: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.28 - - genericfeatures.OpenAPIEnums: {Default: true, PreRelease: featuregate.Beta}, - - genericfeatures.OpenAPIV3: {Default: true, PreRelease: featuregate.Beta}, - - genericfeatures.ServerSideApply: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.29 - - genericfeatures.ServerSideFieldValidation: {Default: true, PreRelease: featuregate.Beta}, - - // features that enable backwards compatibility but are scheduled to be removed - // ... - HPAScaleToZero: {Default: false, PreRelease: featuregate.Alpha}, -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/client.go b/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/client.go deleted file mode 100644 index fcc6f1b90..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/client.go +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package podresources - -import ( - "context" - "fmt" - "time" - - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "k8s.io/kubelet/pkg/apis/podresources/v1" - "k8s.io/kubelet/pkg/apis/podresources/v1alpha1" - "k8s.io/kubernetes/pkg/kubelet/util" -) - -// Note: Consumers of the pod resources API should not be importing this package. -// They should copy paste the function in their project. - -// GetV1alpha1Client returns a client for the PodResourcesLister grpc service -// Note: This is deprecated -func GetV1alpha1Client(socket string, connectionTimeout time.Duration, maxMsgSize int) (v1alpha1.PodResourcesListerClient, *grpc.ClientConn, error) { - addr, dialer, err := util.GetAddressAndDialer(socket) - if err != nil { - return nil, nil, err - } - ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout) - defer cancel() - - conn, err := grpc.DialContext(ctx, addr, - grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithContextDialer(dialer), - grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize))) - if err != nil { - return nil, nil, fmt.Errorf("error dialing socket %s: %v", socket, err) - } - return v1alpha1.NewPodResourcesListerClient(conn), conn, nil -} - -// GetV1Client returns a client for the PodResourcesLister grpc service -func GetV1Client(socket string, connectionTimeout time.Duration, maxMsgSize int) (v1.PodResourcesListerClient, *grpc.ClientConn, error) { - addr, dialer, err := util.GetAddressAndDialer(socket) - if err != nil { - return nil, nil, err - } - ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout) - defer cancel() - - conn, err := grpc.DialContext(ctx, addr, - grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithContextDialer(dialer), - grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize))) - if err != nil { - return nil, nil, fmt.Errorf("error dialing socket %s: %v", socket, err) - } - return v1.NewPodResourcesListerClient(conn), conn, nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/constants.go b/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/constants.go deleted file mode 100644 index 6cc4c6a26..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/constants.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package podresources - -const ( - // Socket is the name of the podresources server socket - Socket = "kubelet" -) diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/server_v1.go b/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/server_v1.go deleted file mode 100644 index 948aa6c91..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/server_v1.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package podresources - -import ( - "context" - "fmt" - - utilfeature "k8s.io/apiserver/pkg/util/feature" - kubefeatures "k8s.io/kubernetes/pkg/features" - "k8s.io/kubernetes/pkg/kubelet/metrics" - - "k8s.io/kubelet/pkg/apis/podresources/v1" -) - -// podResourcesServerV1alpha1 implements PodResourcesListerServer -type v1PodResourcesServer struct { - podsProvider PodsProvider - devicesProvider DevicesProvider - cpusProvider CPUsProvider - memoryProvider MemoryProvider -} - -// NewV1PodResourcesServer returns a PodResourcesListerServer which lists pods provided by the PodsProvider -// with device information provided by the DevicesProvider -func NewV1PodResourcesServer(podsProvider PodsProvider, devicesProvider DevicesProvider, cpusProvider CPUsProvider, memoryProvider MemoryProvider) v1.PodResourcesListerServer { - return &v1PodResourcesServer{ - podsProvider: podsProvider, - devicesProvider: devicesProvider, - cpusProvider: cpusProvider, - memoryProvider: memoryProvider, - } -} - -// List returns information about the resources assigned to pods on the node -func (p *v1PodResourcesServer) List(ctx context.Context, req *v1.ListPodResourcesRequest) (*v1.ListPodResourcesResponse, error) { - metrics.PodResourcesEndpointRequestsTotalCount.WithLabelValues("v1").Inc() - metrics.PodResourcesEndpointRequestsListCount.WithLabelValues("v1").Inc() - - pods := p.podsProvider.GetPods() - podResources := make([]*v1.PodResources, len(pods)) - p.devicesProvider.UpdateAllocatedDevices() - - for i, pod := range pods { - pRes := v1.PodResources{ - Name: pod.Name, - Namespace: pod.Namespace, - Containers: make([]*v1.ContainerResources, len(pod.Spec.Containers)), - } - - for j, container := range pod.Spec.Containers { - pRes.Containers[j] = &v1.ContainerResources{ - Name: container.Name, - Devices: p.devicesProvider.GetDevices(string(pod.UID), container.Name), - CpuIds: p.cpusProvider.GetCPUs(string(pod.UID), container.Name), - Memory: p.memoryProvider.GetMemory(string(pod.UID), container.Name), - } - } - podResources[i] = &pRes - } - - return &v1.ListPodResourcesResponse{ - PodResources: podResources, - }, nil -} - -// GetAllocatableResources returns information about all the resources known by the server - this more like the capacity, not like the current amount of free resources. -func (p *v1PodResourcesServer) GetAllocatableResources(ctx context.Context, req *v1.AllocatableResourcesRequest) (*v1.AllocatableResourcesResponse, error) { - metrics.PodResourcesEndpointRequestsTotalCount.WithLabelValues("v1").Inc() - metrics.PodResourcesEndpointRequestsGetAllocatableCount.WithLabelValues("v1").Inc() - - if !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.KubeletPodResourcesGetAllocatable) { - metrics.PodResourcesEndpointErrorsGetAllocatableCount.WithLabelValues("v1").Inc() - return nil, fmt.Errorf("Pod Resources API GetAllocatableResources disabled") - } - - metrics.PodResourcesEndpointRequestsTotalCount.WithLabelValues("v1").Inc() - - return &v1.AllocatableResourcesResponse{ - Devices: p.devicesProvider.GetAllocatableDevices(), - CpuIds: p.cpusProvider.GetAllocatableCPUs(), - Memory: p.memoryProvider.GetAllocatableMemory(), - }, nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/server_v1alpha1.go b/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/server_v1alpha1.go deleted file mode 100644 index baacd2722..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/server_v1alpha1.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package podresources - -import ( - "context" - - "k8s.io/kubernetes/pkg/kubelet/metrics" - - "k8s.io/kubelet/pkg/apis/podresources/v1" - "k8s.io/kubelet/pkg/apis/podresources/v1alpha1" -) - -// podResourcesServerV1alpha1 implements PodResourcesListerServer -type v1alpha1PodResourcesServer struct { - podsProvider PodsProvider - devicesProvider DevicesProvider -} - -// NewV1alpha1PodResourcesServer returns a PodResourcesListerServer which lists pods provided by the PodsProvider -// with device information provided by the DevicesProvider -func NewV1alpha1PodResourcesServer(podsProvider PodsProvider, devicesProvider DevicesProvider) v1alpha1.PodResourcesListerServer { - return &v1alpha1PodResourcesServer{ - podsProvider: podsProvider, - devicesProvider: devicesProvider, - } -} - -func v1DevicesToAlphaV1(alphaDevs []*v1.ContainerDevices) []*v1alpha1.ContainerDevices { - var devs []*v1alpha1.ContainerDevices - for _, alphaDev := range alphaDevs { - dev := v1alpha1.ContainerDevices{ - ResourceName: alphaDev.ResourceName, - DeviceIds: alphaDev.DeviceIds, - } - devs = append(devs, &dev) - } - - return devs -} - -// List returns information about the resources assigned to pods on the node -func (p *v1alpha1PodResourcesServer) List(ctx context.Context, req *v1alpha1.ListPodResourcesRequest) (*v1alpha1.ListPodResourcesResponse, error) { - metrics.PodResourcesEndpointRequestsTotalCount.WithLabelValues("v1alpha1").Inc() - pods := p.podsProvider.GetPods() - podResources := make([]*v1alpha1.PodResources, len(pods)) - p.devicesProvider.UpdateAllocatedDevices() - - for i, pod := range pods { - pRes := v1alpha1.PodResources{ - Name: pod.Name, - Namespace: pod.Namespace, - Containers: make([]*v1alpha1.ContainerResources, len(pod.Spec.Containers)), - } - - for j, container := range pod.Spec.Containers { - pRes.Containers[j] = &v1alpha1.ContainerResources{ - Name: container.Name, - Devices: v1DevicesToAlphaV1(p.devicesProvider.GetDevices(string(pod.UID), container.Name)), - } - } - podResources[i] = &pRes - } - - return &v1alpha1.ListPodResourcesResponse{ - PodResources: podResources, - }, nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/types.go b/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/types.go deleted file mode 100644 index b6011d129..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/apis/podresources/types.go +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -//go:generate mockgen -source=types.go -destination=testing/provider_mock.go -package=testing DevicesProvider,PodsProvider,CPUsProvider,MemoryProvider -package podresources - -import ( - v1 "k8s.io/api/core/v1" - podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1" -) - -// DevicesProvider knows how to provide the devices used by the given container -type DevicesProvider interface { - // UpdateAllocatedDevices frees any Devices that are bound to terminated pods. - UpdateAllocatedDevices() - // GetDevices returns information about the devices assigned to pods and containers - GetDevices(podUID, containerName string) []*podresourcesapi.ContainerDevices - // GetAllocatableDevices returns information about all the devices known to the manager - GetAllocatableDevices() []*podresourcesapi.ContainerDevices -} - -// PodsProvider knows how to provide the pods admitted by the node -type PodsProvider interface { - GetPods() []*v1.Pod -} - -// CPUsProvider knows how to provide the cpus used by the given container -type CPUsProvider interface { - // GetCPUs returns information about the cpus assigned to pods and containers - GetCPUs(podUID, containerName string) []int64 - // GetAllocatableCPUs returns the allocatable (not allocated) CPUs - GetAllocatableCPUs() []int64 -} - -type MemoryProvider interface { - // GetMemory returns information about the memory assigned to containers - GetMemory(podUID, containerName string) []*podresourcesapi.ContainerMemory - // GetAllocatableMemory returns the allocatable memory from the node - GetAllocatableMemory() []*podresourcesapi.ContainerMemory -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/metrics/OWNERS b/vendor/k8s.io/kubernetes/pkg/kubelet/metrics/OWNERS deleted file mode 100644 index 4971e7564..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/metrics/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners -approvers: - - dashpole diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/metrics/metrics.go b/vendor/k8s.io/kubernetes/pkg/kubelet/metrics/metrics.go deleted file mode 100644 index fe8d3c00c..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/metrics/metrics.go +++ /dev/null @@ -1,633 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package metrics - -import ( - "sync" - "time" - - "k8s.io/component-base/metrics" - "k8s.io/component-base/metrics/legacyregistry" - - "k8s.io/apimachinery/pkg/types" - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/kubernetes/pkg/features" -) - -// This const block defines the metric names for the kubelet metrics. -const ( - KubeletSubsystem = "kubelet" - NodeNameKey = "node_name" - NodeLabelKey = "node" - PodWorkerDurationKey = "pod_worker_duration_seconds" - PodStartDurationKey = "pod_start_duration_seconds" - PodStartSLIDurationKey = "pod_start_sli_duration_seconds" - CgroupManagerOperationsKey = "cgroup_manager_duration_seconds" - PodWorkerStartDurationKey = "pod_worker_start_duration_seconds" - PodStatusSyncDurationKey = "pod_status_sync_duration_seconds" - PLEGRelistDurationKey = "pleg_relist_duration_seconds" - PLEGDiscardEventsKey = "pleg_discard_events" - PLEGRelistIntervalKey = "pleg_relist_interval_seconds" - PLEGLastSeenKey = "pleg_last_seen_seconds" - EvictionsKey = "evictions" - EvictionStatsAgeKey = "eviction_stats_age_seconds" - PreemptionsKey = "preemptions" - VolumeStatsCapacityBytesKey = "volume_stats_capacity_bytes" - VolumeStatsAvailableBytesKey = "volume_stats_available_bytes" - VolumeStatsUsedBytesKey = "volume_stats_used_bytes" - VolumeStatsInodesKey = "volume_stats_inodes" - VolumeStatsInodesFreeKey = "volume_stats_inodes_free" - VolumeStatsInodesUsedKey = "volume_stats_inodes_used" - VolumeStatsHealthStatusAbnormalKey = "volume_stats_health_status_abnormal" - RunningPodsKey = "running_pods" - RunningContainersKey = "running_containers" - - // Metrics keys of remote runtime operations - RuntimeOperationsKey = "runtime_operations_total" - RuntimeOperationsDurationKey = "runtime_operations_duration_seconds" - RuntimeOperationsErrorsKey = "runtime_operations_errors_total" - // Metrics keys of device plugin operations - DevicePluginRegistrationCountKey = "device_plugin_registration_total" - DevicePluginAllocationDurationKey = "device_plugin_alloc_duration_seconds" - // Metrics keys of pod resources operations - PodResourcesEndpointRequestsTotalKey = "pod_resources_endpoint_requests_total" - PodResourcesEndpointRequestsListKey = "pod_resources_endpoint_requests_list" - PodResourcesEndpointRequestsGetAllocatableKey = "pod_resources_endpoint_requests_get_allocatable" - PodResourcesEndpointErrorsListKey = "pod_resources_endpoint_errors_list" - PodResourcesEndpointErrorsGetAllocatableKey = "pod_resources_endpoint_errors_get_allocatable" - - // Metrics keys for RuntimeClass - RunPodSandboxDurationKey = "run_podsandbox_duration_seconds" - RunPodSandboxErrorsKey = "run_podsandbox_errors_total" - - // Metrics to keep track of total number of Pods and Containers started - StartedPodsTotalKey = "started_pods_total" - StartedPodsErrorsTotalKey = "started_pods_errors_total" - StartedContainersTotalKey = "started_containers_total" - StartedContainersErrorsTotalKey = "started_containers_errors_total" - - // Metrics to track HostProcess container usage by this kubelet - StartedHostProcessContainersTotalKey = "started_host_process_containers_total" - StartedHostProcessContainersErrorsTotalKey = "started_host_process_containers_errors_total" - - // Metrics to track ephemeral container usage by this kubelet - ManagedEphemeralContainersKey = "managed_ephemeral_containers" - - // Metrics to track the CPU manager behavior - CPUManagerPinningRequestsTotalKey = "cpu_manager_pinning_requests_total" - CPUManagerPinningErrorsTotalKey = "cpu_manager_pinning_errors_total" - - // Values used in metric labels - Container = "container" - InitContainer = "init_container" - EphemeralContainer = "ephemeral_container" -) - -var ( - // NodeName is a Gauge that tracks the ode's name. The count is always 1. - NodeName = metrics.NewGaugeVec( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: NodeNameKey, - Help: "The node's name. The count is always 1.", - StabilityLevel: metrics.ALPHA, - }, - []string{NodeLabelKey}, - ) - // ContainersPerPodCount is a Histogram that tracks the number of containers per pod. - ContainersPerPodCount = metrics.NewHistogram( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: "containers_per_pod_count", - Help: "The number of containers per pod.", - Buckets: metrics.ExponentialBuckets(1, 2, 5), - StabilityLevel: metrics.ALPHA, - }, - ) - // PodWorkerDuration is a Histogram that tracks the duration (in seconds) in takes to sync a single pod. - // Broken down by the operation type. - PodWorkerDuration = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodWorkerDurationKey, - Help: "Duration in seconds to sync a single pod. Broken down by operation type: create, update, or sync", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - []string{"operation_type"}, - ) - // PodStartDuration is a Histogram that tracks the duration (in seconds) it takes for a single pod to run since it's - // first time seen by kubelet. - PodStartDuration = metrics.NewHistogram( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodStartDurationKey, - Help: "Duration in seconds from kubelet seeing a pod for the first time to the pod starting to run", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - ) - // PodStartSLIDuration is a Histogram that tracks the duration (in seconds) it takes for a single pod to run, - // excluding the time for image pulling. This metric should reflect the "Pod startup latency SLI" definition - // ref: https://github.com/kubernetes/community/blob/master/sig-scalability/slos/pod_startup_latency.md - // - // The histogram bucket boundaries for pod startup latency metrics, measured in seconds. These are hand-picked - // so as to be roughly exponential but still round numbers in everyday units. This is to minimise the number - // of buckets while allowing accurate measurement of thresholds which might be used in SLOs - // e.g. x% of pods start up within 30 seconds, or 15 minutes, etc. - PodStartSLIDuration = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodStartSLIDurationKey, - Help: "Duration in seconds to start a pod, excluding time to pull images and run init containers, measured from pod creation timestamp to when all its containers are reported as started and observed via watch", - Buckets: []float64{0.5, 1, 2, 3, 4, 5, 6, 8, 10, 20, 30, 45, 60, 120, 180, 240, 300, 360, 480, 600, 900, 1200, 1800, 2700, 3600}, - StabilityLevel: metrics.ALPHA, - }, - []string{}, - ) - // CgroupManagerDuration is a Histogram that tracks the duration (in seconds) it takes for cgroup manager operations to complete. - // Broken down by method. - CgroupManagerDuration = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: CgroupManagerOperationsKey, - Help: "Duration in seconds for cgroup manager operations. Broken down by method.", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - []string{"operation_type"}, - ) - // PodWorkerStartDuration is a Histogram that tracks the duration (in seconds) it takes from kubelet seeing a pod to starting a worker. - PodWorkerStartDuration = metrics.NewHistogram( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodWorkerStartDurationKey, - Help: "Duration in seconds from kubelet seeing a pod to starting a worker.", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - ) - // PodStatusSyncDuration is a Histogram that tracks the duration (in seconds) in takes from the time a pod - // status is generated to the time it is synced with the apiserver. If multiple status changes are generated - // on a pod before it is written to the API, the latency is from the first update to the last event. - PodStatusSyncDuration = metrics.NewHistogram( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodStatusSyncDurationKey, - Help: "Duration in seconds to sync a pod status update. Measures time from detection of a change to pod status until the API is successfully updated for that pod, even if multiple intevening changes to pod status occur.", - Buckets: []float64{0.010, 0.050, 0.100, 0.500, 1, 5, 10, 20, 30, 45, 60}, - StabilityLevel: metrics.ALPHA, - }, - ) - // PLEGRelistDuration is a Histogram that tracks the duration (in seconds) it takes for relisting pods in the Kubelet's - // Pod Lifecycle Event Generator (PLEG). - PLEGRelistDuration = metrics.NewHistogram( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGRelistDurationKey, - Help: "Duration in seconds for relisting pods in PLEG.", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - ) - // PLEGDiscardEvents is a Counter that tracks the number of discarding events in the Kubelet's Pod Lifecycle Event Generator (PLEG). - PLEGDiscardEvents = metrics.NewCounter( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGDiscardEventsKey, - Help: "The number of discard events in PLEG.", - StabilityLevel: metrics.ALPHA, - }, - ) - - // PLEGRelistInterval is a Histogram that tracks the intervals (in seconds) between relisting in the Kubelet's - // Pod Lifecycle Event Generator (PLEG). - PLEGRelistInterval = metrics.NewHistogram( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGRelistIntervalKey, - Help: "Interval in seconds between relisting in PLEG.", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - ) - // PLEGLastSeen is a Gauge giving the Unix timestamp when the Kubelet's - // Pod Lifecycle Event Generator (PLEG) was last seen active. - PLEGLastSeen = metrics.NewGauge( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGLastSeenKey, - Help: "Timestamp in seconds when PLEG was last seen active.", - StabilityLevel: metrics.ALPHA, - }, - ) - // RuntimeOperations is a Counter that tracks the cumulative number of remote runtime operations. - // Broken down by operation type. - RuntimeOperations = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: RuntimeOperationsKey, - Help: "Cumulative number of runtime operations by operation type.", - StabilityLevel: metrics.ALPHA, - }, - []string{"operation_type"}, - ) - // RuntimeOperationsDuration is a Histogram that tracks the duration (in seconds) for remote runtime operations to complete. - // Broken down by operation type. - RuntimeOperationsDuration = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: RuntimeOperationsDurationKey, - Help: "Duration in seconds of runtime operations. Broken down by operation type.", - Buckets: metrics.ExponentialBuckets(.005, 2.5, 14), - StabilityLevel: metrics.ALPHA, - }, - []string{"operation_type"}, - ) - // RuntimeOperationsErrors is a Counter that tracks the cumulative number of remote runtime operations errors. - // Broken down by operation type. - RuntimeOperationsErrors = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: RuntimeOperationsErrorsKey, - Help: "Cumulative number of runtime operation errors by operation type.", - StabilityLevel: metrics.ALPHA, - }, - []string{"operation_type"}, - ) - // Evictions is a Counter that tracks the cumulative number of pod evictions initiated by the kubelet. - // Broken down by eviction signal. - Evictions = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: EvictionsKey, - Help: "Cumulative number of pod evictions by eviction signal", - StabilityLevel: metrics.ALPHA, - }, - []string{"eviction_signal"}, - ) - // EvictionStatsAge is a Histogram that tracks the time (in seconds) between when stats are collected and when a pod is evicted - // based on those stats. Broken down by eviction signal. - EvictionStatsAge = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: EvictionStatsAgeKey, - Help: "Time between when stats are collected, and when pod is evicted based on those stats by eviction signal", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - []string{"eviction_signal"}, - ) - // Preemptions is a Counter that tracks the cumulative number of pod preemptions initiated by the kubelet. - // Broken down by preemption signal. A preemption is only recorded for one resource, the sum of all signals - // is the number of preemptions on the given node. - Preemptions = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PreemptionsKey, - Help: "Cumulative number of pod preemptions by preemption resource", - StabilityLevel: metrics.ALPHA, - }, - []string{"preemption_signal"}, - ) - // DevicePluginRegistrationCount is a Counter that tracks the cumulative number of device plugin registrations. - // Broken down by resource name. - DevicePluginRegistrationCount = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: DevicePluginRegistrationCountKey, - Help: "Cumulative number of device plugin registrations. Broken down by resource name.", - StabilityLevel: metrics.ALPHA, - }, - []string{"resource_name"}, - ) - // DevicePluginAllocationDuration is a Histogram that tracks the duration (in seconds) to serve a device plugin allocation request. - // Broken down by resource name. - DevicePluginAllocationDuration = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: DevicePluginAllocationDurationKey, - Help: "Duration in seconds to serve a device plugin Allocation request. Broken down by resource name.", - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - []string{"resource_name"}, - ) - - // PodResourcesEndpointRequestsTotalCount is a Counter that tracks the cumulative number of requests to the PodResource endpoints. - // Broken down by server API version. - PodResourcesEndpointRequestsTotalCount = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PodResourcesEndpointRequestsTotalKey, - Help: "Cumulative number of requests to the PodResource endpoint. Broken down by server api version.", - StabilityLevel: metrics.ALPHA, - }, - []string{"server_api_version"}, - ) - - // PodResourcesEndpointRequestsListCount is a Counter that tracks the number of requests to the PodResource List() endpoint. - // Broken down by server API version. - PodResourcesEndpointRequestsListCount = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PodResourcesEndpointRequestsListKey, - Help: "Number of requests to the PodResource List endpoint. Broken down by server api version.", - StabilityLevel: metrics.ALPHA, - }, - []string{"server_api_version"}, - ) - - // PodResourcesEndpointRequestsGetAllocatableCount is a Counter that tracks the number of requests to the PodResource GetAllocatableResources() endpoint. - // Broken down by server API version. - PodResourcesEndpointRequestsGetAllocatableCount = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PodResourcesEndpointRequestsGetAllocatableKey, - Help: "Number of requests to the PodResource GetAllocatableResources endpoint. Broken down by server api version.", - StabilityLevel: metrics.ALPHA, - }, - []string{"server_api_version"}, - ) - - // PodResourcesEndpointErrorsListCount is a Counter that tracks the number of errors returned by he PodResource List() endpoint. - // Broken down by server API version. - PodResourcesEndpointErrorsListCount = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PodResourcesEndpointErrorsListKey, - Help: "Number of requests to the PodResource List endpoint which returned error. Broken down by server api version.", - StabilityLevel: metrics.ALPHA, - }, - []string{"server_api_version"}, - ) - - // PodResourcesEndpointErrorsGetAllocatableCount is a Counter that tracks the number of errors returned by the PodResource GetAllocatableResources() endpoint. - // Broken down by server API version. - PodResourcesEndpointErrorsGetAllocatableCount = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PodResourcesEndpointErrorsGetAllocatableKey, - Help: "Number of requests to the PodResource GetAllocatableResources endpoint which returned error. Broken down by server api version.", - StabilityLevel: metrics.ALPHA, - }, - []string{"server_api_version"}, - ) - - // RunPodSandboxDuration is a Histogram that tracks the duration (in seconds) it takes to run Pod Sandbox operations. - // Broken down by RuntimeClass.Handler. - RunPodSandboxDuration = metrics.NewHistogramVec( - &metrics.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: RunPodSandboxDurationKey, - Help: "Duration in seconds of the run_podsandbox operations. Broken down by RuntimeClass.Handler.", - // Use DefBuckets for now, will customize the buckets if necessary. - Buckets: metrics.DefBuckets, - StabilityLevel: metrics.ALPHA, - }, - []string{"runtime_handler"}, - ) - // RunPodSandboxErrors is a Counter that tracks the cumulative number of Pod Sandbox operations errors. - // Broken down by RuntimeClass.Handler. - RunPodSandboxErrors = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: RunPodSandboxErrorsKey, - Help: "Cumulative number of the run_podsandbox operation errors by RuntimeClass.Handler.", - StabilityLevel: metrics.ALPHA, - }, - []string{"runtime_handler"}, - ) - - // RunningPodCount is a gauge that tracks the number of Pods currently with a running sandbox - // It is used to expose the kubelet internal state: how many pods have running containers in the container runtime, and mainly for debugging purpose. - RunningPodCount = metrics.NewGauge( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: RunningPodsKey, - Help: "Number of pods that have a running pod sandbox", - StabilityLevel: metrics.ALPHA, - }, - ) - // RunningContainerCount is a gauge that tracks the number of containers currently running - RunningContainerCount = metrics.NewGaugeVec( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: RunningContainersKey, - Help: "Number of containers currently running", - StabilityLevel: metrics.ALPHA, - }, - []string{"container_state"}, - ) - // StartedPodsTotal is a counter that tracks pod sandbox creation operations - StartedPodsTotal = metrics.NewCounter( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: StartedPodsTotalKey, - Help: "Cumulative number of pods started", - StabilityLevel: metrics.ALPHA, - }, - ) - // StartedPodsErrorsTotal is a counter that tracks the number of errors creating pod sandboxes - StartedPodsErrorsTotal = metrics.NewCounter( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: StartedPodsErrorsTotalKey, - Help: "Cumulative number of errors when starting pods", - StabilityLevel: metrics.ALPHA, - }, - ) - // StartedContainersTotal is a counter that tracks the number of container creation operations - StartedContainersTotal = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: StartedContainersTotalKey, - Help: "Cumulative number of containers started", - StabilityLevel: metrics.ALPHA, - }, - []string{"container_type"}, - ) - // StartedContainersTotal is a counter that tracks the number of errors creating containers - StartedContainersErrorsTotal = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: StartedContainersErrorsTotalKey, - Help: "Cumulative number of errors when starting containers", - StabilityLevel: metrics.ALPHA, - }, - []string{"container_type", "code"}, - ) - // StartedHostProcessContainersTotal is a counter that tracks the number of hostprocess container creation operations - StartedHostProcessContainersTotal = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: StartedHostProcessContainersTotalKey, - Help: "Cumulative number of hostprocess containers started. This metric will only be collected on Windows and requires WindowsHostProcessContainers feature gate to be enabled.", - StabilityLevel: metrics.ALPHA, - }, - []string{"container_type"}, - ) - // StartedHostProcessContainersErrorsTotal is a counter that tracks the number of errors creating hostprocess containers - StartedHostProcessContainersErrorsTotal = metrics.NewCounterVec( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: StartedHostProcessContainersErrorsTotalKey, - Help: "Cumulative number of errors when starting hostprocess containers. This metric will only be collected on Windows and requires WindowsHostProcessContainers feature gate to be enabled.", - StabilityLevel: metrics.ALPHA, - }, - []string{"container_type", "code"}, - ) - // ManagedEphemeralContainers is a gauge that indicates how many ephemeral containers are managed by this kubelet. - ManagedEphemeralContainers = metrics.NewGauge( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: ManagedEphemeralContainersKey, - Help: "Current number of ephemeral containers in pods managed by this kubelet. Ephemeral containers will be ignored if disabled by the EphemeralContainers feature gate, and this number will be 0.", - StabilityLevel: metrics.ALPHA, - }, - ) - - // GracefulShutdownStartTime is a gauge that records the time at which the kubelet started graceful shutdown. - GracefulShutdownStartTime = metrics.NewGauge( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: "graceful_shutdown_start_time_seconds", - Help: "Last graceful shutdown start time since unix epoch in seconds", - StabilityLevel: metrics.ALPHA, - }, - ) - - // GracefulShutdownEndTime is a gauge that records the time at which the kubelet completed graceful shutdown. - GracefulShutdownEndTime = metrics.NewGauge( - &metrics.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: "graceful_shutdown_end_time_seconds", - Help: "Last graceful shutdown start time since unix epoch in seconds", - StabilityLevel: metrics.ALPHA, - }, - ) - - LifecycleHandlerHTTPFallbacks = metrics.NewCounter( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: "lifecycle_handler_http_fallbacks_total", - Help: "The number of times lifecycle handlers successfully fell back to http from https.", - StabilityLevel: metrics.ALPHA, - }, - ) - - // CPUManagerPinningRequestsTotal tracks the number of times the pod spec will cause the cpu manager to pin cores - CPUManagerPinningRequestsTotal = metrics.NewCounter( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: CPUManagerPinningRequestsTotalKey, - Help: "The number of cpu core allocations which required pinning.", - StabilityLevel: metrics.ALPHA, - }, - ) - - // CPUManagerPinningErrorsTotal tracks the number of times the pod spec required the cpu manager to pin cores, but the allocation failed - CPUManagerPinningErrorsTotal = metrics.NewCounter( - &metrics.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: CPUManagerPinningErrorsTotalKey, - Help: "The number of cpu core allocations which required pinning failed.", - StabilityLevel: metrics.ALPHA, - }, - ) -) - -var registerMetrics sync.Once - -// Register registers all metrics. -func Register(collectors ...metrics.StableCollector) { - // Register the metrics. - registerMetrics.Do(func() { - legacyregistry.MustRegister(NodeName) - legacyregistry.MustRegister(PodWorkerDuration) - legacyregistry.MustRegister(PodStartDuration) - legacyregistry.MustRegister(PodStartSLIDuration) - legacyregistry.MustRegister(CgroupManagerDuration) - legacyregistry.MustRegister(PodWorkerStartDuration) - legacyregistry.MustRegister(PodStatusSyncDuration) - legacyregistry.MustRegister(ContainersPerPodCount) - legacyregistry.MustRegister(PLEGRelistDuration) - legacyregistry.MustRegister(PLEGDiscardEvents) - legacyregistry.MustRegister(PLEGRelistInterval) - legacyregistry.MustRegister(PLEGLastSeen) - legacyregistry.MustRegister(RuntimeOperations) - legacyregistry.MustRegister(RuntimeOperationsDuration) - legacyregistry.MustRegister(RuntimeOperationsErrors) - legacyregistry.MustRegister(Evictions) - legacyregistry.MustRegister(EvictionStatsAge) - legacyregistry.MustRegister(Preemptions) - legacyregistry.MustRegister(DevicePluginRegistrationCount) - legacyregistry.MustRegister(DevicePluginAllocationDuration) - legacyregistry.MustRegister(RunningContainerCount) - legacyregistry.MustRegister(RunningPodCount) - legacyregistry.MustRegister(ManagedEphemeralContainers) - if utilfeature.DefaultFeatureGate.Enabled(features.KubeletPodResources) { - legacyregistry.MustRegister(PodResourcesEndpointRequestsTotalCount) - - if utilfeature.DefaultFeatureGate.Enabled(features.KubeletPodResourcesGetAllocatable) { - legacyregistry.MustRegister(PodResourcesEndpointRequestsListCount) - legacyregistry.MustRegister(PodResourcesEndpointRequestsGetAllocatableCount) - legacyregistry.MustRegister(PodResourcesEndpointErrorsListCount) - legacyregistry.MustRegister(PodResourcesEndpointErrorsGetAllocatableCount) - } - } - legacyregistry.MustRegister(StartedPodsTotal) - legacyregistry.MustRegister(StartedPodsErrorsTotal) - legacyregistry.MustRegister(StartedContainersTotal) - legacyregistry.MustRegister(StartedContainersErrorsTotal) - legacyregistry.MustRegister(StartedHostProcessContainersTotal) - legacyregistry.MustRegister(StartedHostProcessContainersErrorsTotal) - legacyregistry.MustRegister(RunPodSandboxDuration) - legacyregistry.MustRegister(RunPodSandboxErrors) - legacyregistry.MustRegister(CPUManagerPinningRequestsTotal) - legacyregistry.MustRegister(CPUManagerPinningErrorsTotal) - - for _, collector := range collectors { - legacyregistry.CustomMustRegister(collector) - } - - if utilfeature.DefaultFeatureGate.Enabled(features.GracefulNodeShutdown) && - utilfeature.DefaultFeatureGate.Enabled(features.GracefulNodeShutdownBasedOnPodPriority) { - legacyregistry.MustRegister(GracefulShutdownStartTime) - legacyregistry.MustRegister(GracefulShutdownEndTime) - } - - if utilfeature.DefaultFeatureGate.Enabled(features.ConsistentHTTPGetHandlers) { - legacyregistry.MustRegister(LifecycleHandlerHTTPFallbacks) - } - }) -} - -// GetGather returns the gatherer. It used by test case outside current package. -func GetGather() metrics.Gatherer { - return legacyregistry.DefaultGatherer -} - -// SinceInSeconds gets the time since the specified start in seconds. -func SinceInSeconds(start time.Time) float64 { - return time.Since(start).Seconds() -} - -// SetNodeName sets the NodeName Gauge to 1. -func SetNodeName(name types.NodeName) { - NodeName.WithLabelValues(string(name)).Set(1) -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_darwin.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_darwin.go deleted file mode 100644 index b6a1cc38c..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_darwin.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build darwin -// +build darwin - -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "fmt" - "syscall" - "time" - "unsafe" - - "golang.org/x/sys/unix" -) - -// GetBootTime returns the time at which the machine was started, truncated to the nearest second -func GetBootTime() (time.Time, error) { - output, err := unix.SysctlRaw("kern.boottime") - if err != nil { - return time.Time{}, err - } - var timeval syscall.Timeval - if len(output) != int(unsafe.Sizeof(timeval)) { - return time.Time{}, fmt.Errorf("unexpected output when calling syscall kern.bootime. Expected len(output) to be %v, but got %v", - int(unsafe.Sizeof(timeval)), len(output)) - } - timeval = *(*syscall.Timeval)(unsafe.Pointer(&output[0])) - sec, nsec := timeval.Unix() - return time.Unix(sec, nsec).Truncate(time.Second), nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_freebsd.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_freebsd.go deleted file mode 100644 index 7d605d761..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_freebsd.go +++ /dev/null @@ -1,40 +0,0 @@ -//go:build freebsd -// +build freebsd - -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "fmt" - "time" - - "golang.org/x/sys/unix" - "unsafe" -) - -// GetBootTime returns the time at which the machine was started, truncated to the nearest second -func GetBootTime() (time.Time, error) { - currentTime := time.Now() - ts := &unix.Timeval{} - _, _, e1 := unix.Syscall(uintptr(unix.SYS_CLOCK_GETTIME), uintptr(unix.CLOCK_UPTIME), uintptr(unsafe.Pointer(ts)), 0) - if e1 != 0 { - return time.Time{}, fmt.Errorf("error getting system uptime") - } - - return currentTime.Add(-time.Duration(ts.Sec) * time.Second).Truncate(time.Second), nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_linux.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_linux.go deleted file mode 100644 index b48ef392e..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/boottime_util_linux.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build linux -// +build linux - -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "fmt" - "time" - - "golang.org/x/sys/unix" -) - -// GetBootTime returns the time at which the machine was started, truncated to the nearest second -func GetBootTime() (time.Time, error) { - currentTime := time.Now() - var info unix.Sysinfo_t - if err := unix.Sysinfo(&info); err != nil { - return time.Time{}, fmt.Errorf("error getting system uptime: %s", err) - } - return currentTime.Add(-time.Duration(info.Uptime) * time.Second).Truncate(time.Second), nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/doc.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/doc.go deleted file mode 100644 index eaccd63a3..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package util holds utility functions. -package util // import "k8s.io/kubernetes/pkg/kubelet/util" diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/nodelease.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/nodelease.go deleted file mode 100644 index 9e1b00b76..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/nodelease.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "context" - - coordinationv1 "k8s.io/api/coordination/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clientset "k8s.io/client-go/kubernetes" - - "k8s.io/klog/v2" -) - -// SetNodeOwnerFunc helps construct a newLeasePostProcessFunc which sets -// a node OwnerReference to the given lease object -func SetNodeOwnerFunc(c clientset.Interface, nodeName string) func(lease *coordinationv1.Lease) error { - return func(lease *coordinationv1.Lease) error { - // Setting owner reference needs node's UID. Note that it is different from - // kubelet.nodeRef.UID. When lease is initially created, it is possible that - // the connection between master and node is not ready yet. So try to set - // owner reference every time when renewing the lease, until successful. - if len(lease.OwnerReferences) == 0 { - if node, err := c.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{}); err == nil { - lease.OwnerReferences = []metav1.OwnerReference{ - { - APIVersion: corev1.SchemeGroupVersion.WithKind("Node").Version, - Kind: corev1.SchemeGroupVersion.WithKind("Node").Kind, - Name: nodeName, - UID: node.UID, - }, - } - } else { - klog.ErrorS(err, "Failed to get node when trying to set owner ref to the node lease", "node", klog.KRef("", nodeName)) - return err - } - } - return nil - } -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/pod_startup_latency_tracker.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/pod_startup_latency_tracker.go deleted file mode 100644 index 12ee06bd6..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/pod_startup_latency_tracker.go +++ /dev/null @@ -1,186 +0,0 @@ -/* -Copyright 2022 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "sync" - "time" - - v1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/klog/v2" - "k8s.io/kubernetes/pkg/kubelet/metrics" - "k8s.io/utils/clock" -) - -// PodStartupLatencyTracker records key moments for startup latency calculation, -// e.g. image pulling or pod observed running on watch. -type PodStartupLatencyTracker interface { - ObservedPodOnWatch(pod *v1.Pod, when time.Time) - RecordImageStartedPulling(podUID types.UID) - RecordImageFinishedPulling(podUID types.UID) - RecordStatusUpdated(pod *v1.Pod) - DeletePodStartupState(podUID types.UID) -} - -type basicPodStartupLatencyTracker struct { - // protect against concurrent read and write on pods map - lock sync.Mutex - pods map[types.UID]*perPodState - // For testability - clock clock.Clock -} - -type perPodState struct { - firstStartedPulling time.Time - lastFinishedPulling time.Time - // first time, when pod status changed into Running - observedRunningTime time.Time - // log, if pod latency was already Observed - metricRecorded bool -} - -// NewPodStartupLatencyTracker creates an instance of PodStartupLatencyTracker -func NewPodStartupLatencyTracker() PodStartupLatencyTracker { - return &basicPodStartupLatencyTracker{ - pods: map[types.UID]*perPodState{}, - clock: clock.RealClock{}, - } -} - -func (p *basicPodStartupLatencyTracker) ObservedPodOnWatch(pod *v1.Pod, when time.Time) { - p.lock.Lock() - defer p.lock.Unlock() - - // if the pod is terminal, we do not have to track it anymore for startup - if pod.Status.Phase == v1.PodFailed || pod.Status.Phase == v1.PodSucceeded { - delete(p.pods, pod.UID) - return - } - - state := p.pods[pod.UID] - if state == nil { - // create a new record for pod, only if it was not yet acknowledged by the Kubelet - // this is required, as we want to log metric only for those pods, that where scheduled - // after Kubelet started - if pod.Status.StartTime.IsZero() { - p.pods[pod.UID] = &perPodState{} - } - - return - } - - if state.observedRunningTime.IsZero() { - // skip, pod didn't start yet - return - } - - if state.metricRecorded { - // skip, pod's latency already recorded - return - } - - if hasPodStartedSLO(pod) { - podStartingDuration := when.Sub(pod.CreationTimestamp.Time) - imagePullingDuration := state.lastFinishedPulling.Sub(state.firstStartedPulling) - podStartSLOduration := (podStartingDuration - imagePullingDuration).Seconds() - - klog.InfoS("Observed pod startup duration", - "pod", klog.KObj(pod), - "podStartSLOduration", podStartSLOduration, - "pod.CreationTimestamp", pod.CreationTimestamp.Time, - "firstStartedPulling", state.firstStartedPulling, - "lastFinishedPulling", state.lastFinishedPulling, - "observedRunningTime", state.observedRunningTime, - "watchObservedRunningTime", when) - - metrics.PodStartSLIDuration.WithLabelValues().Observe(podStartSLOduration) - state.metricRecorded = true - } -} - -func (p *basicPodStartupLatencyTracker) RecordImageStartedPulling(podUID types.UID) { - p.lock.Lock() - defer p.lock.Unlock() - - state := p.pods[podUID] - if state == nil { - return - } - - if state.firstStartedPulling.IsZero() { - state.firstStartedPulling = p.clock.Now() - } -} - -func (p *basicPodStartupLatencyTracker) RecordImageFinishedPulling(podUID types.UID) { - p.lock.Lock() - defer p.lock.Unlock() - - state := p.pods[podUID] - if state == nil { - return - } - - state.lastFinishedPulling = p.clock.Now() // Now is always grater than values from the past. -} - -func (p *basicPodStartupLatencyTracker) RecordStatusUpdated(pod *v1.Pod) { - p.lock.Lock() - defer p.lock.Unlock() - - state := p.pods[pod.UID] - if state == nil { - return - } - - if state.metricRecorded { - // skip, pod latency already recorded - return - } - - if !state.observedRunningTime.IsZero() { - // skip, pod already started - return - } - - if hasPodStartedSLO(pod) { - klog.V(3).InfoS("Mark when the pod was running for the first time", "pod", klog.KObj(pod), "rv", pod.ResourceVersion) - state.observedRunningTime = p.clock.Now() - } -} - -// hasPodStartedSLO, check if for given pod, each container has been started at least once -// -// This should reflect "Pod startup latency SLI" definition -// ref: https://github.com/kubernetes/community/blob/master/sig-scalability/slos/pod_startup_latency.md -func hasPodStartedSLO(pod *v1.Pod) bool { - for _, cs := range pod.Status.ContainerStatuses { - if cs.State.Running == nil || cs.State.Running.StartedAt.IsZero() { - return false - } - } - - return true -} - -func (p *basicPodStartupLatencyTracker) DeletePodStartupState(podUID types.UID) { - p.lock.Lock() - defer p.lock.Unlock() - - delete(p.pods, podUID) -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/util.go deleted file mode 100644 index c2969a511..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "fmt" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// FromApiserverCache modifies so that the GET request will -// be served from apiserver cache instead of from etcd. -func FromApiserverCache(opts *metav1.GetOptions) { - opts.ResourceVersion = "0" -} - -// GetNodenameForKernel gets hostname value to set in the hostname field (the nodename field of struct utsname) of the pod. -func GetNodenameForKernel(hostname string, hostDomainName string, setHostnameAsFQDN *bool) (string, error) { - kernelHostname := hostname - // FQDN has to be 64 chars to fit in the Linux nodename kernel field (specification 64 chars and the null terminating char). - const fqdnMaxLen = 64 - if len(hostDomainName) > 0 && setHostnameAsFQDN != nil && *setHostnameAsFQDN { - fqdn := fmt.Sprintf("%s.%s", hostname, hostDomainName) - // FQDN has to be shorter than hostnameMaxLen characters. - if len(fqdn) > fqdnMaxLen { - return "", fmt.Errorf("failed to construct FQDN from pod hostname and cluster domain, FQDN %s is too long (%d characters is the max, %d characters requested)", fqdn, fqdnMaxLen, len(fqdn)) - } - kernelHostname = fqdn - } - return kernelHostname, nil -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_unix.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_unix.go deleted file mode 100644 index e68a194e6..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_unix.go +++ /dev/null @@ -1,154 +0,0 @@ -//go:build freebsd || linux || darwin -// +build freebsd linux darwin - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "context" - "fmt" - "net" - "net/url" - "os" - "path/filepath" - - "golang.org/x/sys/unix" - "k8s.io/klog/v2" -) - -const ( - // unixProtocol is the network protocol of unix socket. - unixProtocol = "unix" -) - -// CreateListener creates a listener on the specified endpoint. -func CreateListener(endpoint string) (net.Listener, error) { - protocol, addr, err := parseEndpointWithFallbackProtocol(endpoint, unixProtocol) - if err != nil { - return nil, err - } - if protocol != unixProtocol { - return nil, fmt.Errorf("only support unix socket endpoint") - } - - // Unlink to cleanup the previous socket file. - err = unix.Unlink(addr) - if err != nil && !os.IsNotExist(err) { - return nil, fmt.Errorf("failed to unlink socket file %q: %v", addr, err) - } - - if err := os.MkdirAll(filepath.Dir(addr), 0750); err != nil { - return nil, fmt.Errorf("error creating socket directory %q: %v", filepath.Dir(addr), err) - } - - // Create the socket on a tempfile and move it to the destination socket to handle improper cleanup - file, err := os.CreateTemp(filepath.Dir(addr), "") - if err != nil { - return nil, fmt.Errorf("failed to create temporary file: %v", err) - } - - if err := os.Remove(file.Name()); err != nil { - return nil, fmt.Errorf("failed to remove temporary file: %v", err) - } - - l, err := net.Listen(protocol, file.Name()) - if err != nil { - return nil, err - } - - if err = os.Rename(file.Name(), addr); err != nil { - return nil, fmt.Errorf("failed to move temporary file to addr %q: %v", addr, err) - } - - return l, nil -} - -// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer. -func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) { - protocol, addr, err := parseEndpointWithFallbackProtocol(endpoint, unixProtocol) - if err != nil { - return "", nil, err - } - if protocol != unixProtocol { - return "", nil, fmt.Errorf("only support unix socket endpoint") - } - - return addr, dial, nil -} - -func dial(ctx context.Context, addr string) (net.Conn, error) { - return (&net.Dialer{}).DialContext(ctx, unixProtocol, addr) -} - -func parseEndpointWithFallbackProtocol(endpoint string, fallbackProtocol string) (protocol string, addr string, err error) { - if protocol, addr, err = parseEndpoint(endpoint); err != nil && protocol == "" { - fallbackEndpoint := fallbackProtocol + "://" + endpoint - protocol, addr, err = parseEndpoint(fallbackEndpoint) - if err == nil { - klog.InfoS("Using this endpoint is deprecated, please consider using full URL format", "endpoint", endpoint, "URL", fallbackEndpoint) - } - } - return -} - -func parseEndpoint(endpoint string) (string, string, error) { - u, err := url.Parse(endpoint) - if err != nil { - return "", "", err - } - - switch u.Scheme { - case "tcp": - return "tcp", u.Host, nil - - case "unix": - return "unix", u.Path, nil - - case "": - return "", "", fmt.Errorf("using %q as endpoint is deprecated, please consider using full url format", endpoint) - - default: - return u.Scheme, "", fmt.Errorf("protocol %q not supported", u.Scheme) - } -} - -// LocalEndpoint returns the full path to a unix socket at the given endpoint -func LocalEndpoint(path, file string) (string, error) { - u := url.URL{ - Scheme: unixProtocol, - Path: path, - } - return filepath.Join(u.String(), file+".sock"), nil -} - -// IsUnixDomainSocket returns whether a given file is a AF_UNIX socket file -func IsUnixDomainSocket(filePath string) (bool, error) { - fi, err := os.Stat(filePath) - if err != nil { - return false, fmt.Errorf("stat file %s failed: %v", filePath, err) - } - if fi.Mode()&os.ModeSocket == 0 { - return false, nil - } - return true, nil -} - -// NormalizePath is a no-op for Linux for now -func NormalizePath(path string) string { - return path -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_unsupported.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_unsupported.go deleted file mode 100644 index 054c36230..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_unsupported.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build !freebsd && !linux && !windows && !darwin -// +build !freebsd,!linux,!windows,!darwin - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "context" - "fmt" - "net" - "time" -) - -// CreateListener creates a listener on the specified endpoint. -func CreateListener(endpoint string) (net.Listener, error) { - return nil, fmt.Errorf("CreateListener is unsupported in this build") -} - -// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer. -func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) { - return "", nil, fmt.Errorf("GetAddressAndDialer is unsupported in this build") -} - -// LockAndCheckSubPath empty implementation -func LockAndCheckSubPath(volumePath, subPath string) ([]uintptr, error) { - return []uintptr{}, nil -} - -// UnlockPath empty implementation -func UnlockPath(fileHandles []uintptr) { -} - -// LocalEndpoint empty implementation -func LocalEndpoint(path, file string) (string, error) { - return "", fmt.Errorf("LocalEndpoints are unsupported in this build") -} - -// GetBootTime empty implementation -func GetBootTime() (time.Time, error) { - return time.Time{}, fmt.Errorf("GetBootTime is unsupported in this build") -} diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_windows.go b/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_windows.go deleted file mode 100644 index af51d45c6..000000000 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/util/util_windows.go +++ /dev/null @@ -1,188 +0,0 @@ -//go:build windows -// +build windows - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "context" - "fmt" - "net" - "net/url" - "strings" - "syscall" - "time" - - "github.com/Microsoft/go-winio" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/klog/v2" -) - -const ( - tcpProtocol = "tcp" - npipeProtocol = "npipe" - // Amount of time to wait between attempting to use a Unix domain socket. - // As detailed in https://github.com/kubernetes/kubernetes/issues/104584 - // the first attempt will most likely fail, hence the need to retry - socketDialRetryPeriod = 1 * time.Second - // Overall timeout value to dial a Unix domain socket, including retries - socketDialTimeout = 4 * time.Second -) - -// CreateListener creates a listener on the specified endpoint. -func CreateListener(endpoint string) (net.Listener, error) { - protocol, addr, err := parseEndpoint(endpoint) - if err != nil { - return nil, err - } - - switch protocol { - case tcpProtocol: - return net.Listen(tcpProtocol, addr) - - case npipeProtocol: - return winio.ListenPipe(addr, nil) - - default: - return nil, fmt.Errorf("only support tcp and npipe endpoint") - } -} - -// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer. -func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) { - protocol, addr, err := parseEndpoint(endpoint) - if err != nil { - return "", nil, err - } - - if protocol == tcpProtocol { - return addr, tcpDial, nil - } - - if protocol == npipeProtocol { - return addr, npipeDial, nil - } - - return "", nil, fmt.Errorf("only support tcp and npipe endpoint") -} - -func tcpDial(ctx context.Context, addr string) (net.Conn, error) { - return (&net.Dialer{}).DialContext(ctx, tcpProtocol, addr) -} - -func npipeDial(ctx context.Context, addr string) (net.Conn, error) { - return winio.DialPipeContext(ctx, addr) -} - -func parseEndpoint(endpoint string) (string, string, error) { - // url.Parse doesn't recognize \, so replace with / first. - endpoint = strings.Replace(endpoint, "\\", "/", -1) - u, err := url.Parse(endpoint) - if err != nil { - return "", "", err - } - - if u.Scheme == "tcp" { - return "tcp", u.Host, nil - } else if u.Scheme == "npipe" { - if strings.HasPrefix(u.Path, "//./pipe") { - return "npipe", u.Path, nil - } - - // fallback host if not provided. - host := u.Host - if host == "" { - host = "." - } - return "npipe", fmt.Sprintf("//%s%s", host, u.Path), nil - } else if u.Scheme == "" { - return "", "", fmt.Errorf("Using %q as endpoint is deprecated, please consider using full url format", endpoint) - } else { - return u.Scheme, "", fmt.Errorf("protocol %q not supported", u.Scheme) - } -} - -// LocalEndpoint empty implementation -func LocalEndpoint(path, file string) (string, error) { - return "", fmt.Errorf("LocalEndpoints are unsupported in this build") -} - -var tickCount = syscall.NewLazyDLL("kernel32.dll").NewProc("GetTickCount64") - -// GetBootTime returns the time at which the machine was started, truncated to the nearest second -func GetBootTime() (time.Time, error) { - currentTime := time.Now() - output, _, err := tickCount.Call() - if errno, ok := err.(syscall.Errno); !ok || errno != 0 { - return time.Time{}, err - } - return currentTime.Add(-time.Duration(output) * time.Millisecond).Truncate(time.Second), nil -} - -// IsUnixDomainSocket returns whether a given file is a AF_UNIX socket file -// Note that due to the retry logic inside, it could take up to 4 seconds -// to determine whether or not the file path supplied is a Unix domain socket -func IsUnixDomainSocket(filePath string) (bool, error) { - // Due to the absence of golang support for os.ModeSocket in Windows (https://github.com/golang/go/issues/33357) - // we need to dial the file and check if we receive an error to determine if a file is Unix Domain Socket file. - - // Note that querrying for the Reparse Points (https://docs.microsoft.com/en-us/windows/win32/fileio/reparse-points) - // for the file (using FSCTL_GET_REPARSE_POINT) and checking for reparse tag: reparseTagSocket - // does NOT work in 1809 if the socket file is created within a bind mounted directory by a container - // and the FSCTL is issued in the host by the kubelet. - - klog.V(6).InfoS("Function IsUnixDomainSocket starts", "filePath", filePath) - // As detailed in https://github.com/kubernetes/kubernetes/issues/104584 we cannot rely - // on the Unix Domain socket working on the very first try, hence the potential need to - // dial multiple times - var lastSocketErr error - err := wait.PollImmediate(socketDialRetryPeriod, socketDialTimeout, - func() (bool, error) { - klog.V(6).InfoS("Dialing the socket", "filePath", filePath) - var c net.Conn - c, lastSocketErr = net.Dial("unix", filePath) - if lastSocketErr == nil { - c.Close() - klog.V(6).InfoS("Socket dialed successfully", "filePath", filePath) - return true, nil - } - klog.V(6).InfoS("Failed the current attempt to dial the socket, so pausing before retry", - "filePath", filePath, "err", lastSocketErr, "socketDialRetryPeriod", - socketDialRetryPeriod) - return false, nil - }) - - // PollImmediate will return "timed out waiting for the condition" if the function it - // invokes never returns true - if err != nil { - klog.V(2).InfoS("Failed all attempts to dial the socket so marking it as a non-Unix Domain socket. Last socket error along with the error from PollImmediate follow", - "filePath", filePath, "lastSocketErr", lastSocketErr, "err", err) - return false, nil - } - return true, nil -} - -// NormalizePath converts FS paths returned by certain go frameworks (like fsnotify) -// to native Windows paths that can be passed to Windows specific code -func NormalizePath(path string) string { - path = strings.ReplaceAll(path, "/", "\\") - if strings.HasPrefix(path, "\\") { - path = "c:" + path - } - return path -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6420aa31e..6644a7724 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,3 @@ -# github.com/Microsoft/go-winio v0.4.17 -## explicit; go 1.12 -github.com/Microsoft/go-winio -github.com/Microsoft/go-winio/pkg/guid # github.com/OneOfOne/xxhash v1.2.9-0.20201014161131-8506fca4db5e ## explicit; go 1.11 github.com/OneOfOne/xxhash @@ -553,10 +549,6 @@ k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/netutil k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/apiserver v0.26.4 => k8s.io/apiserver v0.26.4 -## explicit; go 1.19 -k8s.io/apiserver/pkg/features -k8s.io/apiserver/pkg/util/feature # k8s.io/client-go v0.27.2 => k8s.io/client-go v0.26.4 ## explicit; go 1.19 k8s.io/client-go/applyconfigurations/admissionregistration/v1 @@ -893,13 +885,6 @@ k8s.io/kube-openapi/pkg/validation/spec ## explicit; go 1.19 k8s.io/kubelet/config/v1beta1 k8s.io/kubelet/pkg/apis/podresources/v1 -k8s.io/kubelet/pkg/apis/podresources/v1alpha1 -# k8s.io/kubernetes v1.26.4 -## explicit; go 1.19 -k8s.io/kubernetes/pkg/features -k8s.io/kubernetes/pkg/kubelet/apis/podresources -k8s.io/kubernetes/pkg/kubelet/metrics -k8s.io/kubernetes/pkg/kubelet/util # k8s.io/utils v0.0.0-20230209194617-a36077c30491 ## explicit; go 1.18 k8s.io/utils/buffer