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

🌱 Installimage: create events containing debug.txt and cloud-init-output.log #1002

Merged
merged 1 commit into from
Oct 12, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ __pycache__/
/_output
tmp_*

# baremetal hosts
baremetalhosts*yaml
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ install-cilium-in-wl-cluster:
install-ccm-in-wl-cluster:
helm repo add syself https://charts.syself.com
helm repo update syself
KUBECONFIG=$(WORKER_CLUSTER_KUBECONFIG) helm upgrade --install ccm syself/ccm-hetzner --version 1.1.8 \
KUBECONFIG=$(WORKER_CLUSTER_KUBECONFIG) helm upgrade --install ccm syself/ccm-hetzner --version 1.1.10 \
--namespace kube-system \
--set privateNetwork.enabled=$(PRIVATE_NETWORK)
@echo 'run "kubectl --kubeconfig=$(WORKER_CLUSTER_KUBECONFIG) ..." to work with the new target cluster'
Expand Down Expand Up @@ -749,8 +749,12 @@ lint: lint-golang lint-yaml lint-dockerfile lint-links ## Lint Codebase
.PHONY: format
format: format-starlark format-golang format-yaml ## Format Codebase

.PHONY: generate-mocks
generate-mocks: ## Generate Mocks
cd pkg/services/baremetal/client; go run github.com/vektra/mockery/v2@v2.35.3

.PHONY: generate
generate: generate-manifests generate-go-deepcopy generate-boilerplate generate-modules ## Generate Files
generate: generate-manifests generate-go-deepcopy generate-boilerplate generate-modules generate-mocks ## Generate Files

ALL_VERIFY_CHECKS = boilerplate shellcheck starlark
.PHONY: verify
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/hetznerbaremetalhost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const (
// StateProvisioning means we are sending userData to the host and boot the machine.
StateProvisioning ProvisioningState = "provisioning"

// StateEnsureProvisioned means we are ensuring the reboot worked and cloud init is installed.
// StateEnsureProvisioned means we are ensuring the reboot worked and cloud init was executed successfully.
StateEnsureProvisioned ProvisioningState = "ensure-provisioned"

// StateProvisioned means we have sent userData to the host and booted the machine.
Expand Down
7 changes: 6 additions & 1 deletion controllers/hetznerbaremetalhost_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ var _ = Describe("HetznerBareMetalHostReconciler", func() {
StdErr: "",
Err: nil,
})
osSSHClientAfterInstallImage.On("GetCloudInitOutput").Return(sshclient.Output{StdOut: "dummy content of /var/log/cloud-init-output.log"})

osSSHClientAfterCloudInit.On("Reboot").Return(sshclient.Output{})
osSSHClientAfterCloudInit.On("GetHostName").Return(sshclient.Output{
StdOut: infrav1.BareMetalHostNamePrefix + bmMachineName,
Expand All @@ -182,6 +184,7 @@ var _ = Describe("HetznerBareMetalHostReconciler", func() {
osSSHClientAfterCloudInit.On("CloudInitStatus").Return(sshclient.Output{StdOut: "status: done"})
osSSHClientAfterCloudInit.On("CheckCloudInitLogsForSigTerm").Return(sshclient.Output{})
osSSHClientAfterCloudInit.On("ResetKubeadm").Return(sshclient.Output{})
osSSHClientAfterCloudInit.On("GetCloudInitOutput").Return(sshclient.Output{StdOut: "dummy content of /var/log/cloud-init-output.log"})
})

AfterEach(func() {
Expand Down Expand Up @@ -333,6 +336,7 @@ var _ = Describe("HetznerBareMetalHostReconciler", func() {
}, timeout, time.Second).Should(BeNil())

Eventually(func() bool {
// TODO: Add logging to trace flaky unit-test.
if err := testEnv.Get(ctx, key, host); err != nil {
return false
}
Expand Down Expand Up @@ -693,7 +697,7 @@ var _ = Describe("HetznerBareMetalHostReconciler - missing secrets", func() {
}, timeout).Should(BeTrue())
})

It("gives the right error if secret is invalid", func() {
It("gives the right error if secret if rescue-ssh is invalid", func() {
rescueSSHSecret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "rescue-ssh-secret",
Expand Down Expand Up @@ -828,4 +832,5 @@ name="eth0" model="Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express
sshClient.On("CreatePostInstallScript", mock.Anything).Return(sshclient.Output{})
sshClient.On("ExecuteInstallImage", mock.Anything).Return(sshclient.Output{})
sshClient.On("Reboot").Return(sshclient.Output{})
sshClient.On("GetCloudInitOutput").Return(sshclient.Output{StdOut: "dummy content of /var/log/cloud-init-output.log"})
}
2 changes: 2 additions & 0 deletions controllers/hetznerbaremetalmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ var _ = Describe("HetznerBareMetalMachineReconciler", func() {
StdErr: "",
Err: nil,
})
osSSHClient.On("GetCloudInitOutput").Return(sshclient.Output{StdOut: "dummy content of /var/log/cloud-init-output.log"})

})

AfterEach(func() {
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ KUBECONFIG=$CAPH_WORKER_CLUSTER_KUBECONFIG helm upgrade --install ccm syself/ccm
helm repo add syself https://charts.syself.com
helm repo update syself

KUBECONFIG=$CAPH_WORKER_CLUSTER_KUBECONFIG helm upgrade --install ccm syself/ccm-hetzner --version 1.1.8 \
KUBECONFIG=$CAPH_WORKER_CLUSTER_KUBECONFIG helm upgrade --install ccm syself/ccm-hetzner --version 1.1.10 \
--namespace kube-system \
--set privateNetwork.enabled=false
```
Expand Down
16 changes: 16 additions & 0 deletions pkg/services/baremetal/client/.mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This config was choosen, so that the output matches to old structure (pre config file .mockery.yaml).
# If you are here to copy this config to a new project, then it might
# make sense to choose a structure which needs less config by using
# the default values of Mockery.
all: True
filename: "{{.InterfaceName}}.go"
mockname: "{{.InterfaceName}}"
outpkg: mocks
packages:
github.com/syself/cluster-api-provider-hetzner/pkg/services/baremetal/client/ssh:
config:
dir: mocks/ssh

github.com/syself/cluster-api-provider-hetzner/pkg/services/baremetal/client/robot:
config:
dir: mocks/robot
Loading