@@ -117,18 +117,20 @@ func (c *State) UpsertWorkspace(shard string, ws *tenancyv1alpha1.Workspace) {
117
117
}
118
118
}
119
119
120
- if cluster := c.shardClusterWorkspaceNameCluster [shard ][clusterName ][ws .Name ]; cluster .String () != ws .Spec .Cluster {
121
- if c .shardClusterWorkspaceNameCluster [shard ] == nil {
122
- c .shardClusterWorkspaceNameCluster [shard ] = map [logicalcluster.Name ]map [string ]logicalcluster.Name {}
123
- c .shardClusterWorkspaceName [shard ] = map [logicalcluster.Name ]string {}
124
- c .shardClusterParentCluster [shard ] = map [logicalcluster.Name ]logicalcluster.Name {}
125
- }
126
- if c.shardClusterWorkspaceNameCluster [shard ][clusterName ] == nil {
127
- c.shardClusterWorkspaceNameCluster [shard ][clusterName ] = map [string ]logicalcluster.Name {}
120
+ if ws .Spec .Mount == nil { // If there is no mount, spec.cluster is the only source of truth and should be set.
121
+ if cluster := c.shardClusterWorkspaceNameCluster [shard ][clusterName ][ws .Name ]; cluster .String () != ws .Spec .Cluster {
122
+ if c .shardClusterWorkspaceNameCluster [shard ] == nil {
123
+ c .shardClusterWorkspaceNameCluster [shard ] = map [logicalcluster.Name ]map [string ]logicalcluster.Name {}
124
+ c .shardClusterWorkspaceName [shard ] = map [logicalcluster.Name ]string {}
125
+ c .shardClusterParentCluster [shard ] = map [logicalcluster.Name ]logicalcluster.Name {}
126
+ }
127
+ if c.shardClusterWorkspaceNameCluster [shard ][clusterName ] == nil {
128
+ c.shardClusterWorkspaceNameCluster [shard ][clusterName ] = map [string ]logicalcluster.Name {}
129
+ }
130
+ c.shardClusterWorkspaceNameCluster [shard ][clusterName ][ws .Name ] = logicalcluster .Name (ws .Spec .Cluster )
131
+ c .shardClusterWorkspaceName [shard ][logicalcluster .Name (ws .Spec .Cluster )] = ws .Name
132
+ c .shardClusterParentCluster [shard ][logicalcluster .Name (ws .Spec .Cluster )] = clusterName
128
133
}
129
- c.shardClusterWorkspaceNameCluster [shard ][clusterName ][ws .Name ] = logicalcluster .Name (ws .Spec .Cluster )
130
- c .shardClusterWorkspaceName [shard ][logicalcluster .Name (ws .Spec .Cluster )] = ws .Name
131
- c .shardClusterParentCluster [shard ][logicalcluster .Name (ws .Spec .Cluster )] = clusterName
132
134
}
133
135
134
136
if ws .Spec .Mount != nil {
0 commit comments