Commit 2dce0cff authored by engowzhou's avatar engowzhou Committed by tangcong
Browse files

fix: failed to add/remove member if affinity and toleration is nil

parent 0473ac34
Showing with 8 additions and 2 deletions
+8 -2
......@@ -423,13 +423,19 @@ func (c *EtcdClusterKstone) generateEtcdSpec(cluster *kstonev1alpha2.EtcdCluster
spec["repository"] = cluster.Annotations["repository"]
}
affinity := &cluster.Spec.Affinity
// TODO: Use struct to replace
affinity := make(map[string]interface{})
affinityBytes, _ := json.Marshal(cluster.Spec.Affinity)
_ = json.Unmarshal(affinityBytes, &affinity)
if affinity != nil {
spec["template"].(map[string]interface{})["affinity"] = affinity
}
if cluster.Spec.Tolerations != nil && len(cluster.Spec.Tolerations) > 0 {
spec["template"].(map[string]interface{})["tolerations"] = cluster.Spec.Tolerations
tolerations := make([]interface{}, 0)
tolerationsBytes, _ := json.Marshal(cluster.Spec.Tolerations)
_ = json.Unmarshal(tolerationsBytes, &tolerations)
spec["template"].(map[string]interface{})["tolerations"] = tolerations
}
return spec
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment