Skip to content

Use lock to ensure safe build configuration under goroutine. #2673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2023

Conversation

bxy4543
Copy link
Member

@bxy4543 bxy4543 commented Feb 26, 2023

@cla-assistant
Copy link

cla-assistant bot commented Feb 26, 2023

CLA assistant check
All committers have signed the CLA.

@zzjin zzjin requested a review from cuisongliu February 26, 2023 15:54
@codecov
Copy link

codecov bot commented Feb 26, 2023

Codecov Report

Base: 64.81% // Head: 64.81% // No change to project coverage 👍

Coverage data is based on head (a5ebbf7) compared to base (f7950cb).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2673   +/-   ##
=======================================
  Coverage   64.81%   64.81%           
=======================================
  Files           8        8           
  Lines         577      577           
=======================================
  Hits          374      374           
  Misses        171      171           
  Partials       32       32           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@labring labring deleted a comment from cla-assistant bot Feb 26, 2023
@cuisongliu
Copy link
Collaborator

@willzhang Can you help me test it?

@zzjin zzjin added kind/bug Something isn't working good first issue Good for newcomers priority: high labels Feb 26, 2023
@willzhang
Copy link
Contributor

willzhang commented Feb 26, 2023

sealos version

root@node22:/data/sealos# sealos version
CriVersionInfo:
  RuntimeApiVersion: v1
  RuntimeName: containerd
  RuntimeVersion: v1.6.17
  Version: 0.1.0
KubernetesVersionInfo:
  clientVersion:
    buildDate: "2023-01-18T19:15:31Z"
    compiler: gc
    gitCommit: 5c1d2d4295f9b4eb12bfbf6429fdf989f2ca8a02
    gitTreeState: clean
    gitVersion: v1.24.10
    goVersion: go1.19.5
    major: "1"
    minor: "24"
    platform: linux/amd64
  kustomizeVersion: v4.5.4
  serverVersion:
    buildDate: "2023-01-18T19:08:10Z"
    compiler: gc
    gitCommit: 5c1d2d4295f9b4eb12bfbf6429fdf989f2ca8a02
    gitTreeState: clean
    gitVersion: v1.24.10
    goVersion: go1.19.5
    major: "1"
    minor: "24"
    platform: linux/amd64
SealosVersion:
  buildDate: 2023-02-26T17:03:18+0000
  compiler: gc
  gitCommit: 1180209a
  gitVersion: untagged
  goVersion: go1.20.1
  platform: linux/amd64

new error log

[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node node22 as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node node22 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule node-role.kubernetes.io/control-plane:NoSchedule]
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of control-plane nodes by copying certificate authorities
and service account keys on each node and then running the following as root:

  kubeadm join apiserver.cluster.local:6443 --token <value withheld> \
        --discovery-token-ca-cert-hash sha256:0d5449bc2066781a4257ccbfd9aadb51de236d8b68dcdeeb04138fc8457a5606 \
        --control-plane --certificate-key <value withheld>

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join apiserver.cluster.local:6443 --token <value withheld> \
        --discovery-token-ca-cert-hash sha256:0d5449bc2066781a4257ccbfd9aadb51de236d8b68dcdeeb04138fc8457a5606 
2023-02-27T01:45:52 info Executing pipeline Join in CreateProcessor.
2023-02-27T01:45:52 info [192.168.0.23:22 192.168.0.24:22 192.168.0.30:22] will be added as worker
2023-02-27T01:45:52 info start to get kubernetes token...
2023-02-27T01:45:55 info start to join 192.168.0.30:22 as worker
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2ef8c1b]

goroutine 2604 [running]:
sync.(*Mutex).Lock(...)
        sync/mutex.go:83
github.com/labring/sealos/pkg/runtime.(*KubeadmRuntime).joinNodes.func1()
        github.com/labring/sealos/pkg/runtime/node.go:45 +0xbb
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/[email protected]/errgroup/errgroup.go:72 +0xa5
root@node22:/data/sealos#  

How to reproduce

root@node22:/data/sealos# cat install.sh
#!/bin/bash
sealos run \
hub.sealos.cn/labring/kubernetes:v1.24.10 \
hub.sealos.cn/labring/helm:v3.11.0 \
hub.sealos.cn/labring/calico:v3.24.5 \
registry.cn-shenzhen.aliyuncs.com/cnmirror/openebs:v3.4.0 \
registry.cn-shenzhen.aliyuncs.com/cnmirror/kubesphere:v3.3.2 \
--masters 192.168.0.22 \
--nodes 192.168.0.23,192.168.0.24,192.168.0.30 \
-p 123456

root@node22:/data/sealos# bash install.sh

and why reset failed

root@node22:/data/sealos# sealos reset --force
2023-02-27T01:52:36 warn failed to exec delete process, failed to delete runtime, master hosts cannot be empty
2023-02-27T01:52:36 warn failed to exec delete process, failed to create ssh session for : ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
2023-02-27T01:52:38 info succeeded in deleting current cluster
2023-02-27T01:52:38 info 
      ___           ___           ___           ___       ___           ___
     /\  \         /\  \         /\  \         /\__\     /\  \         /\  \
    /::\  \       /::\  \       /::\  \       /:/  /    /::\  \       /::\  \
   /:/\ \  \     /:/\:\  \     /:/\:\  \     /:/  /    /:/\:\  \     /:/\ \  \
  _\:\~\ \  \   /::\~\:\  \   /::\~\:\  \   /:/  /    /:/  \:\  \   _\:\~\ \  \
 /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/    /:/__/ \:\__\ /\ \:\ \ \__\
 \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/  / \:\  \    \:\  \ /:/  / \:\ \:\ \/__/
  \:\ \:\__\    \:\ \:\__\        \::/  /   \:\  \    \:\  /:/  /   \:\ \:\__\
   \:\/:/  /     \:\ \/__/        /:/  /     \:\  \    \:\/:/  /     \:\/:/  /
    \::/  /       \:\__\         /:/  /       \:\__\    \::/  /       \::/  /
     \/__/         \/__/         \/__/         \/__/     \/__/         \/__/

                  Website: https://www.sealos.io/
                  Address: github.com/labring/sealos
                  Version: untagged-1180209a

Clusterfile lost?

root@node22:/data/sealos# ll /root/.sealos/default/
total 12
drwxr-xr-x 2 root root 4096 Feb 27 01:52 ./
drwxr-xr-x 4 root root 4096 Feb 27 01:52 ../
-rw-r--r-- 1 root root 3150 Feb 27 01:52 Clusterfile.1677433956

@cuisongliu cuisongliu linked an issue Feb 27, 2023 that may be closed by this pull request
@cuisongliu cuisongliu merged commit d073a0e into labring:main Feb 27, 2023
@bxy4543 bxy4543 deleted the fix_concurrent_map branch April 14, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/bug Something isn't working priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: sealos run error with fatal error: concurrent map writes
5 participants