Repository navigation
cleaning up workspace on failure - #362
tinakurian merged 1 commit into
Conversation
75d344b to
88582fb
Compare
|
/test v5-devworkspaces-operator-e2e |
559bb1e to
78f1963
Compare
|
/test v5-devworkspaces-operator-e2e |
78f1963 to
2d78ec0
Compare
|
/test v5-devworkspaces-operator-e2e |
sleshchenko
left a comment
There was a problem hiding this comment.
Be in rush with merging this and make @amisevsk in charge of adapting his PR :-D
| replicaCount := int32(0) | ||
| clusterDeployment.Spec.Replicas = &replicaCount | ||
|
|
||
| err = client.Update(ctx, clusterDeployment) |
There was a problem hiding this comment.
I wonder if we can send patch instead of update.
not sure if it's available with that client, just idea.
There was a problem hiding this comment.
I should be available
// ScaleDeploymentToZero scales the cluster deployment to zero
func ScaleDeploymentToZero(ctx context.Context, workspace *devworkspace.DevWorkspace, client runtimeClient.Client) error {
patch := []byte(`{"spec":{"replicas": 0}}`)
err := client.Patch(context.Background(), &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: workspace.Namespace,
Name: common.DeploymentName(workspace.Status.WorkspaceId),
},
}, runtimeClient.RawPatch(types.StrategicMergePatchType, patch))
if err != nil {
return err
}
return nil
}
@amisevsk WDYT about patching here?
There was a problem hiding this comment.
I've never been able to figure out the semantics of patch; sometimes it does what I expect other times it does not 😄
There was a problem hiding this comment.
I've updated to use the patch!
2d78ec0 to
bfb8062
Compare
|
/test v5-devworkspaces-operator-e2e |
amisevsk
left a comment
There was a problem hiding this comment.
Merge away -- I can copy the
err := provision.ScaleDeploymentToZero(workspace, r.Client)
if err != nil {
return reconcile.Result{}, err
}lines into my PR when I rebase.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amisevsk, JPinkney, sleshchenko, tinakurian The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What does this PR do?
Cleans up cluster deployments by scaling them to 0.
What issues does this PR fix or reference?
#338
Is it tested? How?
The result:
