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

MGMT-19792: Add discovery ignition URL to the infraenv status #7243

Merged
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
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 an 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 an 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 an 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 an HTTP/S URL that
contains the discovery ignition
type: string
initrd:
description: InitrdURL specifies an HTTP/S URL that contains the
initrd
Expand Down
30 changes: 25 additions & 5 deletions internal/controller/controllers/infraenv_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,18 +642,38 @@ func (r *InfraEnvReconciler) setSignedBootArtifactURLs(infraEnv *aiv1beta1.Infra
if err != nil {
return err
}
baseURL, err := url.Parse(r.ServiceBaseURL)
scriptURL, err := url.Parse(r.ServiceBaseURL)
if err != nil {
return err
}
// ASC may be configured to use http in ipxe artifact URLs so that all ipxe clients could consume those
if r.InsecureIPXEURLs {
baseURL.Scheme = "http"
scriptURL.Scheme = "http"
}
baseURL.Path = path.Join(baseURL.Path, filesURL.Path)
baseURL.RawQuery = filesURL.RawQuery
scriptURL.Path = path.Join(scriptURL.Path, filesURL.Path)
scriptURL.RawQuery = filesURL.RawQuery

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

builder = &installer.V2DownloadInfraEnvFilesURL{
InfraEnvID: strfmt.UUID(infraEnvID),
FileName: "discovery.ign",
}
filesURL, err = builder.Build()
if err != nil {
return err
}
ignitionURL, err := url.Parse(r.ServiceBaseURL)
if err != nil {
return err
}
ignitionURL.Path = path.Join(ignitionURL.Path, filesURL.Path)
ignitionURL.RawQuery = filesURL.RawQuery

infraEnv.Status.BootArtifacts.DiscoveryIgnitionURL, err = signURL(ignitionURL.String(), r.AuthType, infraEnvID, gencrypto.InfraEnvKey)
if err != nil {
return err
}
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.