Skip to content

Commit

Permalink
RHEL-9: don't touch rhsm.conf on non-RHUI images.
Browse files Browse the repository at this point in the history
Previously, the auto-registration was explicitly enabled in rhsm.conf
even for non-RHUI cloud images. These are the images that users can
build on-prem or in the hosted service (as vanilla or as customized).
However, the feature never really worked for these images.

Stop enabling the auto-registration in rhsm.conf (basically stop
touching the configuration at all).

Related to https://issues.redhat.com/browse/COMPOSER-2157

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza committed Feb 22, 2024
1 parent a438e7d commit 74e73b9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 81 deletions.
34 changes: 16 additions & 18 deletions pkg/distro/rhel9/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func baseEc2ImageConfig() *distro.ImageConfig {
{
Filename: "00-getty-fixes.conf",
Config: osbuild.SystemdLogindConfigDropin{

Login: osbuild.SystemdLogindConfigLoginSection{
NAutoVTs: common.ToPtr(0),
},
Expand Down Expand Up @@ -266,24 +265,23 @@ func defaultEc2ImageConfig(osVersion string, rhsm bool) *distro.ImageConfig {
return ic
}

// default AMI (EC2 BYOS) images config
func defaultAMIImageConfig(osVersion string, rhsm bool) *distro.ImageConfig {
ic := defaultEc2ImageConfig(osVersion, rhsm)
if rhsm {
// defaultEc2ImageConfig() adds the rhsm options only for RHEL < 9.1
// Add it unconditionally for AMI
ic = appendRHSM(ic)
}
return ic
}

func defaultEc2ImageConfigX86_64(osVersion string, rhsm bool) *distro.ImageConfig {
ic := defaultEc2ImageConfig(osVersion, rhsm)
return appendEC2DracutX86_64(ic)
}

func defaultAMIImageConfigX86_64(osVersion string, rhsm bool) *distro.ImageConfig {
ic := defaultAMIImageConfig(osVersion, rhsm).InheritFrom(defaultEc2ImageConfigX86_64(osVersion, rhsm))
// Default AMI (custom image built by users) images config.
// The configuration does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
func defaultAMIImageConfig() *distro.ImageConfig {
return baseEc2ImageConfig()
}

// Default AMI x86_64 (custom image built by users) images config.
// The configuration does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
func defaultAMIImageConfigX86_64() *distro.ImageConfig {
ic := defaultAMIImageConfig()
return appendEC2DracutX86_64(ic)
}

Expand Down Expand Up @@ -418,9 +416,9 @@ func mkEc2ImgTypeX86_64(osVersion string, rhsm bool) imageType {
return it
}

func mkAMIImgTypeX86_64(osVersion string, rhsm bool) imageType {
func mkAMIImgTypeX86_64() imageType {
it := amiImgTypeX86_64
ic := defaultAMIImageConfigX86_64(osVersion, rhsm)
ic := defaultAMIImageConfigX86_64()
it.defaultImageConfig = ic
return it
}
Expand All @@ -438,9 +436,9 @@ func mkEc2HaImgTypeX86_64(osVersion string, rhsm bool) imageType {
return it
}

func mkAMIImgTypeAarch64(osVersion string, rhsm bool) imageType {
func mkAMIImgTypeAarch64() imageType {
it := amiImgTypeAarch64
ic := defaultAMIImageConfig(osVersion, rhsm)
ic := defaultAMIImageConfig()
it.defaultImageConfig = ic
return it
}
Expand Down
27 changes: 2 additions & 25 deletions pkg/distro/rhel9/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,35 +572,12 @@ var defaultAzureImageConfig = &distro.ImageConfig{
}

// Diff of the default Image Config compare to the `defaultAzureImageConfig`
// The configuration for non-RHUI images does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
var defaultAzureByosImageConfig = &distro.ImageConfig{
GPGKeyFiles: []string{
"/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
},
RHSMConfig: map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{
subscription.RHSMConfigNoSubscription: {
SubMan: &osbuild.RHSMStageOptionsSubMan{
Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{
AutoRegistration: common.ToPtr(true),
},
// Don't disable RHSM redhat.repo management on the GCE
// image, which is BYOS and does not use RHUI for content.
// Otherwise subscribing the system manually after booting
// it would result in empty redhat.repo. Without RHUI, such
// system would have no way to get Red Hat content, but
// enable the repo management manually, which would be very
// confusing.
},
},
subscription.RHSMConfigWithSubscription: {
SubMan: &osbuild.RHSMStageOptionsSubMan{
Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{
AutoRegistration: common.ToPtr(true),
},
// do not disable the redhat.repo management if the user
// explicitly request the system to be subscribed
},
},
},
}

// Diff of the default Image Config compare to the `defaultAzureImageConfig`
Expand Down
8 changes: 4 additions & 4 deletions pkg/distro/rhel9/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func newDistro(name string, minor int) *distribution {
}
x86_64.addImageTypes(
ec2X86Platform,
mkAMIImgTypeX86_64(rd.osVersion, rd.isRHEL()),
mkAMIImgTypeX86_64(),
)

gceX86Platform := &platform.X86{
Expand All @@ -264,7 +264,7 @@ func newDistro(name string, minor int) *distribution {
}
x86_64.addImageTypes(
gceX86Platform,
mkGCEImageType(rd.isRHEL()),
mkGCEImageType(),
)

x86_64.addImageTypes(
Expand Down Expand Up @@ -391,7 +391,7 @@ func newDistro(name string, minor int) *distribution {
ImageFormat: platform.FORMAT_RAW,
},
},
mkAMIImgTypeAarch64(rd.osVersion, rd.isRHEL()),
mkAMIImgTypeAarch64(),
)

ppc64le.addImageTypes(
Expand Down Expand Up @@ -455,7 +455,7 @@ func newDistro(name string, minor int) *distribution {
)

// add GCE RHUI image to RHEL only
x86_64.addImageTypes(gceX86Platform, mkGCERHUIImageType(rd.isRHEL()))
x86_64.addImageTypes(gceX86Platform, mkGCERHUIImageType())
} else {
x86_64.addImageTypes(azureX64Platform, azureImgType)
aarch64.addImageTypes(azureAarch64Platform, azureImgType)
Expand Down
43 changes: 9 additions & 34 deletions pkg/distro/rhel9/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@ var (
}
)

func mkGCEImageType(rhsm bool) imageType {
func mkGCEImageType() imageType {
it := gceImgType
it.defaultImageConfig = baseGCEImageConfig(rhsm)
// The configuration for non-RHUI images does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
it.defaultImageConfig = baseGCEImageConfig()
return it
}

func mkGCERHUIImageType(rhsm bool) imageType {
func mkGCERHUIImageType() imageType {
it := gceRhuiImgType
it.defaultImageConfig = defaultGceRhuiImageConfig(rhsm)
it.defaultImageConfig = defaultGceRhuiImageConfig()
return it
}

func baseGCEImageConfig(rhsm bool) *distro.ImageConfig {
func baseGCEImageConfig() *distro.ImageConfig {
ic := &distro.ImageConfig{
Timezone: common.ToPtr("UTC"),
TimeSynchronization: &osbuild.ChronyStageOptions{
Expand Down Expand Up @@ -154,37 +156,10 @@ func baseGCEImageConfig(rhsm bool) *distro.ImageConfig {
},
}

if rhsm {
ic.RHSMConfig = map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{
subscription.RHSMConfigNoSubscription: {
SubMan: &osbuild.RHSMStageOptionsSubMan{
Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{
AutoRegistration: common.ToPtr(true),
},
// Don't disable RHSM redhat.repo management on the GCE
// image, which is BYOS and does not use RHUI for content.
// Otherwise subscribing the system manually after booting
// it would result in empty redhat.repo. Without RHUI, such
// system would have no way to get Red Hat content, but
// enable the repo management manually, which would be very
// confusing.
},
},
subscription.RHSMConfigWithSubscription: {
SubMan: &osbuild.RHSMStageOptionsSubMan{
Rhsmcertd: &osbuild.SubManConfigRHSMCERTDSection{
AutoRegistration: common.ToPtr(true),
},
// do not disable the redhat.repo management if the user
// explicitly request the system to be subscribed
},
},
}
}
return ic
}

func defaultGceRhuiImageConfig(rhsm bool) *distro.ImageConfig {
func defaultGceRhuiImageConfig() *distro.ImageConfig {
ic := &distro.ImageConfig{
RHSMConfig: map[subscription.RHSMStatus]*osbuild.RHSMStageOptions{
subscription.RHSMConfigNoSubscription: {
Expand All @@ -208,7 +183,7 @@ func defaultGceRhuiImageConfig(rhsm bool) *distro.ImageConfig {
},
},
}
return ic.InheritFrom(baseGCEImageConfig(rhsm))
return ic.InheritFrom(baseGCEImageConfig())
}

func gceCommonPackageSet(t *imageType) rpmmd.PackageSet {
Expand Down

0 comments on commit 74e73b9

Please sign in to comment.