Skip to content

Commit d6b0d39

Browse files
authored
🌱 use ubuntu-22.04 (#1201)
🌱 Update from Ubuntu 20.04 to 22.04
1 parent fea3274 commit d6b0d39

File tree

18 files changed

+174
-48
lines changed

18 files changed

+174
-48
lines changed

Tiltfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ def caph():
142142
yaml = str(encode_yaml_stream(yaml_dict))
143143
yaml = fixup_yaml_empty_arrays(yaml)
144144

145-
# copy things from data directory to .tiltbuild
146-
if not os.path.exists('.tiltbuild/installimage.tgz'):
147-
local("cp data/hetzner-installimage-v1.0.5.tgz .tiltbuild/installimage.tgz")
145+
local("cp data/hetzner-installimage-v1.0.5.tgz .tiltbuild/installimage.tgz")
148146

149147
# Set up a local_resource build of the provider's manager binary.
150148

api/v1beta1/hetznerbaremetalmachine_types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ func Test_Image_String(t *testing.T) {
277277
{
278278
Image{
279279
Name: "nfs",
280-
Path: "/root/.oldroot/nfs/install/../images/Ubuntu-2004-focal-64-minimal-hwe.tar.gz",
280+
Path: "/root/.oldroot/nfs/images/Ubuntu-2204-jammy-amd64-base.tar.gz",
281281
},
282-
"nfs (/root/.oldroot/nfs/install/../images/Ubuntu-2004-focal-64-minimal-hwe.tar.gz)",
282+
"nfs (/root/.oldroot/nfs/images/Ubuntu-2204-jammy-amd64-base.tar.gz)",
283283
},
284284
} {
285285
require.Equal(t, row.expected, row.image.String())

controllers/hetznerbaremetalhost_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,11 @@ name="eth0" model="Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express
884884
StdErr: "",
885885
Err: nil,
886886
})
887+
sshClient.On("GetHardwareDetailsDebug").Return(sshclient.Output{
888+
StdOut: "Dummy outupt",
889+
StdErr: "",
890+
Err: nil,
891+
})
887892
sshClient.On("DownloadImage", mock.Anything, mock.Anything).Return(sshclient.Output{})
888893
sshClient.On("CreateAutoSetup", mock.Anything).Return(sshclient.Output{})
889894
sshClient.On("UntarTGZ").Return(sshclient.Output{})
@@ -892,4 +897,5 @@ name="eth0" model="Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express
892897
sshClient.On("Reboot").Return(sshclient.Output{})
893898
sshClient.On("GetCloudInitOutput").Return(sshclient.Output{StdOut: "dummy content of /var/log/cloud-init-output.log"})
894899
sshClient.On("DetectLinuxOnAnotherDisk", mock.Anything).Return(sshclient.Output{})
900+
sshClient.On("GetRunningInstallImageProcesses").Return(sshclient.Output{})
895901
}

