Skip to content
Closed
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
17 changes: 10 additions & 7 deletions ignition-server/controllers/local_ignitionprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ type LocalIgnitionProvider struct {

var _ IgnitionProvider = (*LocalIgnitionProvider)(nil)


func (p *LocalIgnitionProvider) GetPayload(ctx context.Context, releaseImage string, customConfig string) ([]byte, error) {
// NOTE: If you change this function, you also very likely want to change code around
// https://github.com/openshift/installer/blob/ac9f1c19c96ebab17e67490cf8ccf6504166a566/data/data/bootstrap/files/usr/local/bin/bootkube.sh.template#L299
p.lock.Lock()
defer p.lock.Unlock()

Expand Down Expand Up @@ -152,6 +155,12 @@ func (p *LocalIgnitionProvider) GetPayload(ctx context.Context, releaseImage str
}
}

// Get all images to pass to the MCO
allimagesPath := filepath.Join(workDir, "image-references")
if err := p.ReleaseProvider.SerializeImageStream(allimagesPath); err != nil {
return nil, fmt.Errorf("failed to serialize imagestream: %w", err)
}

// Write out the custom config to the MCC directory
if err := os.WriteFile(filepath.Join(mccBaseDir, "custom.yaml"), []byte(customConfig), 0644); err != nil {
return nil, fmt.Errorf("failed to write mcc config: %w", err)
Expand Down Expand Up @@ -230,13 +239,7 @@ func (p *LocalIgnitionProvider) GetPayload(ctx context.Context, releaseImage str

args := []string{
"bootstrap",
fmt.Sprintf("--machine-config-operator-image=%s", images["machine-config-operator"]),
fmt.Sprintf("--machine-config-oscontent-image=%s", images["machine-os-content"]),
fmt.Sprintf("--infra-image=%s", images["pod"]),
fmt.Sprintf("--keepalived-image=%s", images["keepalived-ipfailover"]),
fmt.Sprintf("--coredns-image=%s", images["codedns"]),
fmt.Sprintf("--haproxy-image=%s", images["haproxy"]),
fmt.Sprintf("--baremetal-runtimecfg-image=%s", images["baremetal-runtimecfg"]),
fmt.Sprintf("--image-references=%s", allimagesPath),
fmt.Sprintf("--root-ca=%s/root-ca.crt", configDir),
fmt.Sprintf("--kube-ca=%s/combined-ca.crt", configDir),
fmt.Sprintf("--infra-config-file=%s/cluster-infrastructure-02-config.yaml", configDir),
Expand Down
2 changes: 2 additions & 0 deletions support/releaseinfo/cached_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ func (p *CachedProvider) Lookup(ctx context.Context, image string, pullSecret []
p.Cache[image] = entry
return entry, nil
}

func (p *CachedProvider) SerializeImageStream(ctx context.Context, image string, pullSecret []byte) (releaseImage *ReleaseImage, err error) {
7 changes: 7 additions & 0 deletions support/releaseinfo/pod_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type PodProvider struct {
Secrets v1.SecretInterface
}

func (p *PodProvider) run(ctx context.Context, image string, pullSecret []byte) (releaseImage *ReleaseImage, err error) {


func (p *PodProvider) Lookup(ctx context.Context, image string, pullSecret []byte) (releaseImage *ReleaseImage, err error) {
log := ctrl.LoggerFrom(ctx, "image-lookup", image)

Expand Down Expand Up @@ -137,6 +140,10 @@ func (p *PodProvider) Lookup(ctx context.Context, image string, pullSecret []byt
return
}

func (p *PodProvider) SerializeImageStream(path string) error {

}

func getContainerLogs(ctx context.Context, pods v1.PodInterface, podName, containerName string) ([]byte, error) {
req := pods.GetLogs(podName, &corev1.PodLogOptions{Container: containerName})
logs, err := req.Stream(ctx)
Expand Down
4 changes: 4 additions & 0 deletions support/releaseinfo/registry_mirror_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ func (p *RegistryMirrorProviderDecorator) Lookup(ctx context.Context, image stri
func (p *RegistryMirrorProviderDecorator) GetRegistryOverrides() map[string]string {
return p.RegistryOverrides
}

func (p *RegistryMirrorProviderDecorator) SerializeImageStream(path string) error {
return p.Delegate.SerializeImageStream(path)
}
14 changes: 14 additions & 0 deletions support/releaseinfo/releaseinfo.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package releaseinfo

import (
"bufio"
"bytes"
"context"
"encoding/json"
"fmt"
"os"
"regexp"
"sort"
"strings"
Expand All @@ -18,6 +21,7 @@ import (
// to by its pullspec.
type Provider interface {
Lookup(ctx context.Context, image string, pullSecret []byte) (*ReleaseImage, error)
SerializeImageStream(path string) error
}

type ProviderWithRegistryOverrides interface {
Expand Down Expand Up @@ -108,6 +112,16 @@ func (i *ReleaseImage) ComponentVersions() (map[string]string, error) {
return versions, nil
}

func (i *ReleaseImage) SerializeImageStream(path string) error {
f, err := os.Create(path)
if err != nil {
return err
}
defer f.Close()
m := json.NewEncoder(bufio.NewWriter(f))
return m.Encode(&i.ImageStream)
}

const (
// This LABEL is a comma-delimited list of key=version pairs that can be consumed
// by other manifests within the payload to hardcode version strings. Version must
Expand Down