Commit 127c6b2f authored by nikhiljindal's avatar nikhiljindal

Fixing a panic by initialising the map before using it

parent 25801575
......@@ -548,6 +548,9 @@ func (ic *IngressController) updateClusterIngressUIDToMasters(cluster *federatio
}
if err == nil {
if masterCluster.Name != cluster.Name { // We're not the master, need to get in sync
if cluster.ObjectMeta.Annotations == nil {
cluster.ObjectMeta.Annotations = map[string]string{}
}
cluster.ObjectMeta.Annotations[uidAnnotationKey] = masterUID
if _, err = ic.federatedApiClient.Federation().Clusters().Update(cluster); err != nil {
glog.Errorf("Failed to add master ingress UID annotation (%q = %q) from master cluster %q to cluster %q, will try again later: %v", uidAnnotationKey, masterUID, masterCluster.Name, cluster.Name, err)
......@@ -561,6 +564,9 @@ func (ic *IngressController) updateClusterIngressUIDToMasters(cluster *federatio
} else {
glog.V(2).Infof("No master cluster found to source an ingress UID from for cluster %q. Attempting to elect new master cluster %q with ingress UID %q = %q", cluster.Name, cluster.Name, uidAnnotationKey, fallbackUID)
if fallbackUID != "" {
if cluster.ObjectMeta.Annotations == nil {
cluster.ObjectMeta.Annotations = map[string]string{}
}
cluster.ObjectMeta.Annotations[uidAnnotationKey] = fallbackUID
if _, err = ic.federatedApiClient.Federation().Clusters().Update(cluster); err != nil {
glog.Errorf("Failed to add ingress UID annotation (%q = %q) to cluster %q. No master elected. Will try again later: %v", uidAnnotationKey, fallbackUID, cluster.Name, err)
......
Markdown is supported
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