Commit 2fb0f661 authored by lukas.burgey's avatar lukas.burgey
Browse files

Implement removal of deployments prior to client deregister

Clients receive all remaining deployments when they deregister, so they can remove them.

This closes #73
parent c1649a00
Pipeline #121931 passed with stage
in 1 minute and 24 seconds
Subproject commit 9b1dafbaa21cb9af304e0dd2d6010a0432cf8958
Subproject commit 9b7f06ca60a364ef3c4d4da5fa6f727dffcf6af2
......@@ -130,10 +130,15 @@ class DeploymentStateSerializer(ModelSerializer):
read_only_fields = (
......@@ -170,29 +170,36 @@ class ConfigurationView(views.APIView):
class DeregisterView(views.APIView):
class DeregisterView(generics.ListAPIView):
authentication_classes = AUTHENTICATION_CLASSES
permission_classes = PERMISSION_CLASSES
serializer_class = clients.DeploymentStateSerializer
def put(self, request):
def get_queryset(self):
# the site where client is located
client_site = None
client_site =
client_site =
except Site.DoesNotExist:
raise ImproperlyConfigured('client has no site')
# deregister the client / its services / its site
# we expect all deployments at the clients to be removed (and therefore simply delete them all)'[DEREG] Client %s from site %s is deregistering', request.user, client_site)'[DEREG] Client %s from site %s is deregistering', self.request.user, client_site)
for service in'[DEREG] Triggering service removal %s', service)
response = 'Success deregistering'
return Response(response)
# the service removals usually cause a lot of deployments to be orphaned
# we return these to the client, so it can remove them
return [
for state in
if state.is_pending_for_restarting_client
......@@ -132,7 +132,7 @@ class ClientViewTest(TestCase):
self.assertEqual(response.status_code, 200)
def test_deregister(self):
response = self.client.put(
response = self.client.get(
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment