Skip to content

Commit 21878b3

Browse files
authored
Restructure redhat subscription manager (#724)
* remove rhsm from cloud providers Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]> * refactor rhsm and move it to MC controller Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]> * adjust rhel subscriptions management for aws Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]> * adjust e2e tests Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]> * fixing rhsm unit tests and run e2e test for all cloud providers Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]> * refactor rhel userdata plugin provider and run azure tests always Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]> * documenting rhsm offline token usages and impacts Signed-off-by: Moath Qasim <[email protected]> Signed-off-by: Moath Qasim <[email protected]>
1 parent 48ded76 commit 21878b3

34 files changed

+186
-176
lines changed

.prow.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ presubmits:
216216
cpu: 500m
217217

218218
- name: pull-machine-controller-e2e-azure
219+
always_run: true
219220
decorate: true
220221
error_on_eviction: true
221222
clone_uri: "ssh://[email protected]/kubermatic/machine-controller.git"

examples/aws-machinedeployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,12 @@ spec:
6969
operatingSystem: "coreos"
7070
operatingSystemSpec:
7171
disableAutoUpdate: true
72+
# 'rhelSubscriptionManagerUser' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_USER`
73+
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
74+
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
75+
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
76+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
77+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
78+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
7279
versions:
7380
kubelet: 1.9.6

examples/azure-machinedeployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,12 @@ spec:
7676
operatingSystem: "coreos"
7777
operatingSystemSpec:
7878
distUpgradeOnBoot: false
79+
# 'rhelSubscriptionManagerUser' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_USER`
80+
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
81+
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
82+
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
83+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
84+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
85+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
7986
versions:
8087
kubelet: 1.9.6

examples/gce-machinedeployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,12 @@ spec:
6666
operatingSystem: "coreos"
6767
operatingSystemSpec:
6868
disableAutoUpdate: true
69+
# 'rhelSubscriptionManagerUser' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_USER`
70+
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
71+
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
72+
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
73+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
74+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
75+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
6976
versions:
7077
kubelet: 1.13.5

examples/kubevirt-machinedeployment.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ spec:
4040
distUpgradeOnBoot: false
4141
disableAutoUpdate: true
4242
# 'rhelSubscriptionManagerUser' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_USER`
43-
rhelSubscriptionManagerUser:
43+
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
4444
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
45-
rhelSubscriptionManagerPassword:
45+
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
46+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
47+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
48+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
4649
versions:
4750
kubelet: "1.12.2"

examples/openstack-machinedeployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,8 @@ spec:
116116
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
117117
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
118118
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
119+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
120+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
121+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
119122
versions:
120123
kubelet: 1.9.6

examples/vsphere-datastore-cluster-machinedeployment.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ spec:
6767
operatingSystemSpec:
6868
distUpgradeOnBoot: false
6969
# 'rhelSubscriptionManagerUser' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_USER`
70-
rhelSubscriptionManagerUser:
70+
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
7171
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
72-
rhelSubscriptionManagerPassword:
72+
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
73+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
74+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
75+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
7376
versions:
7477
kubelet: 1.9.6

examples/vsphere-machinedeployment.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ spec:
6767
operatingSystemSpec:
6868
distUpgradeOnBoot: false
6969
# 'rhelSubscriptionManagerUser' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_USER`
70-
rhelSubscriptionManagerUser:
70+
rhelSubscriptionManagerUser: "<< RHEL_SUBSCRIPTION_MANAGER_USER >>"
7171
# 'rhelSubscriptionManagerPassword' is only used for rhel os and can be set via env var `RHEL_SUBSCRIPTION_MANAGER_PASSWORD`
72-
rhelSubscriptionManagerPassword:
72+
rhelSubscriptionManagerPassword: "<< RHEL_SUBSCRIPTION_MANAGER_PASSWORD >>"
73+
# 'rhsmOfflineToken' if it was provided red hat systems subscriptions will be removed upon machines deletions, and if wasn't
74+
# provided the rhsm will be disabled and any created subscription won't be removed automatically
75+
rhsmOfflineToken: "<< REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN >>"
7376
versions:
7477
kubelet: 1.9.6

