Merge pull request #172 from inercia/inercia/fix_registries_yaml_overwrite

[Fix] Do not try to write the registries.yaml if --enable-registry has not been provided (thanks @inercia)
This commit is contained in:
Thorsten Klein 2020-01-21 18:07:48 +01:00 committed by GitHub
commit ecd86ed993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 8 deletions

View File

@ -152,8 +152,10 @@ func createServer(spec *ClusterSpec) (string, error) {
}
// copy the registry configuration
if err := writeRegistriesConfigInContainer(spec, id); err != nil {
return "", err
if spec.RegistryEnabled {
if err := writeRegistriesConfigInContainer(spec, id); err != nil {
return "", err
}
}
if err := startContainer(id); err != nil {
@ -248,8 +250,10 @@ func createWorker(spec *ClusterSpec, postfix int) (string, error) {
}
// copy the registry configuration
if err := writeRegistriesConfigInContainer(spec, id); err != nil {
return "", err
if spec.RegistryEnabled {
if err := writeRegistriesConfigInContainer(spec, id); err != nil {
return "", err
}
}
if err := startContainer(id); err != nil {

View File

@ -8,8 +8,15 @@ source "$CURR_DIR/common.sh"
#########################################################################################
FIXTURES_DIR=$CURR_DIR/fixtures
# a dummy registries.yaml file
REGISTRIES_YAML=$FIXTURES_DIR/01-registries-empty.yaml
#########################################################################################
info "Creating two clusters..."
$EXE create --wait 60 --name "c1" --api-port 6443 || failed "could not create cluster c1"
$EXE create --wait 60 --name "c1" --api-port 6443 -v $REGISTRIES_YAML:/etc/rancher/k3s/registries.yaml || failed "could not create cluster c1"
$EXE create --wait 60 --name "c2" --api-port 6444 || failed "could not create cluster c2"
info "Checking we have access to both clusters..."

View File

@ -58,12 +58,14 @@ check_url() {
}
check_k3d_clusters() {
[ -n "$EXE" ] || abort "EXE is not defined"
for c in "c1" "c2" ; do
kc=$($EXE get-kubeconfig --name "$c")
if kubectl --kubeconfig=$kc cluster-info ; then
passed "cluster $c is reachable"
[ -n "$kc" ] || abort "could not obtain a kubeconfig for $c"
if kubectl --kubeconfig="$kc" cluster-info ; then
passed "cluster $c is reachable (with kubeconfig=$kc)"
else
warn "could not obtain cluster info for $c with kubeconfig=$kc. Contents:\n$(cat $kc)"
warn "could not obtain cluster info for $c (with kubeconfig=$kc). Contents:\n$(cat $kc)"
return 1
fi
done

View File

@ -0,0 +1,4 @@
mirrors:
"dummy.local":
endpoint:
- http://localhost:32000