Skip to content

Commit

Permalink
Add discovery ignition URL to the infraenv status
Browse files Browse the repository at this point in the history
This will mainly be used with integrations that provide the discovery
ignition as metadata to hosts that boot with a generic disk image rather
than the discovery ISO, but can also be used for debugging.

Resolves https://issues.redhat.com/browse/MGMT-19792
  • Loading branch information
carbonin committed Jan 29, 2025
1 parent 7490e1a commit f1d643c
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/v1beta1/infraenv_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ type BootArtifacts struct {
// IpxeScriptURL specifies an HTTP/S URL that contains the iPXE script
// +optional
IpxeScriptURL string `json:"ipxeScript"`
// DiscoveryIgnitionURL specifies and HTTP/S URL that contains the discovery ignition
// +optional
DiscoveryIgnitionURL string `json:"discoveryIgnitionURL"`
}

// +kubebuilder:object:root=true
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/agent-install.openshift.io_infraenvs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ spec:
bootArtifacts:
description: BootArtifacts specifies the URLs for each boot artifact
properties:
discoveryIgnitionURL:
description: DiscoveryIgnitionURL specifies and HTTP/S URL that
contains the discovery ignition
type: string
initrd:
description: InitrdURL specifies an HTTP/S URL that contains the
initrd
Expand Down
4 changes: 4 additions & 0 deletions config/crd/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3213,6 +3213,10 @@ spec:
bootArtifacts:
description: BootArtifacts specifies the URLs for each boot artifact
properties:
discoveryIgnitionURL:
description: DiscoveryIgnitionURL specifies and HTTP/S URL that
contains the discovery ignition
type: string
initrd:
description: InitrdURL specifies an HTTP/S URL that contains the
initrd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ spec:
bootArtifacts:
description: BootArtifacts specifies the URLs for each boot artifact
properties:
discoveryIgnitionURL:
description: DiscoveryIgnitionURL specifies and HTTP/S URL that
contains the discovery ignition
type: string
initrd:
description: InitrdURL specifies an HTTP/S URL that contains the
initrd
Expand Down
21 changes: 21 additions & 0 deletions internal/controller/controllers/infraenv_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,27 @@ func (r *InfraEnvReconciler) setSignedBootArtifactURLs(infraEnv *aiv1beta1.Infra
return err
}

builder = &installer.V2DownloadInfraEnvFilesURL{
InfraEnvID: strfmt.UUID(infraEnvID),
FileName: "discovery.ign",
}

ignitionURL, err := builder.Build()
if err != nil {
return err
}
baseURL, err = url.Parse(r.ServiceBaseURL)
if err != nil {
return err
}
baseURL.Path = path.Join(baseURL.Path, ignitionURL.Path)
baseURL.RawQuery = ignitionURL.RawQuery

infraEnv.Status.BootArtifacts.DiscoveryIgnitionURL, err = signURL(baseURL.String(), r.AuthType, infraEnvID, gencrypto.InfraEnvKey)
if err != nil {
return err
}

return nil
}

Expand Down
34 changes: 34 additions & 0 deletions internal/controller/controllers/infraenv_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,40 @@ var _ = Describe("infraEnv reconcile", func() {
Expect(scriptURL.Query().Has("ipxe_script_type")).To(BeFalse())
})

It("sets the discovery ignition boot artifact url", func() {
dbInfraEnv := &common.InfraEnv{
GeneratedAt: strfmt.DateTime(time.Now()),
InfraEnv: models.InfraEnv{
ID: &sId,
CPUArchitecture: infraEnvArch,
DownloadURL: "https://images.example.com/images/best-image",
},
}
mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil)
mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil, nil).Return(dbInfraEnv, nil).Times(1)
kubeInfraEnv := newInfraEnvImage("myInfraEnv", testNamespace, aiv1beta1.InfraEnvSpec{
PullSecretRef: &corev1.LocalObjectReference{Name: "pull-secret"},
})
Expect(c.Create(ctx, kubeInfraEnv)).To(Succeed())

_, err := ir.Reconcile(ctx, newInfraEnvRequest(kubeInfraEnv))
Expect(err).ToNot(HaveOccurred())

key := types.NamespacedName{
Namespace: testNamespace,
Name: "myInfraEnv",
}
Expect(c.Get(ctx, key, kubeInfraEnv)).To(BeNil())

ignitionURL, err := url.Parse(kubeInfraEnv.Status.BootArtifacts.DiscoveryIgnitionURL)
Expect(err).ToNot(HaveOccurred())
Expect(ignitionURL.Scheme).To(Equal("https"))
Expect(ignitionURL.Host).To(Equal("www.acme.com"))
Expect(ignitionURL.Path).To(Equal(fmt.Sprintf("/api/assisted-install/v2/infra-envs/%s/downloads/files", sId)))
Expect(ignitionURL.Query().Get("file_name")).To(Equal("discovery.ign"))
})

Context("discovery kernel arguments", func() {
encodeKernelArguments := func(kargs []aiv1beta1.KernelArgument) *string {
internalKargs := internalKernelArgs(kargs)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1d643c

Please sign in to comment.