Skip to content

Commit 5bfcc9c

Browse files
authored
Upgrade k8s.io/client-go and k8s keystore tests (#18817)
1 parent 3bf5689 commit 5bfcc9c

File tree

726 files changed

+124111
-36621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

726 files changed

+124111
-36621
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ field. You can revert this change by configuring tags for the module and omittin
259259
- Add backoff configuration options for the Kafka output. {issue}16777[16777] {pull}17808[17808]
260260
- Add TLS support to Kerberos authentication in Elasticsearch. {pull}18607[18607]
261261
- Change ownership of files in docker images so they can be used in secured environments. {pull}12905[12905]
262+
- Upgrade k8s.io/client-go and k8s keystore tests. {pull}18817[18817]
262263

263264
*Auditbeat*
264265

NOTICE.txt

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,38 @@ This product includes a number of subcomponents with
18531853
separate copyright notices and license terms. Your use of these
18541854
subcomponents is subject to the terms and conditions of the
18551855
subcomponent's license, as noted in the LICENSE file.
1856+
--------------------------------------------------------------------
1857+
Dependency: github.com/evanphx/json-patch
1858+
Version: v4.2.0
1859+
License type (autodetected): BSD-3-Clause
1860+
./vendor/github.com/evanphx/json-patch/LICENSE:
1861+
--------------------------------------------------------------------
1862+
Copyright (c) 2014, Evan Phoenix
1863+
All rights reserved.
1864+
1865+
Redistribution and use in source and binary forms, with or without
1866+
modification, are permitted provided that the following conditions are met:
1867+
1868+
* Redistributions of source code must retain the above copyright notice, this
1869+
list of conditions and the following disclaimer.
1870+
* Redistributions in binary form must reproduce the above copyright notice
1871+
this list of conditions and the following disclaimer in the documentation
1872+
and/or other materials provided with the distribution.
1873+
* Neither the name of the Evan Phoenix nor the names of its contributors
1874+
may be used to endorse or promote products derived from this software
1875+
without specific prior written permission.
1876+
1877+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1878+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1879+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1880+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
1881+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1882+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1883+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1884+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1885+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1886+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1887+
18561888
--------------------------------------------------------------------
18571889
Dependency: github.com/fatih/color
18581890
Version: v1.5.0
@@ -3065,7 +3097,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30653097

30663098
--------------------------------------------------------------------
30673099
Dependency: github.com/google/gofuzz
3068-
Version: v1.0.0
3100+
Version: v1.1.0
30693101
License type (autodetected): Apache-2.0
30703102
./vendor/github.com/google/gofuzz/LICENSE:
30713103
--------------------------------------------------------------------
@@ -5397,7 +5429,7 @@ SOFTWARE.
53975429

53985430
--------------------------------------------------------------------
53995431
Dependency: github.com/json-iterator/go
5400-
Version: v1.1.7
5432+
Version: v1.1.8
54015433
License type (autodetected): MIT
54025434
./vendor/github.com/json-iterator/go/LICENSE:
54035435
--------------------------------------------------------------------
@@ -7120,7 +7152,7 @@ Apache License 2.0
71207152

71217153
--------------------------------------------------------------------
71227154
Dependency: github.com/spf13/pflag
7123-
Version: v1.0.3
7155+
Version: v1.0.5
71247156
License type (autodetected): BSD-3-Clause
71257157
./vendor/github.com/spf13/pflag/LICENSE:
71267158
--------------------------------------------------------------------
@@ -8272,7 +8304,7 @@ Apache License 2.0
82728304

82738305
--------------------------------------------------------------------
82748306
Dependency: gopkg.in/inf.v0
8275-
Version: v0.9.0
8307+
Version: v0.9.1
82768308
License type (autodetected): BSD-3-Clause
82778309
./vendor/gopkg.in/inf.v0/LICENSE:
82788310
--------------------------------------------------------------------
@@ -8903,7 +8935,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89038935

89048936
--------------------------------------------------------------------
89058937
Dependency: k8s.io/api
8906-
Revision: b90922c02518
8938+
Version: v0.18.3
89078939
License type (autodetected): Apache-2.0
89088940
./vendor/k8s.io/api/LICENSE:
89098941
--------------------------------------------------------------------
@@ -8912,7 +8944,7 @@ Apache License 2.0
89128944

89138945
--------------------------------------------------------------------
89148946
Dependency: k8s.io/apimachinery
8915-
Revision: bfcf53abc9f8
8947+
Version: v0.18.3
89168948
License type (autodetected): Apache-2.0
89178949
./vendor/k8s.io/apimachinery/LICENSE:
89188950
--------------------------------------------------------------------
@@ -8921,7 +8953,7 @@ Apache License 2.0
89218953

89228954
--------------------------------------------------------------------
89238955
Dependency: k8s.io/client-go
8924-
Revision: 78d2af792bab
8956+
Version: v0.18.3
89258957
License type (autodetected): Apache-2.0
89268958
./vendor/k8s.io/client-go/LICENSE:
89278959
--------------------------------------------------------------------
@@ -8930,27 +8962,43 @@ Apache License 2.0
89308962

89318963
--------------------------------------------------------------------
89328964
Dependency: k8s.io/klog
8933-
Version: v0.3.4
8934-
Revision: 6a023d6d0e09
8965+
Version: v1.0.0
89358966
License type (autodetected): Apache-2.0
89368967
./vendor/k8s.io/klog/LICENSE:
89378968
--------------------------------------------------------------------
89388969
Apache License 2.0
89398970

89408971

8972+
--------------------------------------------------------------------
8973+
Dependency: k8s.io/kube-openapi
8974+
Revision: 61e04a5be9a6
8975+
License type (autodetected): Apache-2.0
8976+
./vendor/k8s.io/kube-openapi/LICENSE:
8977+
--------------------------------------------------------------------
8978+
Apache License 2.0
8979+
8980+
89418981
--------------------------------------------------------------------
89428982
Dependency: k8s.io/utils
8943-
Revision: 3dccf664f023
8983+
Revision: a9aa75ae1b89
89448984
License type (autodetected): Apache-2.0
89458985
./vendor/k8s.io/utils/LICENSE:
89468986
--------------------------------------------------------------------
89478987
Apache License 2.0
89488988

89498989

8990+
--------------------------------------------------------------------
8991+
Dependency: sigs.k8s.io/structured-merge-diff/v3
8992+
Version: v3.0.0
8993+
License type (autodetected): Apache-2.0
8994+
./vendor/sigs.k8s.io/structured-merge-diff/v3/LICENSE:
8995+
--------------------------------------------------------------------
8996+
Apache License 2.0
8997+
8998+
89508999
--------------------------------------------------------------------
89519000
Dependency: sigs.k8s.io/yaml
8952-
Version: v1.1.1
8953-
Revision: 4cd0c284b15f
9001+
Version: v1.2.0
89549002
License type (autodetected): MIT
89559003
./vendor/sigs.k8s.io/yaml/LICENSE:
89569004
--------------------------------------------------------------------

dev-tools/generate_notice.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,18 @@ def create_notice(filename, beat, copyright, vendor_dir, csvfile, overrides=None
352352
and/or other materials provided with the distribution.
353353
""")]
354354

355+
# This is a temporary workaround to solve UNKNOWN licence issue
356+
# for `evanphx/json-patch`: https://github.com/evanphx/json-patch/pull/105
357+
BSD_LICENSE_CONTENTS_COMMA_MISSING = [
358+
re.sub(r"\s+", " ", """Redistribution and use in source and binary forms, with or without modification,
359+
are permitted provided that the following conditions are met:"""),
360+
re.sub(r"\s+", " ", """Redistributions of source code must retain the above copyright notice, this
361+
list of conditions and the following disclaimer."""),
362+
re.sub(r"\s+", " ", """Redistributions in binary form must reproduce the above copyright notice
363+
this list of conditions and the following disclaimer in the documentation
364+
and/or other materials provided with the distribution.
365+
""")]
366+
355367
BSD_LICENSE_3_CLAUSE = [
356368
re.sub(r"\s+", " ", """Neither the name of"""),
357369
re.sub(r"\s+", " ", """nor the
@@ -400,7 +412,8 @@ def detect_license_summary(content):
400412
return "Apache-2.0"
401413
if any(sentence in content[0:1000] for sentence in MIT_LICENSES):
402414
return "MIT"
403-
if all(sentence in content[0:1000] for sentence in BSD_LICENSE_CONTENTS):
415+
if all(sentence in content[0:1000] for sentence in BSD_LICENSE_CONTENTS) or \
416+
all(sentence in content[0:1000] for sentence in BSD_LICENSE_CONTENTS_COMMA_MISSING):
404417
if all(sentence in content[0:1000] for sentence in BSD_LICENSE_3_CLAUSE):
405418
if all(sentence in content[0:1000] for sentence in BSD_LICENSE_4_CLAUSE):
406419
return "BSD-4-Clause"

dev-tools/mage/kubernetes/kubectl.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func KubectlDeleteInput(env map[string]string, stdout, stderr io.Writer, manifes
7777
// KubectlWait waits for a condition to occur for a resource in the kubernetes cluster.
7878
//
7979
// KUBECONFIG must be in `env` to target a specific cluster.
80-
func KubectlWait(env map[string]string, stdout, stderr io.Writer, waitFor, resource string) error {
80+
func KubectlWait(env map[string]string, stdout, stderr io.Writer, waitFor, resource string, labels string) error {
8181
_, err := sh.Exec(
8282
env,
8383
stdout,
@@ -87,6 +87,8 @@ func KubectlWait(env map[string]string, stdout, stderr io.Writer, waitFor, resou
8787
"--timeout=300s",
8888
fmt.Sprintf("--for=%s", waitFor),
8989
resource,
90+
"-l",
91+
labels,
9092
)
9193
return err
9294
}

dev-tools/mage/kubernetes/kuberemote.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,17 @@ func (r *KubeRemote) Run(env map[string]string, stdout io.Writer, stderr io.Writ
164164

165165
// deleteSSHKey deletes SSH key from the cluster.
166166
func (r *KubeRemote) deleteSSHKey() {
167-
_ = r.cs.CoreV1().Secrets(r.namespace).Delete(r.secretName, &metav1.DeleteOptions{})
167+
_ = r.cs.CoreV1().Secrets(r.namespace).Delete(context.TODO(), r.secretName, metav1.DeleteOptions{})
168168
}
169169

170170
// syncSSHKey syncs the SSH key to the cluster.
171171
func (r *KubeRemote) syncSSHKey() error {
172172
// delete before create
173173
r.deleteSSHKey()
174-
_, err := r.cs.CoreV1().Secrets(r.namespace).Create(createSecretManifest(r.secretName, r.publicKey))
174+
_, err := r.cs.CoreV1().Secrets(r.namespace).Create(
175+
context.TODO(),
176+
createSecretManifest(r.secretName, r.publicKey),
177+
metav1.CreateOptions{})
175178
if err != nil {
176179
return err
177180
}
@@ -180,24 +183,32 @@ func (r *KubeRemote) syncSSHKey() error {
180183

181184
// deleteServiceAccount syncs required service account.
182185
func (r *KubeRemote) deleteServiceAccount() {
183-
_ = r.cs.RbacV1().ClusterRoleBindings().Delete(r.name, &metav1.DeleteOptions{})
184-
_ = r.cs.RbacV1().ClusterRoles().Delete(r.name, &metav1.DeleteOptions{})
185-
_ = r.cs.CoreV1().ServiceAccounts(r.namespace).Delete(r.svcAccName, &metav1.DeleteOptions{})
186+
ctx := context.TODO()
187+
_ = r.cs.RbacV1().ClusterRoleBindings().Delete(ctx, r.name, metav1.DeleteOptions{})
188+
_ = r.cs.RbacV1().ClusterRoles().Delete(ctx, r.name, metav1.DeleteOptions{})
189+
_ = r.cs.CoreV1().ServiceAccounts(r.namespace).Delete(ctx, r.svcAccName, metav1.DeleteOptions{})
186190
}
187191

188192
// syncServiceAccount syncs required service account.
189193
func (r *KubeRemote) syncServiceAccount() error {
194+
ctx := context.TODO()
190195
// delete before create
191196
r.deleteServiceAccount()
192-
_, err := r.cs.CoreV1().ServiceAccounts(r.namespace).Create(createServiceAccountManifest(r.svcAccName))
197+
_, err := r.cs.CoreV1().ServiceAccounts(r.namespace).Create(
198+
ctx,
199+
createServiceAccountManifest(r.svcAccName),
200+
metav1.CreateOptions{})
193201
if err != nil {
194202
return errors.Wrap(err, "failed to create service account")
195203
}
196-
_, err = r.cs.RbacV1().ClusterRoles().Create(createClusterRoleManifest(r.name))
204+
_, err = r.cs.RbacV1().ClusterRoles().Create(ctx, createClusterRoleManifest(r.name), metav1.CreateOptions{})
197205
if err != nil {
198206
return errors.Wrap(err, "failed to create cluster role")
199207
}
200-
_, err = r.cs.RbacV1().ClusterRoleBindings().Create(createClusterRoleBindingManifest(r.name, r.namespace, r.svcAccName))
208+
_, err = r.cs.RbacV1().ClusterRoleBindings().Create(
209+
ctx,
210+
createClusterRoleBindingManifest(r.name, r.namespace, r.svcAccName),
211+
metav1.CreateOptions{})
201212
if err != nil {
202213
return errors.Wrap(err, "failed to create cluster role binding")
203214
}
@@ -212,17 +223,20 @@ func (r *KubeRemote) createPod(env map[string]string, cmd ...string) (*apiv1.Pod
212223
}
213224
image := fmt.Sprintf("golang:%s", version)
214225
r.deletePod() // ensure it doesn't already exist
215-
return r.cs.CoreV1().Pods(r.namespace).Create(createPodManifest(r.name, image, env, cmd, r.workDir, r.destDir, r.secretName, r.svcAccName))
226+
return r.cs.CoreV1().Pods(r.namespace).Create(
227+
context.TODO(),
228+
createPodManifest(r.name, image, env, cmd, r.workDir, r.destDir, r.secretName, r.svcAccName),
229+
metav1.CreateOptions{})
216230
}
217231

218232
// deletePod deletes the pod.
219233
func (r *KubeRemote) deletePod() {
220-
_ = r.cs.CoreV1().Pods(r.namespace).Delete(r.name, &metav1.DeleteOptions{})
234+
_ = r.cs.CoreV1().Pods(r.namespace).Delete(context.TODO(), r.name, metav1.DeleteOptions{})
221235
}
222236

223237
// waitForPod waits for the created pod to match the given condition.
224238
func (r *KubeRemote) waitForPod(wait time.Duration, condition watchtools.ConditionFunc) (*apiv1.Pod, error) {
225-
w, err := r.cs.CoreV1().Pods(r.namespace).Watch(metav1.SingleObject(metav1.ObjectMeta{Name: r.name}))
239+
w, err := r.cs.CoreV1().Pods(r.namespace).Watch(context.TODO(), metav1.SingleObject(metav1.ObjectMeta{Name: r.name}))
226240
if err != nil {
227241
return nil, err
228242
}
@@ -276,7 +290,7 @@ func (r *KubeRemote) streamLogs(container string, stdout io.Writer) error {
276290
Container: container,
277291
Follow: true,
278292
})
279-
logs, err := req.Stream()
293+
logs, err := req.Stream(context.TODO())
280294
if err != nil {
281295
return err
282296
}

dev-tools/mage/kubernetes/kubernetes.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ package kubernetes
1919

2020
import (
2121
"fmt"
22+
"io"
2223
"io/ioutil"
2324
"log"
2425
"os"
2526
"path/filepath"
2627
"strings"
28+
"time"
2729

2830
"github.com/magefile/mage/mg"
2931
"github.com/pkg/errors"
@@ -114,6 +116,11 @@ func (d *KubernetesIntegrationTester) Test(dir string, mageTarget string, env ma
114116
}
115117
}()
116118

119+
err = waitKubeStateMetricsReadiness(env, stdOut, stdErr)
120+
if err != nil {
121+
return err
122+
}
123+
117124
// Pass all environment variables inside the pod, except for KUBECONFIG as the test
118125
// should use the environment set by kubernetes on the pod.
119126
insideEnv := map[string]string{}
@@ -142,6 +149,29 @@ func (d *KubernetesIntegrationTester) InsideTest(test func() error) error {
142149
return test()
143150
}
144151

152+
// waitKubeStateMetricsReadiness waits until kube-state-metrics Pod is ready to receive requests
153+
func waitKubeStateMetricsReadiness(env map[string]string, stdOut, stdErr io.Writer) error {
154+
checkKubeStateMetricsReadyAttempts := 10
155+
readyAttempts := 1
156+
for {
157+
err := KubectlWait(env, stdOut, stdErr, "condition=ready", "pod", "app=kube-state-metrics")
158+
if err != nil {
159+
if mg.Verbose() {
160+
fmt.Println("Kube-state-metrics is not ready yet...retrying")
161+
}
162+
} else {
163+
break
164+
}
165+
if readyAttempts > checkKubeStateMetricsReadyAttempts {
166+
return errors.Wrapf(err, "Timeout waiting for kube-state-metrics")
167+
}
168+
time.Sleep(6 * time.Second)
169+
readyAttempts += 1
170+
}
171+
// kube-state-metrics ready, return with no error
172+
return nil
173+
}
174+
145175
// kubernetesPodName returns the pod name to use with kubernetes.
146176
func kubernetesPodName() string {
147177
commit, err := mage.CommitHash()

go.mod

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ require (
133133
github.com/sanathkr/yaml v1.0.1-0.20170819201035-0056894fa522 // indirect
134134
github.com/shirou/gopsutil v2.19.11+incompatible
135135
github.com/spf13/cobra v0.0.3
136-
github.com/spf13/pflag v1.0.3
136+
github.com/spf13/pflag v1.0.5
137137
github.com/stretchr/testify v1.5.0
138138
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
139139
github.com/tsg/gopacket v0.0.0-20190320122513-dd3d0e41124a
@@ -160,17 +160,14 @@ require (
160160
google.golang.org/api v0.15.0
161161
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
162162
google.golang.org/grpc v1.27.1
163-
gopkg.in/inf.v0 v0.9.0
163+
gopkg.in/inf.v0 v0.9.1
164164
gopkg.in/jcmturner/gokrb5.v7 v7.5.0
165165
gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528
166166
gopkg.in/yaml.v2 v2.3.0
167167
howett.net/plist v0.0.0-20181124034731-591f970eefbb
168-
k8s.io/api v0.0.0-20190722141453-b90922c02518
169-
k8s.io/apimachinery v0.0.0-20190719140911-bfcf53abc9f8
170-
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
171-
k8s.io/klog v0.3.4-0.20190719014911-6a023d6d0e09 // indirect
172-
k8s.io/utils v0.0.0-20190712204705-3dccf664f023 // indirect
173-
sigs.k8s.io/yaml v1.1.1-0.20190704183835-4cd0c284b15f // indirect
168+
k8s.io/api v0.18.3
169+
k8s.io/apimachinery v0.18.3
170+
k8s.io/client-go v0.18.3
174171
)
175172

176173
replace (

0 commit comments

Comments
 (0)