Skip to content

Commit

Permalink
Merge pull request #5626 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…5588-to-release-1.0

🐛 restore - set tenants on the new object graph constructed from files in the backup directory
  • Loading branch information
k8s-ci-robot authored Nov 10, 2021
2 parents 147c6b6 + 700da3e commit 79f4a6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/clusterctl/client/cluster/mover.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (o *objectMover) Restore(toCluster Client, directory string) error {
// by a naming convention (without any explicit OwnerReference).
objectGraph.setSoftOwnership()

// Completes the graph by setting for each node the list of tenants the node belongs to.
objectGraph.setTenants()

// Check whether nodes are not included in GVK considered for restore.
objectGraph.checkVirtualNode()

Expand Down
8 changes: 6 additions & 2 deletions cmd/clusterctl/client/cluster/mover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,12 @@ func Test_objectMover_restore(t *testing.T) {
g.Expect(graph.addRestoredObj(&objs[i])).NotTo(HaveOccurred())
}

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery("")).To(Succeed())
// restore works on the target cluster which does not yet have objs to discover
// instead set the owners and tenants correctly on object graph like how ObjectMover.Restore does
// https://github.com/kubernetes-sigs/cluster-api/blob/main/cmd/clusterctl/client/cluster/mover.go#L129-L132
graph.setSoftOwnership()
graph.setTenants()
graph.checkVirtualNode()

err = mover.restore(graph, toProxy)
if tt.wantErr {
Expand Down

0 comments on commit 79f4a6c

Please sign in to comment.