Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cc825813
Unverified
Commit
cc825813
authored
Apr 16, 2021
by
Menna Elmasry
Committed by
GitHub
Apr 16, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3210 from MonzElmasry/fix_ci_1.19
[backport 1.19] Fix ci flakey tests and image pull registry
parents
72e8196c
f14540cc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
15 deletions
+71
-15
.drone.yml
.drone.yml
+3
-0
Dockerfile.test.dapper
Dockerfile.test.dapper
+2
-2
Dockerfile
package/Dockerfile
+1
-0
test-helpers
scripts/test-helpers
+65
-13
No files found.
.drone.yml
View file @
cc825813
...
@@ -65,6 +65,7 @@ steps:
...
@@ -65,6 +65,7 @@ steps:
image
:
rancher/dapper:v0.5.0
image
:
rancher/dapper:v0.5.0
secrets
:
[
gcloud_auth
]
secrets
:
[
gcloud_auth
]
environment
:
environment
:
ENABLE_REGISTRY
:
'
true'
GCLOUD_AUTH
:
GCLOUD_AUTH
:
from_secret
:
gcloud_auth
from_secret
:
gcloud_auth
commands
:
commands
:
...
@@ -160,6 +161,7 @@ steps:
...
@@ -160,6 +161,7 @@ steps:
image
:
rancher/dapper:v0.5.0
image
:
rancher/dapper:v0.5.0
secrets
:
[
gcloud_auth
]
secrets
:
[
gcloud_auth
]
environment
:
environment
:
ENABLE_REGISTRY
:
'
true'
GCLOUD_AUTH
:
GCLOUD_AUTH
:
from_secret
:
gcloud_auth
from_secret
:
gcloud_auth
commands
:
commands
:
...
@@ -239,6 +241,7 @@ steps:
...
@@ -239,6 +241,7 @@ steps:
image
:
rancher/dapper:v0.5.0
image
:
rancher/dapper:v0.5.0
secrets
:
[
gcloud_auth
]
secrets
:
[
gcloud_auth
]
environment
:
environment
:
ENABLE_REGISTRY
:
'
true'
GCLOUD_AUTH
:
GCLOUD_AUTH
:
from_secret
:
gcloud_auth
from_secret
:
gcloud_auth
commands
:
commands
:
...
...
Dockerfile.test.dapper
View file @
cc825813
...
@@ -17,8 +17,8 @@ RUN OS=linux; \
...
@@ -17,8 +17,8 @@ RUN OS=linux; \
ENV TEST_CLEANUP true
ENV TEST_CLEANUP true
ENV DAPPER_RUN_ARGS --privileged --network host
ENV DAPPER_RUN_ARGS --privileged --network host
-v /tmp:/tmp
ENV DAPPER_ENV REPO TAG DRONE_TAG DRONE_BUILD_EVENT IMAGE_NAME GCLOUD_AUTH
ENV DAPPER_ENV REPO TAG DRONE_TAG DRONE_BUILD_EVENT IMAGE_NAME GCLOUD_AUTH
SONOBUOY_VERSION ENABLE_REGISTRY
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/
ENV DAPPER_OUTPUT ./dist
ENV DAPPER_OUTPUT ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_DOCKER_SOCKET true
...
...
package/Dockerfile
View file @
cc825813
...
@@ -17,5 +17,6 @@ VOLUME /var/lib/rancher/k3s
...
@@ -17,5 +17,6 @@ VOLUME /var/lib/rancher/k3s
VOLUME
/var/lib/cni
VOLUME
/var/lib/cni
VOLUME
/var/log
VOLUME
/var/log
ENV
PATH="$PATH:/bin/aux"
ENV
PATH="$PATH:/bin/aux"
ENV
CRI_CONFIG_FILE="/var/lib/rancher/k3s/agent/etc/crictl.yaml"
ENTRYPOINT
["/bin/k3s"]
ENTRYPOINT
["/bin/k3s"]
CMD
["agent"]
CMD
["agent"]
scripts/test-helpers
View file @
cc825813
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# ---
# ---
port-used
()
{
port-used
()
{
(
cat
</dev/null
>
/dev/tcp/127.0.0.1/
$1
)
2>/dev/null
netstat
-tuna
|
grep
-q
":
$1
"
}
}
export
-f
port-used
export
-f
port-used
...
@@ -133,16 +133,18 @@ dump-logs() {
...
@@ -133,16 +133,18 @@ dump-logs() {
[
"
$name
"
]
||
continue
[
"
$name
"
]
||
continue
mkdir
-p
$node
/logs
mkdir
-p
$node
/logs
local hostname
=
$(
docker
exec
$name
hostname
)
local hostname
=
$(
docker
exec
$name
hostname
)
docker
exec
$server
kubectl describe node/
$hostname
>
$node
/logs/kubectl-describe-node.txt
docker
cp
$name
:/var/lib/rancher/k3s/agent/containerd/containerd.log
$node
/logs/containerd.log 2>/dev/null
docker logs
$name
>
$node
/logs/system.log 2>&1
docker logs
$name
>
$node
/logs/system.log 2>&1
docker
exec
$name
crictl pods
>
$node
/logs/crictl-pods.txt
if
[[
$name
==
k3s-
*
]]
;
then
docker
exec
$name
crictl ps
-a
>
$node
/logs/crictl-ps.txt
docker
exec
$server
kubectl describe node/
$hostname
>
$node
/logs/kubectl-describe-node.txt
docker
exec
$name
crictl ps
-a
-o
json
>
$node
/metadata/crictl-ps.json
docker
cp
$name
:/var/lib/rancher/k3s/agent/containerd/containerd.log
$node
/logs/containerd.log 2>/dev/null
for
container
in
$(
jq
-r
'.containers[].id'
<
$node
/metadata/crictl-ps.json
)
;
do
docker
exec
$name
crictl pods
>
$node
/logs/crictl-pods.txt
local
cname
=
$(
jq
-r
'.containers[] | select(.id == "'
$container
'") | .metadata.name'
<
$node
/metadata/crictl-ps.json
)
docker
exec
$name
crictl ps
-a
>
$node
/logs/crictl-ps.txt
docker
exec
$name
crictl logs
$container
>
$node
/logs/
$cname
-
$container
.log 2>&1
docker
exec
$name
crictl ps
-a
-o
json
>
$node
/metadata/crictl-ps.json
done
for
container
in
$(
jq
-r
'.containers[].id'
<
$node
/metadata/crictl-ps.json
)
;
do
local
cname
=
$(
jq
-r
'.containers[] | select(.id == "'
$container
'") | .metadata.name'
<
$node
/metadata/crictl-ps.json
)
docker
exec
$name
crictl logs
$container
>
$node
/logs/
$cname
-
$container
.log 2>&1
done
fi
for
log
in
$node
/logs/
*
.log
;
do
for
log
in
$node
/logs/
*
.log
;
do
echo
echo
echo
"#- Tail:
$log
"
echo
"#- Tail:
$log
"
...
@@ -234,7 +236,7 @@ sonobuoy-test() {
...
@@ -234,7 +236,7 @@ sonobuoy-test() {
--plugin-env
=
e2e.E2E_USE_GO_RUNNER
=
true
\
--plugin-env
=
e2e.E2E_USE_GO_RUNNER
=
true
\
--sonobuoy-image
=
rancher/sonobuoy-sonobuoy:v
${
SONOBUOY_VERSION
:-
0
.19.0
}
\
--sonobuoy-image
=
rancher/sonobuoy-sonobuoy:v
${
SONOBUOY_VERSION
:-
0
.19.0
}
\
--kube-conformance-image-version
=
${
VERSION_K8S
}
\
--kube-conformance-image-version
=
${
VERSION_K8S
}
\
--wait
=
3
0
\
--wait
=
9
0
\
$@
&
$@
&
local
sonobuoyPID
=
$!
local
sonobuoyPID
=
$!
...
@@ -287,8 +289,8 @@ test-setup() {
...
@@ -287,8 +289,8 @@ test-setup() {
mkdir
-p
$TEST_DIR
/metadata
mkdir
-p
$TEST_DIR
/metadata
if
[
"
$LABEL
"
]
;
then
if
[
"
$LABEL
"
]
;
then
exec
>
>(
awk
-W
interactive
"{ printf
\"
[
\0
33[36m
${
LABEL
}
\0
33[m] %s
\n\"
,
\$
0
}"
)
\
exec
>
>(
awk
"{ printf
\"
[
\0
33[36m
${
LABEL
}
\0
33[m] %s
\n\"
,
\$
0; fflush()
}"
)
\
2>
>(
awk
-W
interactive
"{ printf
\"
[
\0
33[35m
${
LABEL
}
\0
33[m] %s
\n\"
,
\$
0
}"
>
&2
)
2>
>(
awk
"{ printf
\"
[
\0
33[35m
${
LABEL
}
\0
33[m] %s
\n\"
,
\$
0; fflush()
}"
>
&2
)
echo
"
$LABEL
"
>
$TEST_DIR
/metadata/label
echo
"
$LABEL
"
>
$TEST_DIR
/metadata/label
fi
fi
...
@@ -417,6 +419,7 @@ provision-server() {
...
@@ -417,6 +419,7 @@ provision-server() {
-p
6443
\
-p
6443
\
-e
K3S_TOKEN
=
$(
cat
$TEST_DIR
/metadata/secret
)
\
-e
K3S_TOKEN
=
$(
cat
$TEST_DIR
/metadata/secret
)
\
-e
K3S_DEBUG
=
true
\
-e
K3S_DEBUG
=
true
\
${
REGISTRY_CLUSTER_ARGS
:-}
\
$K3S_IMAGE
server
$ARGS
$SERVER_ARGS
${
!SERVER_INSTANCE_ARGS
}
$K3S_IMAGE
server
$ARGS
$SERVER_ARGS
${
!SERVER_INSTANCE_ARGS
}
local
ip
=
$(
docker inspect
--format
'{{ .NetworkSettings.IPAddress }}'
$name
|
tee
$TEST_DIR
/servers/
$count
/metadata/ip
)
local
ip
=
$(
docker inspect
--format
'{{ .NetworkSettings.IPAddress }}'
$name
|
tee
$TEST_DIR
/servers/
$count
/metadata/ip
)
...
@@ -443,6 +446,7 @@ provision-agent() {
...
@@ -443,6 +446,7 @@ provision-agent() {
--privileged
\
--privileged
\
-e
K3S_TOKEN
=
$(
cat
$TEST_DIR
/metadata/secret
)
\
-e
K3S_TOKEN
=
$(
cat
$TEST_DIR
/metadata/secret
)
\
-e
K3S_URL
=
$K3S_URL
\
-e
K3S_URL
=
$K3S_URL
\
${
REGISTRY_CLUSTER_ARGS
:-}
\
$K3S_IMAGE
agent
$ARGS
$AGENT_ARGS
${
!AGENT_INSTANCE_ARGS
}
$K3S_IMAGE
agent
$ARGS
$AGENT_ARGS
${
!AGENT_INSTANCE_ARGS
}
echo
"Started
$name
"
echo
"Started
$name
"
...
@@ -455,6 +459,10 @@ export -f provision-agent
...
@@ -455,6 +459,10 @@ export -f provision-agent
provision-cluster
()
{
provision-cluster
()
{
run-function cluster-pre-hook
run-function cluster-pre-hook
if
[
"
${
ENABLE_REGISTRY
}
"
==
'true'
]
;
then
provision-registry-proxy
fi
for
i
in
$(
seq
1
$NUM_SERVERS
)
;
do
for
i
in
$(
seq
1
$NUM_SERVERS
)
;
do
provision-server
provision-server
timeout
--foreground
120s bash
-c
"wait-for-kubeconfig
$i
"
timeout
--foreground
120s bash
-c
"wait-for-kubeconfig
$i
"
...
@@ -478,6 +486,50 @@ export -f provision-cluster
...
@@ -478,6 +486,50 @@ export -f provision-cluster
# ---
# ---
provision-registry-proxy
()
{
set
-e
-o
pipefail
local
image
=
"docker.io/library/registry:2.7.1"
local
prefix
=
"docker-registry-"
local
registries
=
"docker.io:registry-1.docker.io k8s.gcr.io gcr.io quay.io ghcr.io"
local
registries_yaml
=
"
$TEST_DIR
/registries.yaml"
echo
"mirrors:"
>
$registries_yaml
for
registry
in
$registries
;
do
IFS
=
:
read
registry_name registry_endpoint
<<<
$registry
if
[
-z
"
$registry_endpoint
"
]
;
then
registry_endpoint
=
$registry_name
fi
local
name
=
"registry_
${
registry_name
//./_
}
"
local
status
=
$(
docker inspect
$name
--format
'{{ .State.Status }} {{ .Config.Image }} {{ (index .HostConfig.PortBindings "5000/tcp" 0).HostPort }}'
2>/dev/null
||
true
)
read
state_status config_image hostport
<<<
$status
if
[
"
$state_status
"
!=
"running"
]
||
[
"
$config_image
"
!=
"
$image
"
]
;
then
hostport
=
$(
timeout
--foreground
5s bash
-c
get-port
)
docker
rm
--force
$name
2>/dev/null
||
true
docker run
\
-d
--name
$name
\
-p
0.0.0.0:
$hostport
:5000
\
-v
"registry-cache:/var/lib/registry"
\
-e
"REGISTRY_HTTP_SECRET=shared-secret"
\
-e
"REGISTRY_PROXY_REMOTEURL=https://
$registry_endpoint
"
\
-e
"REGISTRY_STORAGE_CACHE_BLOBDESCRIPTOR=inmemory"
\
-e
"REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry/
$registry_name
"
\
$image
fi
echo
-e
"
$registry_name
:
\n
endpoint:
\n
- http://172.17.0.1:
$hostport
"
>>
$registries_yaml
done
echo
"Using registry mirror with cluster registries.yaml:"
cat
$registries_yaml
export
REGISTRY_CLUSTER_ARGS
=
"-v
$registries_yaml
:/etc/rancher/k3s/registries.yaml"
}
export
-f
provision-registry-proxy
# ---
early-exit
()
{
early-exit
()
{
printf
"
\0
33[33m
$1
\0
33[m
\n
"
printf
"
\0
33[33m
$1
\0
33[m
\n
"
exit
$2
exit
$2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment