Skip to content

Commit

Permalink
fix: Remove all nodePorts in the propagated service manifests (#287)
Browse files Browse the repository at this point in the history
Co-authored-by: guofei <[email protected]>
Co-authored-by: Ryan Zhang <[email protected]>
  • Loading branch information
3 people authored Sep 14, 2022
1 parent c64bc1e commit 3d09ebe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/controllers/clusterresourceplacement/resource_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,22 @@ func generateManifest(object *unstructured.Unstructured) (*workv1alpha1.Manifest
unstructured.RemoveNestedField(object.Object, "spec", "clusterIP")
unstructured.RemoveNestedField(object.Object, "spec", "clusterIPs")
}
// We should remove all node ports that are assigned by hubcluster if any.
unstructured.RemoveNestedField(object.Object, "spec", "healthCheckNodePort")

vals, found, err := unstructured.NestedFieldNoCopy(object.Object, "spec", "ports")
if found && err == nil {
if ports, ok := vals.([]interface{}); ok {
for i := range ports {
if each, ok := ports[i].(map[string]interface{}); ok {
delete(each, "nodePort")
}
}
}
}
if err != nil {
return nil, errors.Wrapf(err, "failed to get the ports field in Serivce object, name =%s", object.GetName())
}
}

rawContent, err := object.MarshalJSON()
Expand Down

0 comments on commit 3d09ebe

Please sign in to comment.