Skip to content

Commit 79e3534

Browse files
Merge pull request #10481 from isabella-janssen/mco-2200-claude
MCO-2200: Add day-0 dual streams support for ABI install flow
2 parents e871a5d + 6c9972c commit 79e3534

11 files changed

Lines changed: 124 additions & 45 deletions

File tree

pkg/asset/agent/image/agentimage.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ func (a *AgentImage) Generate(ctx context.Context, dependencies asset.Parents) e
106106
logrus.Debugf("Using custom rootfs URL: %s", a.rootFSURL)
107107
} else {
108108
// Default to the URL from the RHCOS streams file
109-
defaultRootFSURL, err := baseIso.getRootFSURL(ctx, a.cpuArch)
109+
osImageStream := agentManifests.GetOSImageStream()
110+
defaultRootFSURL, err := baseIso.getRootFSURL(ctx, a.cpuArch, osImageStream)
110111
if err != nil {
111112
return err
112113
}

pkg/asset/agent/image/baseiso.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (i *BaseIso) Name() string {
3636
}
3737

3838
// Fetch RootFS URL using the rhcos.json.
39-
func (i *BaseIso) getRootFSURL(ctx context.Context, archName string) (string, error) {
40-
metal, err := rhcos.GetMetalArtifact(ctx, archName)
39+
func (i *BaseIso) getRootFSURL(ctx context.Context, archName string, osImageStream types.OSImageStream) (string, error) {
40+
metal, err := rhcos.GetMetalArtifact(ctx, archName, osImageStream)
4141
if err != nil {
4242
return "", err
4343
}
@@ -69,8 +69,11 @@ func (i *BaseIso) Generate(ctx context.Context, dependencies asset.Parents) erro
6969
clusterInfo := &joiner.ClusterInfo{}
7070
dependencies.Get(agentManifests, registriesConf, agentWorkflow, clusterInfo)
7171

72+
// Extract osImageStream from AgentClusterInstall annotation
73+
osImageStream := agentManifests.GetOSImageStream()
74+
7275
baseIsoFileName, err := rhcos.NewBaseISOFetcher(
73-
i.getRelease(agentManifests, registriesConf.MirrorConfig)).GetBaseISOFilename(ctx, agentManifests.InfraEnv.Spec.CpuArchitecture)
76+
i.getRelease(agentManifests, registriesConf.MirrorConfig), osImageStream).GetBaseISOFilename(ctx, agentManifests.InfraEnv.Spec.CpuArchitecture)
7477

7578
if err == nil {
7679
logrus.Debugf("Using base ISO image %s", baseIsoFileName)

pkg/asset/agent/image/ignition.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
269269
infraEnvID := infraEnvAsset.ID
270270
logrus.Debug("Generated random infra-env id ", infraEnvID)
271271

272-
osImage, err := getOSImagesInfo(ctx, archName, openshiftVersion)
272+
osImageStream := agentManifests.GetOSImageStream()
273+
osImage, err := getOSImagesInfo(ctx, archName, openshiftVersion, osImageStream)
273274
if err != nil {
274275
return err
275276
}
@@ -745,13 +746,13 @@ func addExtraManifests(config *igntypes.Config, extraManifests *manifests.ExtraM
745746
return nil
746747
}
747748

748-
func getOSImagesInfo(ctx context.Context, cpuArch string, openshiftVersion string) (*models.OsImage, error) {
749+
func getOSImagesInfo(ctx context.Context, cpuArch string, openshiftVersion string, osImageStream types.OSImageStream) (*models.OsImage, error) {
749750
osImage := &models.OsImage{
750751
CPUArchitecture: &cpuArch,
751752
}
752753
osImage.OpenshiftVersion = &openshiftVersion
753754

754-
artifacts, err := rhcos.GetMetalArtifact(ctx, cpuArch)
755+
artifacts, err := rhcos.GetMetalArtifact(ctx, cpuArch, osImageStream)
755756
if err != nil {
756757
return nil, err
757758
}

pkg/asset/agent/image/unconfigured_ignition.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/openshift/installer/pkg/asset/agent/workflow"
2323
"github.com/openshift/installer/pkg/asset/ignition"
2424
"github.com/openshift/installer/pkg/asset/ignition/bootstrap"
25+
"github.com/openshift/installer/pkg/rhcos"
2526
"github.com/openshift/installer/pkg/types"
2627
agenttypes "github.com/openshift/installer/pkg/types/agent"
2728
"github.com/openshift/installer/pkg/version"
@@ -155,7 +156,8 @@ func (a *UnconfiguredIgnition) Generate(ctx context.Context, dependencies asset.
155156
if err != nil {
156157
return err
157158
}
158-
osImage, err := getOSImagesInfo(ctx, archName, openshiftVersion)
159+
// Use default OS image stream for unconfigured ignition workflow
160+
osImage, err := getOSImagesInfo(ctx, archName, openshiftVersion, rhcos.DefaultOSImageStream)
159161
if err != nil {
160162
return err
161163
}

pkg/asset/agent/manifests/agent.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package manifests
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"reflect"
78

89
"github.com/pkg/errors"
10+
"github.com/sirupsen/logrus"
911
corev1 "k8s.io/api/core/v1"
1012
"k8s.io/apimachinery/pkg/util/validation/field"
1113

@@ -16,6 +18,8 @@ import (
1618
"github.com/openshift/installer/pkg/asset"
1719
"github.com/openshift/installer/pkg/asset/agent/workflow"
1820
workflowreport "github.com/openshift/installer/pkg/asset/agent/workflow/report"
21+
"github.com/openshift/installer/pkg/rhcos"
22+
"github.com/openshift/installer/pkg/types"
1923
)
2024

2125
const (
@@ -118,6 +122,35 @@ func (m *AgentManifests) GetPullSecretData() string {
118122
return m.PullSecret.StringData[".dockerconfigjson"]
119123
}
120124

125+
// GetOSImageStream extracts the osImageStream from the AgentClusterInstall
126+
// installConfigOverrides annotation, or returns the default if not present.
127+
func (m *AgentManifests) GetOSImageStream() types.OSImageStream {
128+
if m.AgentClusterInstall == nil {
129+
return rhcos.DefaultOSImageStream
130+
}
131+
132+
if m.AgentClusterInstall.Annotations == nil {
133+
return rhcos.DefaultOSImageStream
134+
}
135+
136+
overridesJSON, ok := m.AgentClusterInstall.Annotations[installConfigOverrides]
137+
if !ok {
138+
return rhcos.DefaultOSImageStream
139+
}
140+
141+
var overrides agentClusterInstallInstallConfigOverrides
142+
if err := json.Unmarshal([]byte(overridesJSON), &overrides); err != nil {
143+
logrus.Debugf("Failed to parse installConfigOverrides: %v", err)
144+
return rhcos.DefaultOSImageStream
145+
}
146+
147+
if overrides.OSImageStream == nil || *overrides.OSImageStream == "" {
148+
return rhcos.DefaultOSImageStream
149+
}
150+
151+
return *overrides.OSImageStream
152+
}
153+
121154
func (m *AgentManifests) finish() error {
122155
if err := m.validateAgentManifests().ToAggregate(); err != nil {
123156
return errors.Wrapf(err, "invalid agent configuration")

pkg/asset/agent/manifests/agentclusterinstall.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/openshift/installer/pkg/asset/agent/agentconfig"
3030
"github.com/openshift/installer/pkg/asset/agent/workflow"
3131
"github.com/openshift/installer/pkg/ipnet"
32+
"github.com/openshift/installer/pkg/rhcos"
3233
"github.com/openshift/installer/pkg/types"
3334
"github.com/openshift/installer/pkg/types/baremetal"
3435
"github.com/openshift/installer/pkg/types/defaults"
@@ -131,6 +132,8 @@ type agentClusterInstallInstallConfigOverrides struct {
131132
FeatureSet configv1.FeatureSet `json:"featureSet,omitempty"`
132133
// Allow override of FeatureGates
133134
FeatureGates []string `json:"featureGates,omitempty"`
135+
// OSImageStream is the OS Image Stream to be used for all machines in the cluster
136+
OSImageStream *types.OSImageStream `json:"osImageStream,omitempty"`
134137
}
135138

136139
var _ asset.WritableAsset = (*AgentClusterInstall)(nil)
@@ -397,6 +400,11 @@ func (a *AgentClusterInstall) Generate(_ context.Context, dependencies asset.Par
397400
icOverrides.AdditionalTrustBundlePolicy = installConfig.Config.AdditionalTrustBundlePolicy
398401
}
399402

403+
if installConfig.Config.OSImageStream != rhcos.DefaultOSImageStream && installConfig.Config.OSImageStream != "" {
404+
icOverridden = true
405+
icOverrides.OSImageStream = &installConfig.Config.OSImageStream
406+
}
407+
400408
if icOverridden {
401409
overrides, err := json.Marshal(icOverrides)
402410
if err != nil {

pkg/asset/imagebased/image/baseiso.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/openshift/installer/pkg/asset"
1212
assetrhcos "github.com/openshift/installer/pkg/asset/rhcos"
13+
"github.com/openshift/installer/pkg/rhcos"
1314
"github.com/openshift/installer/pkg/rhcos/cache"
1415
"github.com/openshift/installer/pkg/types"
1516
)
@@ -80,7 +81,8 @@ func (i *BaseIso) Load(f asset.FileFetcher) (bool, error) {
8081

8182
// Download the RHCOS base ISO via rhcos.json.
8283
func (i *BaseIso) downloadBaseIso(ctx context.Context, archName string) (string, error) {
83-
metal, err := assetrhcos.GetMetalArtifact(ctx, archName)
84+
// Use default OS image stream for image-based installer
85+
metal, err := assetrhcos.GetMetalArtifact(ctx, archName, rhcos.DefaultOSImageStream)
8486
if err != nil {
8587
return "", err
8688
}

pkg/asset/rhcos/iso.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ import (
2222

2323
// BaseIso generates the base ISO file for the image.
2424
type BaseIso struct {
25-
ocRelease ReleasePayload
25+
ocRelease ReleasePayload
26+
osImageStream types.OSImageStream
2627
}
2728

2829
// NewBaseISOFetcher returns a struct that can be used to fetch a base ISO using
29-
// the default method.
30-
func NewBaseISOFetcher(ocRelease ReleasePayload) *BaseIso {
30+
// the default method with the specified OS image stream.
31+
func NewBaseISOFetcher(ocRelease ReleasePayload, osImageStream types.OSImageStream) *BaseIso {
3132
return &BaseIso{
32-
ocRelease: ocRelease,
33+
ocRelease: ocRelease,
34+
osImageStream: osImageStream,
3335
}
3436
}
3537

@@ -52,12 +54,12 @@ func (i *BaseIso) GetBaseISOFilename(ctx context.Context, arch string) (baseIsoF
5254
}
5355

5456
// GetMetalArtifact returns the CoreOS metal artifacts for a given arch
55-
// using the embedded stream metadata.
56-
func GetMetalArtifact(ctx context.Context, archName string) (stream.PlatformArtifacts, error) {
57+
// using the embedded stream metadata with the specified stream.
58+
func GetMetalArtifact(ctx context.Context, archName string, osImageStream types.OSImageStream) (stream.PlatformArtifacts, error) {
5759
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
5860
defer cancel()
5961

60-
st, err := rhcos.FetchCoreOSBuild(ctx, rhcos.DefaultOSImageStream)
62+
st, err := rhcos.FetchCoreOSBuild(ctx, osImageStream)
6163
if err != nil {
6264
return stream.PlatformArtifacts{}, err
6365
}
@@ -77,7 +79,7 @@ func GetMetalArtifact(ctx context.Context, archName string) (stream.PlatformArti
7779

7880
// Download the ISO using the URL in rhcos.json.
7981
func (i *BaseIso) downloadIso(ctx context.Context, archName string) (string, error) {
80-
metal, err := GetMetalArtifact(ctx, archName)
82+
metal, err := GetMetalArtifact(ctx, archName, i.osImageStream)
8183
if err != nil {
8284
return "", err
8385
}
@@ -101,14 +103,14 @@ func (i *BaseIso) checkReleasePayloadBaseISOVersion(ctx context.Context, r Relea
101103
logrus.Debugf("Checking release payload base ISO version")
102104

103105
// Get current release payload CoreOS version
104-
payloadRelease, err := r.GetBaseIsoVersion(archName)
106+
payloadRelease, err := r.GetBaseIsoVersion(archName, i.osImageStream)
105107
if err != nil {
106108
logrus.Warnf("unable to determine base ISO version: %s", err.Error())
107109
return
108110
}
109111

110112
// Get pinned version from installer
111-
metal, err := GetMetalArtifact(ctx, archName)
113+
metal, err := GetMetalArtifact(ctx, archName, i.osImageStream)
112114
if err != nil {
113115
logrus.Warnf("unable to determine base ISO version: %s", err.Error())
114116
return
@@ -133,7 +135,7 @@ func (i *BaseIso) retrieveBaseIso(ctx context.Context, archName string) (string,
133135
if err := workflowreport.GetReport(ctx).SubStage(workflow.StageFetchBaseISOExtract); err != nil {
134136
return "", err
135137
}
136-
baseIsoFileName, err := i.ocRelease.GetBaseIso(archName)
138+
baseIsoFileName, err := i.ocRelease.GetBaseIso(archName, i.osImageStream)
137139
if err == nil {
138140
if err := workflowreport.GetReport(ctx).SubStage(workflow.StageFetchBaseISOVerify); err != nil {
139141
return "", err

pkg/asset/rhcos/iso_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/assert"
13+
14+
"github.com/openshift/installer/pkg/types"
1315
)
1416

1517
func TestBaseIso(t *testing.T) {
@@ -69,7 +71,7 @@ func TestBaseIso(t *testing.T) {
6971
isoBaseVersion: ocReleaseImage,
7072
baseIsoFileName: ocBaseIsoFilename,
7173
baseIsoError: tc.getIsoError,
72-
})
74+
}, types.OSImageStreamRHCOS9)
7375
filename, err := fetcher.GetBaseISOFilename(context.Background(), "")
7476

7577
if tc.expectedError == "" {
@@ -88,14 +90,14 @@ type mockRelease struct {
8890
baseIsoError error
8991
}
9092

91-
func (m *mockRelease) GetBaseIso(architecture string) (string, error) {
93+
func (m *mockRelease) GetBaseIso(architecture string, osImageStream types.OSImageStream) (string, error) {
9294
if m.baseIsoError != nil {
9395
return "", m.baseIsoError
9496
}
9597
return m.baseIsoFileName, nil
9698
}
9799

98-
func (m *mockRelease) GetBaseIsoVersion(architecture string) (string, error) {
100+
func (m *mockRelease) GetBaseIsoVersion(architecture string, osImageStream types.OSImageStream) (string, error) {
99101
return m.isoBaseVersion, nil
100102
}
101103

0 commit comments

Comments
 (0)