Skip to content
Open
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: 1 addition & 1 deletion pkg/asset/ignition/bootstrap_ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (i *BootstrapIgnition) Generate(_ context.Context, dependencies asset.Paren
// Determine if we're using the OCP registry (for the podman run command)
useOcpRegistry := reg.ShouldUseOcpRegistry(envConfig, applianceConfig)
if useOcpRegistry {
logrus.Info("BootstrapIgnition will use OCP docker-registry image")
logrus.Debug("BootstrapIgnition will use OCP docker-registry image")
}

i.Config = igntypes.Config{
Expand Down
6 changes: 4 additions & 2 deletions pkg/asset/ignition/install_ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (i *InstallIgnition) Generate(_ context.Context, dependencies asset.Parents
// Determine if we're using the OCP registry (for the podman run command)
useOcpRegistry := registry.ShouldUseOcpRegistry(envConfig, applianceConfig)
if useOcpRegistry {
logrus.Info("InstallIgnition will use OCP docker-registry image")
logrus.Debug("InstallIgnition will use OCP docker-registry image")
}

i.Config = igntypes.Config{
Expand Down Expand Up @@ -126,7 +126,9 @@ func (i *InstallIgnition) Generate(_ context.Context, dependencies asset.Parents
// Create install template data
templateData := templates.GetInstallIgnitionTemplateData(
envConfig.IsLiveISO,
corePassHash)
swag.BoolValue(applianceConfig.Config.EnableInteractiveFlow),
corePassHash,
)

// Add registry service from appropriate directory (OCP or default)
registryServiceDir := "services/local-registry-default"
Expand Down
23 changes: 15 additions & 8 deletions pkg/asset/registry/registriesconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"

"github.com/containers/image/pkg/sysregistriesv2"
"github.com/go-openapi/swag"
"github.com/openshift/appliance/pkg/asset/config"
"github.com/openshift/appliance/pkg/consts"
"github.com/openshift/installer/pkg/asset"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (i *RegistriesConf) Generate(_ context.Context, dependencies asset.Parents)
i.fSys = os.DirFS(envConfig.CacheDir)
}

registries, err := i.generateRegistries()
registries, err := i.generateRegistries(applianceConfig.Config.EnableInteractiveFlow)
if err != nil {
return err
}
Expand All @@ -99,7 +100,7 @@ func (i *RegistriesConf) Generate(_ context.Context, dependencies asset.Parents)
return nil
}

func (i *RegistriesConf) generateRegistries() (*sysregistriesv2.V2RegistriesConf, error) {
func (i *RegistriesConf) generateRegistries(enableInteractiveFlow *bool) (*sysregistriesv2.V2RegistriesConf, error) {
idmsFile, err := fs.ReadFile(i.fSys, idmsFileName)
if err != nil {
return nil, err
Expand All @@ -122,12 +123,18 @@ func (i *RegistriesConf) generateRegistries() (*sysregistriesv2.V2RegistriesConf
logrus.Debugf("adding mirrors for %s", r.Location)
for _, m := range idmsMirror.Mirrors {
re := regexp.MustCompile(`^[^/]+`)
r.Mirrors = append(r.Mirrors, sysregistriesv2.Endpoint{
Location: re.ReplaceAllString(m, fmt.Sprintf("%s:%d", RegistryDomain, RegistryPort)),
})
r.Mirrors = append(r.Mirrors, sysregistriesv2.Endpoint{
Location: re.ReplaceAllString(m, fmt.Sprintf("%s:%d", RegistryDomain, RegistryPortUpgrade)),
})
if swag.BoolValue(enableInteractiveFlow) {
r.Mirrors = append(r.Mirrors, sysregistriesv2.Endpoint{
Location: re.ReplaceAllString(m, fmt.Sprintf("%s:%d", "localhost", RegistryPort)),
})
} else {
r.Mirrors = append(r.Mirrors, sysregistriesv2.Endpoint{
Location: re.ReplaceAllString(m, fmt.Sprintf("%s:%d", RegistryDomain, RegistryPort)),
})
r.Mirrors = append(r.Mirrors, sysregistriesv2.Endpoint{
Location: re.ReplaceAllString(m, fmt.Sprintf("%s:%d", RegistryDomain, RegistryPortUpgrade)),
})
}
}
regs.Registries = append(regs.Registries, r)
}
Expand Down
17 changes: 14 additions & 3 deletions pkg/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,29 @@ func (r *release) mirrorImages(imageSetFile, blockedImages, additionalImages, op
}

// Copy generated yaml files to cache dir
if err = r.copyOutputYamls(tempDir); err != nil {
if err = r.copyOutputYamls(tempDir, r.ApplianceConfig.Config.EnableInteractiveFlow); err != nil {
return err
}

return err
}

func (r *release) copyOutputYamls(ocMirrorDir string) error {
func (r *release) copyOutputYamls(ocMirrorDir string, enableInteractiveFlow *bool) error {
// If interactive flow is enabled, use localhost as registry domain, otherwise use the default registry domain
var registryDomain string
if swag.BoolValue(enableInteractiveFlow) {
registryDomain = "localhost"
} else {
registryDomain = registry.RegistryDomain
}

// Get all yaml files from the oc-mirror output
yamlPaths, err := filepath.Glob(filepath.Join(ocMirrorDir, "working-dir", consts.OcMirrorResourcesDir, "*.yaml"))
if err != nil {
return err
}

// Iterate over all yaml files and replace the localhost with the internal registry URI
for _, yamlPath := range yamlPaths {
logrus.Debugf("Copying ymals from oc-mirror output: %s", yamlPath)
yamlBytes, err := r.OSInterface.ReadFile(yamlPath)
Expand All @@ -183,7 +194,7 @@ func (r *release) copyOutputYamls(ocMirrorDir string) error {

// Replace localhost with internal registry URI
buildRegistryURI := fmt.Sprintf("127.0.0.1:%d", swag.IntValue(r.ApplianceConfig.Config.ImageRegistry.Port))
internalRegistryURI := fmt.Sprintf("%s:%d", registry.RegistryDomain, registry.RegistryPort)
internalRegistryURI := fmt.Sprintf("%s:%d", registryDomain, registry.RegistryPort)
newYaml := strings.ReplaceAll(string(yamlBytes), buildRegistryURI, internalRegistryURI)

// Write edited yamls to cache
Expand Down
22 changes: 18 additions & 4 deletions pkg/templates/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func GetBootstrapIgnitionTemplateData(isLiveISO, enableInteractiveFlow bool, ocp
InstallIgnitionConfig string
RendezvousHostEnvPlaceholder string

ReleaseImages, ReleaseImage, OsImages string
ReleaseImages, ReleaseImage, OsImages string
RegistryDomain, RegistryFilePath, RegistryImage string

Partition0, Partition1, Partition2, Partition3 Partition
Expand All @@ -130,11 +130,17 @@ func GetBootstrapIgnitionTemplateData(isLiveISO, enableInteractiveFlow bool, ocp
OsImages: string(osImages),

// Registry
RegistryDomain: registry.RegistryDomain,
RegistryFilePath: consts.RegistryFilePath,
RegistryImage: consts.RegistryImage,
}

// If interactive flow is enabled, use localhost as registry domain, otherwise use the default registry domain
if enableInteractiveFlow {
data.RegistryDomain = "localhost"
} else {
data.RegistryDomain = registry.RegistryDomain
}

// Fetch base image partitions (Disk image mode)
if coreosImagePath != "" {
partitions, err := NewPartitions().GetCoreOSPartitions(coreosImagePath)
Expand All @@ -152,7 +158,15 @@ func GetBootstrapIgnitionTemplateData(isLiveISO, enableInteractiveFlow bool, ocp
return data
}

func GetInstallIgnitionTemplateData(isLiveISO bool, corePassHash string) interface{} {
func GetInstallIgnitionTemplateData(isLiveISO bool, enableInteractiveFlow bool, corePassHash string) interface{} {
// If interactive flow is enabled, use localhost as registry domain, otherwise use the default registry domain
var registryDomain string
if enableInteractiveFlow {
registryDomain = "localhost"
} else {
registryDomain = registry.RegistryDomain
}

return struct {
IsBootstrapStep bool
IsLiveISO bool
Expand All @@ -164,7 +178,7 @@ func GetInstallIgnitionTemplateData(isLiveISO bool, corePassHash string) interfa
IsLiveISO: isLiveISO,

// Registry
RegistryDomain: registry.RegistryDomain,
RegistryDomain: registryDomain,
RegistryFilePath: consts.RegistryFilePath,
RegistryImage: consts.RegistryImage,
GrubCfgFilePath: consts.GrubCfgFilePath,
Expand Down