diff --git a/pkg/asset/ignition/bootstrap_ignition.go b/pkg/asset/ignition/bootstrap_ignition.go index b6b6d7d7..fa7981c5 100644 --- a/pkg/asset/ignition/bootstrap_ignition.go +++ b/pkg/asset/ignition/bootstrap_ignition.go @@ -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{ diff --git a/pkg/asset/ignition/install_ignition.go b/pkg/asset/ignition/install_ignition.go index a0d2a05c..f74845fc 100644 --- a/pkg/asset/ignition/install_ignition.go +++ b/pkg/asset/ignition/install_ignition.go @@ -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{ @@ -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" diff --git a/pkg/asset/registry/registriesconf.go b/pkg/asset/registry/registriesconf.go index 838d954d..ffa3106b 100644 --- a/pkg/asset/registry/registriesconf.go +++ b/pkg/asset/registry/registriesconf.go @@ -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" @@ -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 } @@ -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 @@ -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) } diff --git a/pkg/release/release.go b/pkg/release/release.go index 84725132..3046047c 100644 --- a/pkg/release/release.go +++ b/pkg/release/release.go @@ -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) @@ -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 diff --git a/pkg/templates/data.go b/pkg/templates/data.go index 1bd2740c..3e4e4716 100644 --- a/pkg/templates/data.go +++ b/pkg/templates/data.go @@ -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 @@ -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) @@ -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 @@ -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,