Skip to content

Commit

Permalink
Merge pull request #433 from fao89/vhost
Browse files Browse the repository at this point in the history
Fix vhost configuration
  • Loading branch information
openshift-merge-bot[bot] authored Oct 4, 2024
2 parents 3dda9a4 + 1fe7d9d commit 4960778
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
14 changes: 5 additions & 9 deletions controllers/heat_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,15 +966,15 @@ func (r *HeatReconciler) generateServiceSecrets(
templateParameters := initTemplateParameters(instance, authURL, password, authEncryptionKey, transportURL, mc, databaseAccount, dbSecret)

// Render vhost configuration for API and CFN
var httpdAPIVhostConfig map[string]interface{}
var httpdCfnAPIVhostConfig map[string]interface{}
httpdAPIVhostConfig := map[string]interface{}{}
httpdCfnAPIVhostConfig := map[string]interface{}{}
for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} {
var (
apiTLSEnabled = instance.Spec.HeatAPI.TLS.API.Enabled(endpt)
cfnAPITLSEnabled = instance.Spec.HeatCfnAPI.TLS.API.Enabled(endpt)
)
httpdAPIVhostConfig = renderVhost(instance, endpt, heatapi.ServiceName, apiTLSEnabled)
httpdCfnAPIVhostConfig = renderVhost(instance, endpt, heatcfnapi.ServiceName, cfnAPITLSEnabled)
renderVhost(httpdAPIVhostConfig, instance, endpt, heatapi.ServiceName, apiTLSEnabled)
renderVhost(httpdCfnAPIVhostConfig, instance, endpt, heatcfnapi.ServiceName, cfnAPITLSEnabled)
}

// create HeatAPI httpd vhost template parameters
Expand Down Expand Up @@ -1327,9 +1327,7 @@ func initTemplateParameters(
}
}

func renderVhost(instance *heatv1beta1.Heat, endpt service.Endpoint, serviceName string, tlsEnabled bool) map[string]interface{} {
httpdVhostConfig := map[string]interface{}{}

func renderVhost(httpdVhostConfig map[string]interface{}, instance *heatv1beta1.Heat, endpt service.Endpoint, serviceName string, tlsEnabled bool) {
var (
ServerNameString = fmt.Sprintf("%s-%s.%s.svc", serviceName, endpt.String(), instance.Namespace)
SSLCertFilePath = fmt.Sprintf("/etc/pki/tls/certs/%s.crt", endpt.String())
Expand All @@ -1344,6 +1342,4 @@ func renderVhost(instance *heatv1beta1.Heat, endpt service.Endpoint, serviceName
endptConfig["SSLCertificateKeyFile"] = SSLKeyFilePath
}
httpdVhostConfig[endpt.String()] = endptConfig

return httpdVhostConfig
}
38 changes: 17 additions & 21 deletions controllers/heat_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,40 @@ func TestRenderVhost(t *testing.T) {
endpt service.Endpoint
serviceName string
tlsEnabled bool
expected map[string]interface{}
}{
{
name: "Basic case with TLS disabled",
instance: instanceTest1,
endpt: "internal",
serviceName: "my-service",
tlsEnabled: false,
expected: map[string]interface{}{
"internal": map[string]interface{}{
"ServerName": "my-service-internal.test1HeatNamespace.svc",
"TLS": false,
},
},
},
{
name: "Basic case with TLS enabled",
instance: instanceTest1,
endpt: "public",
serviceName: "my-service",
tlsEnabled: true,
expected: map[string]interface{}{
"public": map[string]interface{}{
"ServerName": "my-service-public.test1HeatNamespace.svc",
"TLS": true,
"SSLCertificateFile": "/etc/pki/tls/certs/public.crt",
"SSLCertificateKeyFile": "/etc/pki/tls/private/public.key",
},
},
},
}

expected := map[string]interface{}{
"internal": map[string]interface{}{
"ServerName": "my-service-internal.test1HeatNamespace.svc",
"TLS": false,
},
"public": map[string]interface{}{
"ServerName": "my-service-public.test1HeatNamespace.svc",
"TLS": true,
"SSLCertificateFile": "/etc/pki/tls/certs/public.crt",
"SSLCertificateKeyFile": "/etc/pki/tls/private/public.key",
},
}
result := map[string]interface{}{}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := renderVhost(tt.instance, tt.endpt, tt.serviceName, tt.tlsEnabled)
if !reflect.DeepEqual(result, tt.expected) {
t.Errorf("Expected %v, got %v", tt.expected, result)
}
})
renderVhost(result, tt.instance, tt.endpt, tt.serviceName, tt.tlsEnabled)
}
if !reflect.DeepEqual(result, expected) {
t.Errorf("Expected %v, got %v", expected, result)
}
}
3 changes: 0 additions & 3 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@
heat_tempest_plugin.*
cifmw_test_operator_tempest_exclude_list: |
heat_tempest_plugin.tests.functional.test_os_wait_condition.OSWaitCondition.test_create_stack_with_multi_signal_waitcondition
heat_tempest_plugin.tests.functional.test_software_config.ParallelDeploymentsTest.test_deployments_metadata
heat_tempest_plugin.tests.scenario.test_server_cfn_init.CfnInitIntegrationTest.test_server_cfn_init
heat_tempest_plugin.tests.scenario.test_aodh_alarm.AodhAlarmTest.test_alarm
heat_tempest_plugin.tests.scenario.test_base_resources.BasicResourcesTest.test_base_resources_integration
heat_tempest_plugin.tests.scenario.test_server_signal.ServerSignalIntegrationTest.test_server_signal_userdata_format_raw
heat_tempest_plugin.tests.scenario.test_server_signal.ServerSignalIntegrationTest.test_server_signal_userdata_format_software_config
heat_tempest_plugin.tests.scenario.test_server_software_config.SoftwareConfigIntegrationTest.test_server_software_config
heat_tempest_plugin.tests.scenario.test_remote_deeply_nested.RemoteDeeplyNestedStackTest.test_remote_nested
heat_tempest_plugin.tests.functional.test_remote_stack.RemoteStackTest
external_plugin: "opendev.org/openstack/heat-tempest-plugin"
change_item: "{{ zuul['items'] | selectattr('project.canonical_name', 'equalto', external_plugin) }}"
cifmw_test_operator_tempest_external_plugin: "{{ [] if change_item | length < 1 else [ { 'repository': 'https://' + external_plugin + '.git', 'changeRepository': 'https://review' + external_plugin, 'changeRefspec': [ 'refs/changes', change_item[0].change[-2:], change_item[0].change, change_item[0].patchset ] | join('/') } ] }}"

0 comments on commit 4960778

Please sign in to comment.