Skip to content

Commit

Permalink
CA: integrate BasicSnapshotStore with drasnapshot.Snapshot
Browse files Browse the repository at this point in the history
Store the DRA snapshot inside the current internal data in
SetClusterState().

Retrieve the DRA snapshot from the current internal data in
DraSnapshot().

Clone the DRA snapshot whenever the internal data is cloned
during Fork(). This matches the forking logic that BasicSnapshotStore
uses, ensuring that the DRA object state is correctly
forked/commited/reverted during the corresponding ClusterSnapshot
operations.

This should be a no-op, as DraSnapshot() isn't called anywhere yet,
adn no DRA snapshot is passed to SetClusterState() yet.
  • Loading branch information
towca committed Dec 4, 2024
1 parent 817f222 commit 297a590
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cluster-autoscaler/simulator/clustersnapshot/store/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type BasicSnapshotStore struct {
type internalBasicSnapshotData struct {
nodeInfoMap map[string]*schedulerframework.NodeInfo
pvcNamespacePodMap map[string]map[string]bool
draSnapshot drasnapshot.Snapshot
}

func (data *internalBasicSnapshotData) listNodeInfos() []*schedulerframework.NodeInfo {
Expand Down Expand Up @@ -142,6 +143,7 @@ func (data *internalBasicSnapshotData) clone() *internalBasicSnapshotData {
return &internalBasicSnapshotData{
nodeInfoMap: clonedNodeInfoMap,
pvcNamespacePodMap: clonedPvcNamespaceNodeMap,
draSnapshot: data.draSnapshot.Clone(),
}
}

Expand Down Expand Up @@ -208,8 +210,7 @@ func (snapshot *BasicSnapshotStore) getInternalData() *internalBasicSnapshotData

// DraSnapshot returns the DRA snapshot.
func (snapshot *BasicSnapshotStore) DraSnapshot() drasnapshot.Snapshot {
// TODO(DRA): Return DRA snapshot.
return drasnapshot.Snapshot{}
return snapshot.getInternalData().draSnapshot
}

// GetNodeInfo gets a NodeInfo.
Expand Down Expand Up @@ -262,7 +263,7 @@ func (snapshot *BasicSnapshotStore) SetClusterState(nodes []*apiv1.Node, schedul
}
}
}
// TODO(DRA): Save DRA snapshot.
snapshot.getInternalData().draSnapshot = draSnapshot
return nil
}

Expand Down

0 comments on commit 297a590

Please sign in to comment.