Skip to content
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

Fix some bugs #1795

Merged
merged 2 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pkg/cluster-runtime/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (i *Installer) runHostHook(phase Phase, hosts []net.IP) error {
sort.Sort(hookConfigList)
for _, hookConfig := range hookConfigList {
var targetHosts []net.IP
expectedHosts := i.infraDriver.GetHostIPListByRole(string(hookConfig.Scope))
expectedHosts := i.getHostIPListByScope(hookConfig.Scope)
// Make sure each host got from Scope is in the given host ip list.
for _, expected := range expectedHosts {
if netUtils.IsInIPList(expected, hosts) {
Expand Down Expand Up @@ -151,6 +151,24 @@ func (i *Installer) runClusterHook(master0 net.IP, phase Phase) error {
return nil
}

// getHostIPListByScope get ip list for scope, support use '|' to specify multiple scopes, they are ORed
func (i *Installer) getHostIPListByScope(scope Scope) []net.IP {
var ret []net.IP
scopes := strings.Split(string(scope), "|")
for _, s := range scopes {
hosts := i.infraDriver.GetHostIPListByRole(strings.TrimSpace(s))

// remove duplicates
for _, h := range hosts {
if !netUtils.IsInIPList(h, ret) {
ret = append(ret, h)
}
}
}

return ret
}

func NewShellHook() HookFunc {
return func(data string, hosts []net.IP, driver infradriver.InfraDriver) error {
rootfs := driver.GetClusterRootfsPath()
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rm -rf /etc/kubernetes/ && \
rm -rf /etc/systemd/system/kubelet.service.d && rm -rf /etc/systemd/system/kubelet.service && \
rm -rf /usr/bin/kubeadm && rm -rf /usr/bin/kubelet-pre-start.sh && \
rm -rf /usr/bin/kubelet && rm -rf /usr/bin/kubectl && \
rm -rf /var/lib/kubelet && rm -rf /etc/sysctl.d/k8s.conf && \
rm -rf /var/lib/kubelet/* && rm -rf /etc/sysctl.d/k8s.conf && \
rm -rf /etc/cni && rm -rf /opt/cni && \
rm -rf /var/lib/etcd && rm -rf /var/etcd
`
Expand Down