Skip to content

Commit

Permalink
Fix rebase conflicts, missed powervs tests, adjust powervs assets
Browse files Browse the repository at this point in the history
  • Loading branch information
lobziik committed Mar 31, 2022
1 parent bfd9a6c commit e3a1986
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
23 changes: 19 additions & 4 deletions pkg/cloud/cloud_test.go
Expand Up @@ -52,6 +52,7 @@ func (tp *testPlatform) getOperatorConfig() config.OperatorConfig {
CloudControllerManagerIBM: "registry.ci.openshift.org/openshift:ibm-cloud-controller-manager",
CloudControllerManagerOpenStack: "registry.ci.openshift.org/openshift:openstack-cloud-controller-manager",
CloudControllerManagerVSphere: "registry.ci.openshift.org/openshift:vsphere-cloud-controller-manager",
CloudControllerManagerPowerVS: "quay.io/openshift/origin-powervs-cloud-controller-manager",
},
PlatformStatus: tp.platformStatus,
InfrastructureName: "my-cool-cluster-777",
Expand All @@ -70,6 +71,7 @@ func getPlatforms() testPlatformsMap {
string(configv1.VSpherePlatformType): {getDummyPlatformStatus(configv1.VSpherePlatformType, false)},
string(configv1.OvirtPlatformType): {getDummyPlatformStatus(configv1.OvirtPlatformType, false)},
string(configv1.IBMCloudPlatformType): {getDummyPlatformStatus(configv1.IBMCloudPlatformType, false)},
string(configv1.PowerVSPlatformType): {getDummyPlatformStatus(configv1.PowerVSPlatformType, false)},
string(configv1.LibvirtPlatformType): {getDummyPlatformStatus(configv1.LibvirtPlatformType, false)},
string(configv1.KubevirtPlatformType): {getDummyPlatformStatus(configv1.KubevirtPlatformType, false)},
string(configv1.BareMetalPlatformType): {getDummyPlatformStatus(configv1.BareMetalPlatformType, false)},
Expand Down Expand Up @@ -127,19 +129,17 @@ func TestGetResources(t *testing.T) {
}, {
name: "OpenStack resources returned as expected",
testPlatform: platformsMap[string(configv1.OpenStackPlatformType)],
expectedResourceCount: 3,
expectedResourceCount: 2,
expectedResourcesKindName: []string{
"ConfigMap/openstack-cloud-controller-manager-config",
"Deployment/openstack-cloud-controller-manager",
"PodDisruptionBudget/openstack-cloud-controller-manager",
},
}, {
name: "OpenStack resources returned as expected with signle node cluster",
testPlatform: platformsMap[string(configv1.OpenStackPlatformType)],
expectedResourceCount: 2,
expectedResourceCount: 1,
singleReplica: true,
expectedResourcesKindName: []string{
"ConfigMap/openstack-cloud-controller-manager-config",
"Deployment/openstack-cloud-controller-manager",
},
}, {
Expand Down Expand Up @@ -223,6 +223,21 @@ func TestGetResources(t *testing.T) {
expectedResourceCount: 1,
singleReplica: true,
expectedResourcesKindName: []string{"Deployment/ibm-cloud-controller-manager"},
}, {
name: "PowerVS resources",
testPlatform: platformsMap[string(configv1.PowerVSPlatformType)],
expectedResourceCount: 2,
singleReplica: false,
expectedResourcesKindName: []string{
"Deployment/powervs-cloud-controller-manager",
"PodDisruptionBudget/powervs-cloud-controller-manager",
},
}, {
name: "PowerVS resources with single node cluster",
testPlatform: platformsMap[string(configv1.PowerVSPlatformType)],
expectedResourceCount: 1,
singleReplica: true,
expectedResourcesKindName: []string{"Deployment/powervs-cloud-controller-manager"},
}, {
name: "Libvirt resources are empty",
testPlatform: platformsMap[string(configv1.LibvirtPlatformType)],
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloud/powervs/assets/deployment.yaml
Expand Up @@ -5,17 +5,20 @@ metadata:
namespace: openshift-cloud-controller-manager
labels:
k8s-app: powervs-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
replicas: 2
strategy:
type: Recreate
selector:
matchLabels:
k8s-app: powervs-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
template:
metadata:
labels:
k8s-app: powervs-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
priorityClassName: system-cluster-critical
hostNetwork: true
Expand All @@ -28,6 +31,7 @@ spec:
labelSelector:
matchLabels:
k8s-app: powervs-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
Expand Down
10 changes: 6 additions & 4 deletions pkg/cloud/powervs/powervs.go
Expand Up @@ -27,7 +27,8 @@ type imagesReference struct {
}

var templateValuesValidationMap = map[string]interface{}{
"images": "required",
"images": "required",
"cloudproviderName": "required,type(string)",
}

type powerVSAssets struct {
Expand All @@ -39,9 +40,10 @@ func (assets *powerVSAssets) GetRenderedResources() []client.Object {
return assets.renderedResources
}

func getTemplateValues(images *imagesReference) (common.TemplateValues, error) {
func getTemplateValues(images *imagesReference, operatorConfig config.OperatorConfig) (common.TemplateValues, error) {
values := common.TemplateValues{
"images": images,
"images": images,
"cloudproviderName": operatorConfig.GetPlatformNameString(),
}
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
if err != nil {
Expand All @@ -66,7 +68,7 @@ func NewProviderAssets(config config.OperatorConfig) (common.CloudProviderAssets
if err != nil {
return nil, err
}
templateValues, err := getTemplateValues(images)
templateValues, err := getTemplateValues(images, config)
if err != nil {
return nil, fmt.Errorf("can not construct template values for %s assets: %v", providerName, err)
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/cloud/powervs/powervs_test.go
Expand Up @@ -3,6 +3,7 @@ package powervs
import (
"testing"

configv1 "github.com/openshift/api/config/v1"
"github.com/stretchr/testify/assert"

"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
Expand All @@ -19,12 +20,21 @@ func TestResourcesRenderingSmoke(t *testing.T) {
name: "Empty config",
config: config.OperatorConfig{},
initErrMsg: "powervs: missed images in config: CloudControllerManager: non zero value required",
}, {
name: "No platform status",
config: config.OperatorConfig{
ImagesReference: config.ImagesReference{
CloudControllerManagerPowerVS: "CloudControllerManagerPowerVS",
},
},
initErrMsg: "can not construct template values for powervs assets: cloudproviderName: non zero value required",
}, {
name: "Minimal allowed config",
config: config.OperatorConfig{
ImagesReference: config.ImagesReference{
CloudControllerManagerPowerVS: "CloudControllerManagerPowerVS",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.PowerVSPlatformType},
},
},
}
Expand Down

0 comments on commit e3a1986

Please sign in to comment.