registry: only warn, if configmap couldn't be created in any node, as one is enough.

pull/447/head
iwilltry42 4 years ago
parent 680a6974c6
commit d17a2aefa9
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 14
      pkg/client/cluster.go
  2. 4
      tests/test_config_file.sh

@ -206,7 +206,7 @@ func ClusterPrep(ctx context.Context, runtime k3drt.Runtime, clusterConfig *conf
if err != nil {
return fmt.Errorf("Failed to generate LocalRegistryHosting configmap: %+v", err)
}
log.Errorf("Writing YAML: %s", string(regCm))
log.Tracef("Writing LocalRegistryHosting YAML:\n%s", string(regCm))
clusterConfig.ClusterCreateOpts.NodeHooks = append(clusterConfig.ClusterCreateOpts.NodeHooks, k3d.NodeHook{
Stage: k3d.LifecycleStagePreStart,
Action: actions.WriteFileAction{
@ -912,12 +912,20 @@ func prepInjectHostIP(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.C
}
func prepCreateLocalRegistryHostingConfigMap(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster) error {
success := false
for _, node := range cluster.Nodes {
if node.Role == k3d.AgentRole || node.Role == k3d.ServerRole {
if err := runtime.ExecInNode(ctx, node, []string{"sh", "-c", "kubectl apply -f /tmp/reg.yaml"}); err != nil {
log.Warnf("Failed to create cm in node '%s'", node.Name)
err := runtime.ExecInNode(ctx, node, []string{"sh", "-c", "kubectl apply -f /tmp/reg.yaml"})
if err == nil {
success = true
break
} else {
log.Debugf("Failed to create LocalRegistryHosting ConfigMap in node %s: %+v", node.Name, err)
}
}
}
if success == false {
log.Warnf("Failed to create LocalRegistryHosting ConfigMap")
}
return nil
}

@ -43,6 +43,10 @@ exec_in_node "k3d-$clustername-server-0" "env" | grep "bar=baz" || failed "Expec
info "Ensuring that container labels have been set as stated in the config"
docker_assert_container_label "k3d-$clustername-server-0" "foo=bar" || failed "Expected label 'foo=bar' not present on container/node k3d-$clustername-server-0"
## Registry Node
info "Ensuring, that we have a registry node present"
$EXE node list "k3d-$clustername-registry" || failed "Expected k3d-$clustername-registry to be present"
# Cleanup
info "Deleting cluster $clustername..."

Loading…
Cancel
Save