Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/dataplane/util/ansible_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (a *EEJob) FormatAEEExtraVars(
}

if len(deployment.Spec.ServicesOverride) > 0 {
a.ExtraVars["edpm_services_override"] = json.RawMessage([]byte(fmt.Sprintf("\"%s\"", deployment.Spec.ServicesOverride)))
a.ExtraVars["edpm_services_override"], _ = json.Marshal(deployment.Spec.ServicesOverride)
}
}

Expand Down
4 changes: 4 additions & 0 deletions internal/dataplane/util/ansibleee.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func (a *EEJob) JobForOpenStackAnsibleEE(h *helper.Helper) (*batchv1.Job, error)
parsedExtraVars := ""
// unmarshal nested data structures
for _, variable := range keys {
if variable == "edpm_services_override" {
parsedExtraVars += fmt.Sprintf("%s: %s\n", variable, a.ExtraVars[variable])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use yaml.marshal() to avoid the issue, but if we think that's expensive we can atleast avoid the hardcoded key check?

if len(a.ExtraVars) > 0 {
    extraVarsMap := make(map[string]interface{})
    for variable, rawValue := range a.ExtraVars {
        var tmp interface{}
        err := yaml.Unmarshal(rawValue, &tmp)
        if err != nil {
            return nil, err
        }
        extraVarsMap[variable] = tmp
    }
    
    yamlBytes, err := yaml.Marshal(extraVarsMap)
    if err != nil {
        return nil, err
    }
    
    setRunnerEnvVar(h, "RUNNER_EXTRA_VARS", string(yamlBytes), "extraVars", job, hashes)
}

or


for _, variable := range keys {
    var tmp interface{}
    err := yaml.Unmarshal(a.ExtraVars[variable], &tmp)
    if err != nil {
        return nil, err
    }
   
    if _, ok := tmp.([]interface{}); ok {
        parsedExtraVars += fmt.Sprintf("%s: %s\n", variable, a.ExtraVars[variable])
    } else {
        parsedExtraVars += fmt.Sprintf("%s: %s\n", variable, tmp)
    }
}

continue
}
var tmp interface{}
err := yaml.Unmarshal(a.ExtraVars[variable], &tmp)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ spec:

edpm_override_hosts: edpm-compute-no-nodes
edpm_service_type: ovn
edpm_services_override: [ovn]
edpm_services_override: ["ovn"]


imagePullPolicy: Always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ spec:

edpm_override_hosts: edpm-compute-no-nodes
edpm_service_type: configure-os
edpm_services_override: [configure-os]
edpm_services_override: ["configure-os"]


imagePullPolicy: Always
Expand Down
4 changes: 2 additions & 2 deletions test/kuttl/tests/dataplane-deploy-tls-test/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ spec:

edpm_override_hosts: openstack-edpm-tls
edpm_service_type: tls-dns-ips
edpm_services_override: [install-certs-ovrd tls-dns-ips custom-tls-dns]
edpm_services_override: ["install-certs-ovrd","tls-dns-ips","custom-tls-dns"]


imagePullPolicy: Always
Expand Down Expand Up @@ -315,7 +315,7 @@ spec:

edpm_override_hosts: openstack-edpm-tls
edpm_service_type: custom-tls-dns
edpm_services_override: [install-certs-ovrd tls-dns-ips custom-tls-dns]
edpm_services_override: ["install-certs-ovrd","tls-dns-ips","custom-tls-dns"]


imagePullPolicy: Always
Expand Down