pkg/cloudprovider/provider/aws/provider.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
cloudprovidererrors "github.com/kubermatic/machine-controller/pkg/cloudprovider/errors"
3939
"github.com/kubermatic/machine-controller/pkg/cloudprovider/instance"
4040
awstypes "github.com/kubermatic/machine-controller/pkg/cloudprovider/provider/aws/types"
41-
"github.com/kubermatic/machine-controller/pkg/cloudprovider/rhsm"
4241
cloudprovidertypes "github.com/kubermatic/machine-controller/pkg/cloudprovider/types"
4342
"github.com/kubermatic/machine-controller/pkg/providerconfig"
4443
providerconfigtypes "github.com/kubermatic/machine-controller/pkg/providerconfig/types"
@@ -146,7 +145,6 @@ type Config struct {
146145
EBSVolumeEncrypted bool
147146
Tags map[string]string
148147
AssignPublicIP *bool
149-
manager rhsm.RedHatSubscriptionManager
150148
}
151149

152150
type amiFilter struct {
@@ -324,13 +322,7 @@ func (p *provider) getConfig(s v1alpha1.ProviderSpec) (*Config, *providerconfigt
324322
c.Tags = rawConfig.Tags
325323
c.IsSpotInstance = rawConfig.IsSpotInstance
326324
c.AssignPublicIP = rawConfig.AssignPublicIP
327-
offlineToken, _ := p.configVarResolver.GetConfigVarStringValueOrEnv(rawConfig.RHSMOfflineToken, "REDHAT_SUBSCRIPTIONS_OFFLINE_TOKEN")
328-
if offlineToken != "" {
329-
c.manager, err = rhsm.NewRedHatSubscriptionManager(offlineToken)
330-
if err != nil {
331-
return nil, nil, nil, fmt.Errorf("failed to create redhat subscription manager: %v", err)
332-
}
333-
}
325+
334326
return &c, &pconfig, &rawConfig, err
335327
}
336328

@@ -590,7 +582,7 @@ func (p *provider) Cleanup(machine *v1alpha1.Machine, _ *cloudprovidertypes.Prov
590582
return false, err
591583
}
592584

593-
config, pc, _, err := p.getConfig(machine.Spec.ProviderSpec)
585+
config, _, _, err := p.getConfig(machine.Spec.ProviderSpec)
594586
if err != nil {
595587
return false, cloudprovidererrors.TerminalError{
596588
Reason: common.InvalidConfigurationMachineError,
@@ -614,12 +606,6 @@ func (p *provider) Cleanup(machine *v1alpha1.Machine, _ *cloudprovidertypes.Prov
614606
klog.V(3).Infof("successfully triggered termination of instance %s at aws", instance.ID())
615607
}
616608

617-
if pc.OperatingSystem == providerconfigtypes.OperatingSystemRHEL && config.manager != nil {
618-
if err := config.manager.UnregisterInstance(*instance.instance.PrivateDnsName); err != nil {
619-
return false, fmt.Errorf("failed delete machine %s subscription: %v", machine.Name, err)
620-
}
621-
}
622-
623609
return false, nil
624610
}
625611

pkg/cloudprovider/provider/aws/types/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ type RawConfig struct {
3939
EBSVolumeEncrypted providerconfigtypes.ConfigVarBool `json:"ebsVolumeEncrypted"`
4040
Tags map[string]string `json:"tags,omitempty"`
4141
AssignPublicIP *bool `json:"assignPublicIP,omitempty"`
42-
RHSMOfflineToken providerconfigtypes.ConfigVarString `json:"rhsmOfflineToken,omitempty"`
4342
}

0 commit comments

Comments
 (0)