Skip to content

Commit 4a615ec

Browse files
committed
remove etc-pki-entitlement cruft
1 parent b2e4422 commit 4a615ec

File tree

10 files changed

+53
-152
lines changed

10 files changed

+53
-152
lines changed

devex/cmd/onclustertesting/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ feature is implemented in OCL, this should no longer be a problem.
8787
### RHEL entitlements
8888

8989
If your cluster has the `etc-pki-entitlement` secret in the
90-
`openshift-config-managed` namespace, you can use the
91-
`--copy-etc-pki-entitlement-secret` flag with the `setup` command. This will
92-
clone the secret into the MCO namespace. This copy will be removed during the
93-
teardown process.
90+
`openshift-config-managed` namespace, the operator will automatically
91+
copy it into the MCO namespace, when a build is required.
9492

9593
### /etc/yum.repos.d and /etc/pki/rpm-gpg
9694

devex/cmd/onclustertesting/ci.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ const (
2121
func runCiSetupCmd(setupOpts opts) error {
2222
utils.ParseFlags()
2323

24-
if setupOpts.injectYumRepos && setupOpts.copyEtcPkiEntitlementSecret {
25-
return fmt.Errorf("flags --inject-yum-repos and --copy-etc-pki-entitlement cannot be combined")
26-
}
27-
2824
if err := utils.CheckForBinaries([]string{"oc"}); err != nil {
2925
return err
3026
}

devex/cmd/onclustertesting/machineosconfigs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func newMachineOSConfig(opts moscOpts) *mcfgv1.MachineOSConfig {
4444
},
4545
RenderedImagePushSpec: mcfgv1.ImageTagFormat(opts.finalImagePullspec),
4646
ImageBuilder: mcfgv1.MachineOSImageBuilder{
47-
ImageBuilderType: mcfgv1.MachineOSImageBuilderType("PodImageBuilder"),
47+
ImageBuilderType: mcfgv1.JobBuilder,
4848
},
4949
Containerfile: []mcfgv1.MachineOSContainerfile{
5050
{

devex/cmd/onclustertesting/opts.go

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,34 @@ import (
99
)
1010

1111
type opts struct {
12-
pushSecretName string
13-
pullSecretName string
14-
finalImagePullSecretName string
15-
pushSecretPath string
16-
pullSecretPath string
17-
finalImagePullspec string
18-
containerfilePath string
19-
containerfileContents string
20-
poolName string
21-
injectYumRepos bool
22-
waitForBuildInfo bool
23-
copyEtcPkiEntitlementSecret bool
24-
enableFeatureGate bool
12+
pushSecretName string
13+
pullSecretName string
14+
finalImagePullSecretName string
15+
pushSecretPath string
16+
pullSecretPath string
17+
finalImagePullspec string
18+
containerfilePath string
19+
containerfileContents string
20+
poolName string
21+
injectYumRepos bool
22+
waitForBuildInfo bool
23+
enableFeatureGate bool
2524
}
2625

2726
func (o *opts) deepCopy() opts {
2827
return opts{
29-
pushSecretName: o.pushSecretName,
30-
pullSecretName: o.pullSecretName,
31-
pushSecretPath: o.pushSecretPath,
32-
pullSecretPath: o.pullSecretPath,
33-
finalImagePullspec: o.finalImagePullspec,
34-
finalImagePullSecretName: o.finalImagePullSecretName,
35-
containerfilePath: o.containerfilePath,
36-
containerfileContents: o.containerfileContents,
37-
poolName: o.poolName,
38-
injectYumRepos: o.injectYumRepos,
39-
waitForBuildInfo: o.waitForBuildInfo,
40-
copyEtcPkiEntitlementSecret: o.copyEtcPkiEntitlementSecret,
41-
enableFeatureGate: o.enableFeatureGate,
28+
pushSecretName: o.pushSecretName,
29+
pullSecretName: o.pullSecretName,
30+
pushSecretPath: o.pushSecretPath,
31+
pullSecretPath: o.pullSecretPath,
32+
finalImagePullspec: o.finalImagePullspec,
33+
finalImagePullSecretName: o.finalImagePullSecretName,
34+
containerfilePath: o.containerfilePath,
35+
containerfileContents: o.containerfileContents,
36+
poolName: o.poolName,
37+
injectYumRepos: o.injectYumRepos,
38+
waitForBuildInfo: o.waitForBuildInfo,
39+
enableFeatureGate: o.enableFeatureGate,
4240
}
4341
}
4442

devex/cmd/onclustertesting/secrets.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,6 @@ func copyGlobalPullSecret(cs *framework.ClientSet) error {
3939
return utils.CloneSecretWithLabels(cs, src, dst, labels)
4040
}
4141

42-
func copyEtcPkiEntitlementSecret(cs *framework.ClientSet) error {
43-
name := "etc-pki-entitlement"
44-
45-
src := utils.SecretRef{
46-
Name: name,
47-
Namespace: "openshift-config-managed",
48-
}
49-
50-
dst := utils.SecretRef{
51-
Name: name,
52-
Namespace: ctrlcommon.MCONamespace,
53-
}
54-
55-
labels := map[string]string{
56-
createdByOnClusterBuildsHelper: "",
57-
}
58-
59-
err := utils.CloneSecretWithLabels(cs, src, dst, labels)
60-
if apierrs.IsNotFound(err) {
61-
klog.Warningf("Secret %s not found, cannot copy", src.String())
62-
return nil
63-
}
64-
65-
return fmt.Errorf("could not copy secret %s to %s: %w", src.String(), dst.String(), err)
66-
}
67-
6842
func getSecretNameFromFile(path string) (string, error) {
6943
secret, err := loadSecretFromFile(path)
7044

devex/cmd/onclustertesting/setup.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func init() {
5555
setupCmd.PersistentFlags().StringVar(&setupOpts.containerfilePath, "containerfile-path", "", "Optional Containerfile to inject for the build.")
5656
setupCmd.PersistentFlags().BoolVar(&setupOpts.enableFeatureGate, "enable-feature-gate", false, "Enables the required featuregates if not already enabled.")
5757
setupCmd.PersistentFlags().BoolVar(&setupOpts.injectYumRepos, "inject-yum-repos", false, fmt.Sprintf("Injects contents from the /etc/yum.repos.d and /etc/pki/rpm-gpg directories found in %s into the %s namespace.", yumReposContainerImagePullspec, ctrlcommon.MCONamespace))
58-
setupCmd.PersistentFlags().BoolVar(&setupOpts.copyEtcPkiEntitlementSecret, "copy-etc-pki-entitlement-secret", false, fmt.Sprintf("Copies etc-pki-entitlement into the %s namespace, assuming it exists.", ctrlcommon.MCONamespace))
5958

6059
rootCmd.AddCommand(setupCmd)
6160
}
@@ -84,10 +83,6 @@ func runSetupCmd(setupOpts opts) error {
8483
return fmt.Errorf("flags --push-secret-name and --push-secret-path cannot be combined")
8584
}
8685

87-
if setupOpts.injectYumRepos && setupOpts.copyEtcPkiEntitlementSecret {
88-
return fmt.Errorf("flags --inject-yum-repos and --copy-etc-pki-entitlement cannot be combined")
89-
}
90-
9186
if err := utils.CheckForBinaries([]string{"oc"}); err != nil {
9287
return err
9388
}
@@ -99,15 +94,14 @@ func runSetupCmd(setupOpts opts) error {
9994
}
10095

10196
return mobSetup(cs, opts{
102-
pushSecretName: setupOpts.pushSecretName,
103-
pullSecretName: setupOpts.pullSecretName,
104-
pushSecretPath: setupOpts.pushSecretPath,
105-
pullSecretPath: setupOpts.pullSecretPath,
106-
finalImagePullspec: setupOpts.finalImagePullspec,
107-
containerfilePath: setupOpts.containerfilePath,
108-
poolName: setupOpts.poolName,
109-
injectYumRepos: setupOpts.injectYumRepos,
110-
copyEtcPkiEntitlementSecret: setupOpts.copyEtcPkiEntitlementSecret,
97+
pushSecretName: setupOpts.pushSecretName,
98+
pullSecretName: setupOpts.pullSecretName,
99+
pushSecretPath: setupOpts.pushSecretPath,
100+
pullSecretPath: setupOpts.pullSecretPath,
101+
finalImagePullspec: setupOpts.finalImagePullspec,
102+
containerfilePath: setupOpts.containerfilePath,
103+
poolName: setupOpts.poolName,
104+
injectYumRepos: setupOpts.injectYumRepos,
111105
})
112106
}
113107

@@ -118,10 +112,6 @@ func runInClusterRegistrySetupCmd(setupOpts opts) error {
118112
return err
119113
}
120114

121-
if setupOpts.injectYumRepos && setupOpts.copyEtcPkiEntitlementSecret {
122-
return fmt.Errorf("flags --inject-yum-repos and --copy-etc-pki-entitlement cannot be combined")
123-
}
124-
125115
cs := framework.NewClientSet("")
126116

127117
if err := checkForRequiredFeatureGates(cs, setupOpts); err != nil {
@@ -215,12 +205,6 @@ func createSecrets(cs *framework.ClientSet, opts opts) error {
215205

216206
}
217207

218-
if opts.copyEtcPkiEntitlementSecret {
219-
eg.Go(func() error {
220-
return copyEtcPkiEntitlementSecret(cs)
221-
})
222-
}
223-
224208
if opts.injectYumRepos {
225209
eg.Go(func() error {
226210
return extractAndInjectYumEpelRepos(cs)

pkg/controller/build/buildrequest/machineosbuild_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestMachineOSBuild(t *testing.T) {
2828
}
2929

3030
// Some of the test cases expect the hash name to be the same. This is that hash value.
31-
expectedCommonHashName := "worker-e945ec808b468c07f6a2cf1936c23a13"
31+
expectedCommonHashName := "worker-55592464e51104dcc274a300565fec9e"
3232

3333
testCases := []struct {
3434
name string

test/e2e-ocl/helpers_test.go

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/distribution/reference"
2121
imagev1 "github.com/openshift/api/image/v1"
2222
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
23+
"github.com/openshift/machine-config-operator/pkg/controller/build/constants"
2324
"github.com/openshift/machine-config-operator/pkg/controller/build/utils"
2425
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
2526
"github.com/openshift/machine-config-operator/test/framework"
@@ -35,10 +36,6 @@ import (
3536
"sigs.k8s.io/yaml"
3637
)
3738

38-
const (
39-
clonedSecretLabelKey string = "machineconfiguration.openshift.io/cloned-secret"
40-
)
41-
4239
func applyMC(t *testing.T, cs *framework.ClientSet, mc *mcfgv1.MachineConfig) func() {
4340
cleanupFunc := helpers.ApplyMC(t, cs, mc)
4441
t.Logf("Created new MachineConfig %q", mc.Name)
@@ -696,34 +693,17 @@ func convertFilesFromContainerImageToBytesMap(t *testing.T, pullspec, containerF
696693
return out
697694
}
698695

699-
// Copy the entitlement certificates into the MCO namespace. If the secrets
700-
// cannot be found, calls t.Skip() to skip the test.
701-
//
702-
// Registers and returns a cleanup function to remove the certificate(s) after test completion.
703-
func copyEntitlementCerts(t *testing.T, cs *framework.ClientSet) func() {
704-
src := metav1.ObjectMeta{
705-
Name: "etc-pki-entitlement",
706-
Namespace: "openshift-config-managed",
707-
}
708-
709-
dst := metav1.ObjectMeta{
710-
Name: src.Name,
711-
Namespace: ctrlcommon.MCONamespace,
712-
}
713-
714-
_, err := cs.CoreV1Interface.Secrets(src.Namespace).Get(context.TODO(), src.Name, metav1.GetOptions{})
715-
if err == nil {
716-
return cloneSecret(t, cs, src, dst)
717-
}
696+
// Skips the test if the entitlement secret is not present.
697+
func skipIfEntitlementNotPresent(t *testing.T, cs *framework.ClientSet) {
718698

699+
_, err := cs.CoreV1Interface.Secrets(constants.EtcPkiEntitlementSecretName).Get(context.TODO(), ctrlcommon.OpenshiftConfigManagedNamespace, metav1.GetOptions{})
719700
if k8serrors.IsNotFound(err) {
720-
t.Logf("Secret %q not found in %q, skipping test", src.Name, src.Namespace)
701+
t.Logf("Secret %q not found in %q, skipping test", constants.EtcPkiEntitlementSecretName, ctrlcommon.OpenshiftConfigManagedNamespace)
721702
t.Skip()
722-
return func() {}
703+
return
723704
}
724-
725-
t.Fatalf("could not get %q from %q: %s", src.Name, src.Namespace, err)
726-
return func() {}
705+
// No other errors are expected.
706+
require.NoError(t, err)
727707
}
728708

729709
// Uses the centos stream 9 container and extracts the contents of both the
@@ -768,34 +748,6 @@ func injectYumRepos(t *testing.T, cs *framework.ClientSet) func() {
768748
})
769749
}
770750

771-
// Clones a given secret from a given namespace into the MCO namespace.
772-
// Registers and returns a cleanup function to delete the secret upon test
773-
// completion.
774-
func cloneSecret(t *testing.T, cs *framework.ClientSet, src, dst metav1.ObjectMeta) func() {
775-
secret, err := cs.CoreV1Interface.Secrets(src.Namespace).Get(context.TODO(), src.Name, metav1.GetOptions{})
776-
require.NoError(t, err)
777-
778-
secretCopy := &corev1.Secret{
779-
ObjectMeta: metav1.ObjectMeta{
780-
Name: dst.Name,
781-
Namespace: dst.Namespace,
782-
Labels: map[string]string{
783-
clonedSecretLabelKey: "",
784-
},
785-
},
786-
Data: secret.Data,
787-
Type: secret.Type,
788-
}
789-
790-
cleanup := createSecret(t, cs, secretCopy)
791-
t.Logf("Cloned \"%s/%s\" to \"%s/%s\"", src.Namespace, src.Name, dst.Namespace, dst.Name)
792-
793-
return makeIdempotentAndRegister(t, func() {
794-
cleanup()
795-
t.Logf("Deleted cloned secret \"%s/%s\"", dst.Namespace, dst.Name)
796-
})
797-
}
798-
799751
func newMachineConfig(name, pool string) *mcfgv1.MachineConfig {
800752
mode := 420
801753
testfiledata := fmt.Sprintf("data:,%s-%s", name, pool)

test/e2e-ocl/onclusterlayering_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type onClusterLayeringTestOpts struct {
8686
poolName string
8787

8888
// Use RHEL entitlements
89-
useEtcPkiEntitlement bool
89+
entitlementRequired bool
9090

9191
// Inject YUM repo information from a Centos 9 stream container
9292
useYumRepos bool
@@ -211,9 +211,8 @@ func TestYumReposBuilds(t *testing.T) {
211211
})
212212
}
213213

214-
// Clones the etc-pki-entitlement certificate from the openshift-config-managed
215-
// namespace into the MCO namespace. Then performs an on-cluster layering build
216-
// which should consume the entitlement certificates.
214+
// Then performs an on-cluster layering build which should consume the
215+
// etc-pki-entitlement certificates.
217216
func TestEntitledBuilds(t *testing.T) {
218217
skipOnOKD(t)
219218

@@ -222,7 +221,7 @@ func TestEntitledBuilds(t *testing.T) {
222221
customDockerfiles: map[string]string{
223222
layeredMCPName: entitledDockerfile,
224223
},
225-
useEtcPkiEntitlement: true,
224+
entitlementRequired: true,
226225
})
227226
}
228227

@@ -786,10 +785,10 @@ func assertBuildJobIsAsExpected(t *testing.T, cs *framework.ClientSet, mosb *mcf
786785
// Returns a MachineOSConfig object for the caller to create to begin the build
787786
// process.
788787
func prepareForOnClusterLayeringTest(t *testing.T, cs *framework.ClientSet, testOpts onClusterLayeringTestOpts) *mcfgv1.MachineOSConfig {
789-
// If the test requires RHEL entitlements, clone them from
790-
// "etc-pki-entitlement" in the "openshift-config-managed" namespace.
791-
if testOpts.useEtcPkiEntitlement {
792-
copyEntitlementCerts(t, cs)
788+
// If the test requires RHEL entitlements, ensure they are present
789+
// in the test cluster. If not found, the test is skipped.
790+
if testOpts.entitlementRequired {
791+
skipIfEntitlementNotPresent(t, cs)
793792
}
794793

795794
// If the test requires /etc/yum.repos.d and /etc/pki/rpm-gpg, pull a Centos

test/helpers/machineosconfigbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewMachineOSConfigBuilder(name string) *MachineOSConfigBuilder {
2626

2727
Containerfile: []mcfgv1.MachineOSContainerfile{},
2828
ImageBuilder: mcfgv1.MachineOSImageBuilder{
29-
ImageBuilderType: mcfgv1.MachineOSImageBuilderType("PodImageBuilder"),
29+
ImageBuilderType: mcfgv1.JobBuilder,
3030
},
3131
BaseImagePullSecret: nil,
3232
RenderedImagePushSecret: mcfgv1.ImageSecretObjectReference{},

0 commit comments

Comments
 (0)