pkg/services/baremetal/client/mocks/ssh/Client.go

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/services/baremetal/client/ssh/ssh_client.go

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ type Client interface {
188188
GetHardwareDetailsCPUFlags() Output
189189
GetHardwareDetailsCPUThreads() Output
190190
GetHardwareDetailsCPUCores() Output
191+
GetHardwareDetailsDebug() Output
192+
GetRunningInstallImageProcesses() Output
191193
GetCloudInitOutput() Output
192194
CreateAutoSetup(data string) Output
193195
DownloadImage(path, url string) Output
@@ -250,7 +252,7 @@ func (c *sshClient) GetHardwareDetailsRAM() Output {
250252

251253
// GetHardwareDetailsNics implements the GetHardwareDetailsNics method of the SSHClient interface.
252254
func (c *sshClient) GetHardwareDetailsNics() Output {
253-
out := c.runSSH(`cat << 'EOF' > nic-info.sh
255+
out := c.runSSH(`cat << 'EOF_VIA_SSH' > nic-info.sh
254256
#!/bin/sh
255257
for iname in $(ip a |awk '/state UP/{print $2}' | sed 's/://')
256258
do
@@ -270,7 +272,7 @@ if test -n $IP_V6; then
270272
fi
271273
272274
done
273-
EOF`)
275+
EOF_VIA_SSH`)
274276
if out.Err != nil || out.StdErr != "" {
275277
return out
276278
}
@@ -322,11 +324,19 @@ func (c *sshClient) GetHardwareDetailsCPUCores() Output {
322324
return c.runSSH(`grep 'cpu cores' /proc/cpuinfo | uniq | awk '{print $4}'`)
323325
}
324326

327+
// GetHardwareDetailsDebug implements the GetHardwareDetailsDebug method of the SSHClient interface.
328+
func (c *sshClient) GetHardwareDetailsDebug() Output {
329+
return c.runSSH(`ip a; echo ==========----------==========;
330+
ethtool "*"; echo ==========----------==========;
331+
lspci; echo ==========----------==========;
332+
`)
333+
}
334+
325335
// CreateAutoSetup implements the CreateAutoSetup method of the SSHClient interface.
326336
func (c *sshClient) CreateAutoSetup(data string) Output {
327-
return c.runSSH(fmt.Sprintf(`cat << 'EOF' > /autosetup
337+
return c.runSSH(fmt.Sprintf(`cat << 'EOF_VIA_SSH' > /autosetup
328338
%s
329-
EOF`, data))
339+
EOF_VIA_SSH`, data))
330340
}
331341

332342
// DownloadImage implements the DownloadImage method of the SSHClient interface.
@@ -345,15 +355,21 @@ OCI_REGISTRY_AUTH_TOKEN=%s /root/download-from-oci.sh %s %s`, downloadFromOciShe
345355

346356
// CreatePostInstallScript implements the CreatePostInstallScript method of the SSHClient interface.
347357
func (c *sshClient) CreatePostInstallScript(data string) Output {
348-
out := c.runSSH(fmt.Sprintf(`cat << 'EOF' > /root/post-install.sh
349-
%sEOF`, data))
358+
out := c.runSSH(fmt.Sprintf(`cat << 'EOF_VIA_SSH' > /root/post-install.sh
359+
%s
360+
EOF_VIA_SSH`, data))
350361

351362
if out.Err != nil || out.StdErr != "" {
352363
return out
353364
}
354365
return c.runSSH(`chmod +x /root/post-install.sh . `)
355366
}
356367

368+
// GetRunningInstallImageProcesses returns the running installimage processes. Output.StdOut is empty if no processes are running.
369+
func (c *sshClient) GetRunningInstallImageProcesses() Output {
370+
return c.runSSH(`ps aux| grep installimage | grep -v grep; true`)
371+
}
372+
357373
// ExecuteInstallImage implements the ExecuteInstallImage method of the SSHClient interface.
358374
func (c *sshClient) ExecuteInstallImage(hasPostInstallScript bool) Output {
359375
var cmd string
@@ -363,13 +379,13 @@ func (c *sshClient) ExecuteInstallImage(hasPostInstallScript bool) Output {
363379
cmd = `/root/hetzner-installimage/installimage -a -c /autosetup`
364380
}
365381

366-
out := c.runSSH(fmt.Sprintf(`cat << 'EOF' > /root/installimage-wrapper.sh
382+
out := c.runSSH(fmt.Sprintf(`cat << 'EOF_VIA_SSH' > /root/installimage-wrapper.sh
367383
#!/bin/bash
368384
export TERM=xterm
369385
370386
# don't wait 20 seconds before starting: echo "x"
371387
echo "x" | %s
372-
EOF`, cmd))
388+
EOF_VIA_SSH`, cmd))
373389
if out.Err != nil || out.StdErr != "" {
374390
return out
375391
}
@@ -428,15 +444,16 @@ func (c *sshClient) CreateNoCloudDirectory() Output {
428444

429445
// CreateMetaData implements the CreateMetaData method of the SSHClient interface.
430446
func (c *sshClient) CreateMetaData(hostName string) Output {
431-
return c.runSSH(fmt.Sprintf(`cat << 'EOF' > /var/lib/cloud/seed/nocloud-net/meta-data
447+
return c.runSSH(fmt.Sprintf(`cat << 'EOF_VIA_SSH' > /var/lib/cloud/seed/nocloud-net/meta-data
432448
local-hostname: %s
433-
EOF`, hostName))
449+
EOF_VIA_SSH`, hostName))
434450
}
435451

436452
// CreateUserData implements the CreateUserData method of the SSHClient interface.
437453
func (c *sshClient) CreateUserData(userData string) Output {
438-
return c.runSSH(fmt.Sprintf(`cat << 'EOF' > /var/lib/cloud/seed/nocloud-net/user-data
439-
%sEOF`, userData))
454+
return c.runSSH(fmt.Sprintf(`cat << 'EOF_VIA_SSH' > /var/lib/cloud/seed/nocloud-net/user-data
455+
%s
456+
EOF_VIA_SSH`, userData))
440457
}
441458

442459
// CloudInitStatus implements the CloudInitStatus method of the SSHClient interface.
@@ -488,9 +505,9 @@ func (c *sshClient) ResetKubeadm() Output {
488505
}
489506

490507
func (c *sshClient) DetectLinuxOnAnotherDisk(sliceOfWwns []string) Output {
491-
return c.runSSH(fmt.Sprintf(`cat <<'EOF' | bash -s -- %s
508+
return c.runSSH(fmt.Sprintf(`cat <<'EOF_VIA_SSH' | bash -s -- %s
492509
%s
493-
EOF
510+
EOF_VIA_SSH
494511
`, strings.Join(sliceOfWwns, " "), detectLinuxOnAnotherDiskShellScript))
495512
}
496513

pkg/services/baremetal/host/host.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ func (s *Service) actionRegistering() actionResult {
537537
return actionContinue{delay: 10 * time.Second}
538538
}
539539

540+
output := sshClient.GetHardwareDetailsDebug()
541+
if output.Err != nil {
542+
return actionError{err: fmt.Errorf("failed to obtain hardware for debugging: %w", output.Err)}
543+
}
544+
record.Eventf(s.scope.HetznerBareMetalHost, "GetHardwareDetails", "%s\n\nstderr:\n%s", output.StdOut, out.StdErr)
545+
540546
if s.scope.HetznerBareMetalHost.Spec.Status.HardwareDetails == nil {
541547
hardwareDetails, err := getHardwareDetails(sshClient)
542548
if err != nil {
@@ -928,7 +934,7 @@ func getCPUFlags(sshClient sshclient.Client) ([]string, error) {
928934

929935
func handleSSHError(out sshclient.Output) error {
930936
if out.Err != nil {
931-
return fmt.Errorf("failed to perform ssh command: %w", out.Err)
937+
return fmt.Errorf("failed to perform ssh command: stdout %q. stderr %q. %w", out.StdOut, out.StdErr, out.Err)
932938
}
933939
if out.StdErr != "" {
934940
return fmt.Errorf("%w: StdErr: %s", errSSHStderr, out.StdErr)
@@ -987,7 +993,7 @@ func (s *Service) actionImageInstalling() actionResult {
987993

988994
// Some other error like connection timeout. Retry again later.
989995
// This often during provisioning.
990-
msg := fmt.Sprintf("DetectLinuxOnAnotherDisk failed (will retry): %s. StdErr: %s (%s)",
996+
msg := fmt.Sprintf("will retry: %s. StdErr: %s (%s)",
991997
out.StdOut, out.StdErr, out.Err.Error())
992998
conditions.MarkFalse(
993999
s.scope.HetznerBareMetalHost,
@@ -1002,6 +1008,20 @@ func (s *Service) actionImageInstalling() actionResult {
10021008
}
10031009
}
10041010

1011+
// if the previous reconcile was stopped, then wait until the first
1012+
// run of installimage was finished.
1013+
out = sshClient.GetRunningInstallImageProcesses()
1014+
if out.Err != nil {
1015+
return actionError{err: fmt.Errorf("failed to get running installimage processes: %q %q %w", out.StdOut, out.StdErr, out.Err)}
1016+
}
1017+
if out.StdOut != "" {
1018+
record.Warnf(s.scope.HetznerBareMetalHost, "InstallImageAlreadyRunning",
1019+
"installimage is already running:\n%s", out.StdOut)
1020+
return actionContinue{
1021+
delay: 10 * time.Second,
1022+
}
1023+
}
1024+
10051025
record.Event(s.scope.HetznerBareMetalHost, "InstallImagePreflightCheckSuccessful", "Rescue system reachable, disks look good.")
10061026

10071027
autoSetupInput, actionRes := s.createAutoSetupInput(sshClient)

pkg/services/baremetal/host/host_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ var _ = Describe("actionRegistering", func() {
11031103
sshMock.On("GetHardwareDetailsCPUFlags").Return(sshclient.Output{StdOut: "flag1 flag2 flag3"})
11041104
sshMock.On("GetHardwareDetailsCPUThreads").Return(sshclient.Output{StdOut: "123"})
11051105
sshMock.On("GetHardwareDetailsCPUCores").Return(sshclient.Output{StdOut: "12"})
1106-
1106+
sshMock.On("GetHardwareDetailsDebug").Return(sshclient.Output{StdOut: "Dummy outupt"})
11071107
service := newTestService(host, nil, bmmock.NewSSHFactory(sshMock, sshMock, sshMock), nil, helpers.GetDefaultSSHSecret(rescueSSHKeyName, "default"))
11081108

11091109
actResult := service.actionRegistering()

pkg/services/hcloud/server/server_suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ const serverJSON = `
7979
},
8080
"deleted": null,
8181
"deprecated": "2018-02-28T00:00:00+00:00",
82-
"description": "Ubuntu 20.04 Standard 64 bit",
82+
"description": "Ubuntu 22.04 Standard 64 bit",
8383
"disk_size": 10,
8484
"id": 42,
8585
"image_size": 2.3,
8686
"labels": {},
87-
"name": "ubuntu-20.04",
87+
"name": "ubuntu-22.04",
8888
"os_flavor": "ubuntu",
89-
"os_version": "20.04",
89+
"os_version": "22.04",
9090
"protection": {
9191
"delete": false
9292
},

templates/cluster-templates/bases/hcloud-kcp-fedora.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ spec:
251251
- dnf install --setopt=obsoletes=0 -y kubelet-0:1.23.4-0 kubeadm-0:1.23.4-0 kubectl-0:1.23.4-0 python3-dnf-plugin-versionlock bash-completion --disableexcludes=kubernetes && dnf versionlock kubelet kubectl kubeadm && systemctl enable kubelet && systemctl start crio && kubeadm config images pull --kubernetes-version 1.23.4
252252
- dnf install -y policycoreutils-python-utils
253253
- semanage fcontext -a -t container_file_t /var/lib/etcd && mkdir -p /var/lib/etcd && restorecon -rv /var /etc
254-
- echo 'source <(kubectl completion bash)' >>~/.bashrc
255-
- echo 'export KUBECONFIG=/etc/kubernetes/admin.conf' >>~/.bashrc
254+
- echo 'source <(kubectl completion bash)' >>/root/.bashrc
255+
- echo 'export KUBECONFIG=/etc/kubernetes/admin.conf' >>/root/.bashrc
256256
- setenforce 0 && sed -i -e '/^\(#\|\)SELINUX/s/^.*$/SELINUX=disabled/' /etc/selinux/config
257257
- dnf -y remove firewalld
258258
- dnf -y autoremove && dnf -y clean all

templates/cluster-templates/bases/hcloud-kcp-ubuntu.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ spec:
194194
- apt-get update
195195
- apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion && apt-mark hold kubelet kubectl kubeadm && systemctl enable kubelet
196196
- kubeadm config images pull --kubernetes-version $KUBERNETES_VERSION
197-
- echo 'source <(kubectl completion bash)' >>~/.bashrc
198-
- echo 'export KUBECONFIG=/etc/kubernetes/admin.conf' >>~/.bashrc
197+
- echo 'source <(kubectl completion bash)' >>/root/.bashrc
198+
- echo 'export KUBECONFIG=/etc/kubernetes/admin.conf' >>/root/.bashrc
199199
- apt-get -y autoremove && apt-get -y clean all
200200
version: "${KUBERNETES_VERSION}"

0 commit comments

Comments
 (0)