@@ -46,39 +46,39 @@ func (*AsyncStorageProvisioner) NeedsStorage(workspace *dw.DevWorkspaceTemplateS
46
46
return needsStorage (workspace )
47
47
}
48
48
49
- func (p * AsyncStorageProvisioner ) ProvisionStorage (podAdditions * v1alpha1.PodAdditions , workspaceWithConfig * common.DevWorkspaceWithConfig , clusterAPI sync.ClusterAPI ) error {
49
+ func (p * AsyncStorageProvisioner ) ProvisionStorage (podAdditions * v1alpha1.PodAdditions , workspace * common.DevWorkspaceWithConfig , clusterAPI sync.ClusterAPI ) error {
50
50
if err := checkConfigured (); err != nil {
51
51
return & ProvisioningError {
52
52
Message : fmt .Sprintf ("%s. Contact an administrator to resolve this issue." , err .Error ()),
53
53
}
54
54
}
55
55
56
- numWorkspaces , _ , err := p .getAsyncWorkspaceCount (workspaceWithConfig .Namespace , clusterAPI )
56
+ numWorkspaces , _ , err := p .getAsyncWorkspaceCount (workspace .Namespace , clusterAPI )
57
57
if err != nil {
58
58
return err
59
59
}
60
60
// If there is more than one started workspace using async storage, then we fail starting additional ones
61
61
// Note we need to check phase so as to not accidentally fail an already-running workspace when a second one
62
62
// is created.
63
- if numWorkspaces > 1 && workspaceWithConfig .Status .Phase != dw .DevWorkspaceStatusRunning {
63
+ if numWorkspaces > 1 && workspace .Status .Phase != dw .DevWorkspaceStatusRunning {
64
64
return & ProvisioningError {
65
- Message : fmt .Sprintf ("cannot provision storage for workspace %s" , workspaceWithConfig .Name ),
65
+ Message : fmt .Sprintf ("cannot provision storage for workspace %s" , workspace .Name ),
66
66
Err : fmt .Errorf ("at most one workspace using async storage can be running in a namespace" ),
67
67
}
68
68
}
69
69
70
70
// Add ephemeral volumes
71
- if err := addEphemeralVolumesFromWorkspace (& workspaceWithConfig .DevWorkspace , podAdditions ); err != nil {
71
+ if err := addEphemeralVolumesFromWorkspace (& workspace .DevWorkspace , podAdditions ); err != nil {
72
72
return err
73
73
}
74
74
75
75
// If persistent storage is not needed, we're done
76
- if ! p .NeedsStorage (& workspaceWithConfig .Spec .Template ) {
76
+ if ! p .NeedsStorage (& workspace .Spec .Template ) {
77
77
return nil
78
78
}
79
79
80
80
// Sync SSH keypair to cluster
81
- secret , configmap , err := asyncstorage .GetOrCreateSSHConfig (& workspaceWithConfig .DevWorkspace , clusterAPI )
81
+ secret , configmap , err := asyncstorage .GetOrCreateSSHConfig (& workspace .DevWorkspace , clusterAPI )
82
82
if err != nil {
83
83
if errors .Is (err , asyncstorage .NotReadyError ) {
84
84
return & NotReadyError {
@@ -89,12 +89,12 @@ func (p *AsyncStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdd
89
89
return err
90
90
}
91
91
92
- pvcName , err := checkForExistingCommonPVC (workspaceWithConfig .Namespace , clusterAPI )
92
+ pvcName , err := checkForExistingCommonPVC (workspace .Namespace , clusterAPI )
93
93
if err != nil {
94
94
return err
95
95
}
96
96
97
- pvcTerminating , err := checkPVCTerminating (pvcName , workspaceWithConfig .Namespace , clusterAPI , workspaceWithConfig .Config )
97
+ pvcTerminating , err := checkPVCTerminating (pvcName , workspace .Namespace , clusterAPI , workspace .Config )
98
98
if err != nil {
99
99
return err
100
100
} else if pvcTerminating {
@@ -106,15 +106,15 @@ func (p *AsyncStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdd
106
106
107
107
if pvcName != "" {
108
108
// Create common PVC if needed
109
- clusterPVC , err := syncCommonPVC (workspaceWithConfig .Namespace , clusterAPI , workspaceWithConfig .Config )
109
+ clusterPVC , err := syncCommonPVC (workspace .Namespace , clusterAPI , workspace .Config )
110
110
if err != nil {
111
111
return err
112
112
}
113
113
pvcName = clusterPVC .Name
114
114
}
115
115
116
116
// Create async server deployment
117
- deploy , err := asyncstorage .SyncWorkspaceSyncDeploymentToCluster (workspaceWithConfig .Namespace , configmap , pvcName , clusterAPI , workspaceWithConfig .Config )
117
+ deploy , err := asyncstorage .SyncWorkspaceSyncDeploymentToCluster (workspace .Namespace , configmap , pvcName , clusterAPI , workspace .Config )
118
118
if err != nil {
119
119
if errors .Is (err , asyncstorage .NotReadyError ) {
120
120
return & NotReadyError {
@@ -157,40 +157,40 @@ func (p *AsyncStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdd
157
157
return err
158
158
}
159
159
160
- volumes , err := p .addVolumesForAsyncStorage (podAdditions , & workspaceWithConfig .DevWorkspace )
160
+ volumes , err := p .addVolumesForAsyncStorage (podAdditions , & workspace .DevWorkspace )
161
161
if err != nil {
162
162
return err
163
163
}
164
164
165
165
sshSecretVolume := asyncstorage .GetVolumeFromSecret (secret )
166
- asyncSidecar := asyncstorage .GetAsyncSidecar (workspaceWithConfig .Status .DevWorkspaceId , sshSecretVolume .Name , volumes )
166
+ asyncSidecar := asyncstorage .GetAsyncSidecar (workspace .Status .DevWorkspaceId , sshSecretVolume .Name , volumes )
167
167
podAdditions .Containers = append (podAdditions .Containers , * asyncSidecar )
168
168
podAdditions .Volumes = append (podAdditions .Volumes , * sshSecretVolume )
169
169
170
170
return nil
171
171
}
172
172
173
- func (p * AsyncStorageProvisioner ) CleanupWorkspaceStorage (workspaceWithConfig * common.DevWorkspaceWithConfig , clusterAPI sync.ClusterAPI ) error {
173
+ func (p * AsyncStorageProvisioner ) CleanupWorkspaceStorage (workspace * common.DevWorkspaceWithConfig , clusterAPI sync.ClusterAPI ) error {
174
174
// TODO: This approach relies on there being a maximum of one workspace running per namespace.
175
- asyncDeploy , err := asyncstorage .GetWorkspaceSyncDeploymentCluster (workspaceWithConfig .Namespace , clusterAPI )
175
+ asyncDeploy , err := asyncstorage .GetWorkspaceSyncDeploymentCluster (workspace .Namespace , clusterAPI )
176
176
if err != nil {
177
177
if k8sErrors .IsNotFound (err ) {
178
- return runCommonPVCCleanupJob (workspaceWithConfig , clusterAPI )
178
+ return runCommonPVCCleanupJob (workspace , clusterAPI )
179
179
} else {
180
180
return err
181
181
}
182
182
}
183
183
184
184
// Check if another workspace is currently using the async server
185
- numWorkspaces , totalWorkspaces , err := p .getAsyncWorkspaceCount (workspaceWithConfig .Namespace , clusterAPI )
185
+ numWorkspaces , totalWorkspaces , err := p .getAsyncWorkspaceCount (workspace .Namespace , clusterAPI )
186
186
if err != nil {
187
187
return err
188
188
}
189
189
switch numWorkspaces {
190
190
case 0 :
191
191
// no problem
192
192
case 1 :
193
- if workspaceWithConfig .Spec .Started {
193
+ if workspace .Spec .Started {
194
194
// This is the only workspace using the async server, we can safely stop it
195
195
break
196
196
}
@@ -219,12 +219,12 @@ func (p *AsyncStorageProvisioner) CleanupWorkspaceStorage(workspaceWithConfig *c
219
219
}
220
220
221
221
// Clean up PVC using usual job
222
- err = runCommonPVCCleanupJob (workspaceWithConfig , clusterAPI )
222
+ err = runCommonPVCCleanupJob (workspace , clusterAPI )
223
223
if err != nil {
224
224
return err
225
225
}
226
226
227
- retry , err := asyncstorage .RemoveAuthorizedKeyFromConfigMap (& workspaceWithConfig .DevWorkspace , clusterAPI )
227
+ retry , err := asyncstorage .RemoveAuthorizedKeyFromConfigMap (& workspace .DevWorkspace , clusterAPI )
228
228
if err != nil {
229
229
return & ProvisioningError {
230
230
Message : "Failed to remove authorized key from async storage configmap" ,
0 commit comments