Skip to content

Commit 84f81dc

Browse files
committed
fix: create cluster error in cluster node
Signed-off-by: redscholar <blacktiledhouse@gmail.com>
1 parent 4eec1ab commit 84f81dc

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

builtin/core/playbooks/create_cluster.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
- hosts:
5050
- localhost
5151
roles:
52-
- image-registry/push
52+
- role: image-registry/push
53+
when:
54+
- .groups.image_registry | empty | not
55+
- .image_registry.type | empty | not
5356

5457
# Install the Kubernetes cluster
5558
- hosts:

builtin/core/roles/defaults/defaults/main/10-download.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ download:
143143
images:
144144
manifests: []
145145
# Architectures for which images should be downloaded.
146-
registry: >
146+
registry: >-
147147
{{- if .zone | eq "cn" }}
148148
hub.kubesphere.com.cn
149149
{{- end }}

pkg/modules/copy/copy.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/cockroachdb/errors"
2929
kkcorev1alpha1 "github.com/kubesphere/kubekey/api/core/v1alpha1"
3030
"k8s.io/apimachinery/pkg/runtime"
31+
"k8s.io/apimachinery/pkg/util/rand"
3132
"k8s.io/klog/v2"
3233
"k8s.io/utils/ptr"
3334

@@ -250,7 +251,7 @@ func (ca copyArgs) copyAbsoluteDir(ctx context.Context, conn connector.Connector
250251
}
251252
dest := filepath.Join(ca.dest, rel)
252253

253-
tmpDest := filepath.Join("/tmp", dest)
254+
tmpDest := filepath.Join("/tmp", dest+"."+rand.String(5))
254255

255256
if err = conn.PutFile(ctx, data, tmpDest, mode); err != nil {
256257
return err
@@ -294,7 +295,7 @@ func (ca copyArgs) copyRelativeDir(ctx context.Context, pj project.Project, relP
294295
}
295296
dest := filepath.Join(ca.dest, rel)
296297

297-
tmpDest := filepath.Join("/tmp", dest)
298+
tmpDest := filepath.Join("/tmp", dest+"."+rand.String(5))
298299

299300
err = conn.PutFile(ctx, data, tmpDest, mode)
300301
if err != nil {
@@ -329,7 +330,7 @@ func (ca copyArgs) copyContent(ctx context.Context, mode fs.FileMode, conn conne
329330
mode = os.FileMode(*ca.mode)
330331
}
331332

332-
tmpDest := filepath.Join("/tmp", ca.dest)
333+
tmpDest := filepath.Join("/tmp", ca.dest+"."+rand.String(5))
333334

334335
if err := conn.PutFile(ctx, []byte(ca.content), tmpDest, mode); err != nil {
335336
return internal.StdoutFailed, "failed to copy file", err
@@ -355,7 +356,7 @@ func (ca copyArgs) copyFile(ctx context.Context, data []byte, mode fs.FileMode,
355356
if ca.mode != nil {
356357
mode = os.FileMode(*ca.mode)
357358
}
358-
tmpDest := filepath.Join("/tmp", dest)
359+
tmpDest := filepath.Join("/tmp", dest+"."+rand.String(5))
359360

360361
if err := conn.PutFile(ctx, data, tmpDest, mode); err != nil {
361362
return err

pkg/modules/template/template.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/cockroachdb/errors"
2929
kkcorev1alpha1 "github.com/kubesphere/kubekey/api/core/v1alpha1"
3030
"k8s.io/apimachinery/pkg/runtime"
31+
"k8s.io/apimachinery/pkg/util/rand"
3132
"k8s.io/klog/v2"
3233
"k8s.io/utils/ptr"
3334

@@ -227,7 +228,7 @@ func handleRelativeDir(ctx context.Context, pj project.Project, relPath string,
227228
}
228229
dest = filepath.Join(ta.dest, rel)
229230
}
230-
tmpDest := filepath.Join("/tmp", dest)
231+
tmpDest := filepath.Join("/tmp", dest+"."+rand.String(5))
231232

232233
if err = conn.PutFile(ctx, result, tmpDest, mode); err != nil {
233234
return err
@@ -254,7 +255,7 @@ func (ta templateArgs) readFile(ctx context.Context, data string, mode fs.FileMo
254255
if ta.mode != nil {
255256
mode = os.FileMode(*ta.mode)
256257
}
257-
tmpDest := filepath.Join("/tmp", dest)
258+
tmpDest := filepath.Join("/tmp", dest+"."+rand.String(5))
258259

259260
if err = conn.PutFile(ctx, result, tmpDest, mode); err != nil {
260261
return err
@@ -303,7 +304,7 @@ func (ta templateArgs) absDir(ctx context.Context, conn connector.Connector, var
303304
dest = filepath.Join(ta.dest, rel)
304305
}
305306

306-
tmpDest := filepath.Join("/tmp", dest)
307+
tmpDest := filepath.Join("/tmp", dest+"."+rand.String(5))
307308

308309
if err = conn.PutFile(ctx, result, tmpDest, mode); err != nil {
309310
return err

0 commit comments

Comments
 (0)