Proxy: Forward requests as partition and use it in standalone
The idea is to make it possible while embedding SlapOS in an existing partition to configure that some requests are forwarded to the master of the partition and to make these requests as the partition - so that when this partition is destroyed all other partitions from the embedded partitions are destroyed.
A bit more integration in slapos is still needed, but is intended to be used in theia (and why not webrunner):
At the beginning theia's instance looks like this:
after an ERP5 instance is requested in theia's embedded slapos, the partition requests are forwarded as this partition and appear here, as requested by theia:
This can also allow transparent integration, because the partition credentials are known by the partition, unlike the user credentials.
43 44 except ImportError: 44 45 import subprocess 45 46 47 try: 48 from typing import TYPE_CHECKING, Optional, Iterable, Dict, Union 49 if TYPE_CHECKING: 50 import subprocess 51 except ImportError: # XXX to be removed once we depend on typing I developed this on top of !217 , because I wanted to have typing support to make development easier. Instead of removing all type definitions, I made it try/except for python2 (but there's a typing egg for python2 and !217 includes a dependency to this egg) this way we can already use mypy if we want during development.
577 app.logger.debug("requesting from partition %s", master_entry) 578 # XXX ComputerPartition.request and OpenOrder.request have different signatures 579 partition = slap.registerComputerPartition( 580 master_entry['computer'], 581 master_entry['partition'], 582 ).request( 583 software_release=request_form['software_release'], 584 software_type=request_form.get('software_type', ''), 585 partition_reference=partition_reference, 586 shared=loads(request_form['shared_xml'].encode('utf-8')), 587 partition_parameter_kw=partition_parameter_kw, 588 filter_kw=filter_kw, 589 state=loads(request_form['state'].encode('utf-8')), 590 ) 591 else: 592 filter_kw['source_instance_id'] = partition_reference added 1 commit
- 9ba35df6 - slap/standalone: support setting multi-master in slapos.cfg
I understood the problem with
$SLAPGRID_INSTANCE_ROOT
in tests. It does not happen when we run only one test, it's an isolation problem.This is for something introduced in a403cff3 , when processing a partition, we set
os.environ['SLAPGRID_INSTANCE_ROOT']
but this is never unset and just leaked to all previous executions. One way could be to use a pattern like this:os.environ['SLAPGRID_INSTANCE_ROOT'] = self.instance_root try: ... finally: os.environ.pop('SLAPGRID_INSTANCE_ROOT', None)
I'm trying this first ...
I don't really understand this
$SLAPGRID_INSTANCE_ROOT
trick. I made bb888d99 to set a$SLAPGRID_INSTANCE_ROOT
in a context manager only for the time of installation of the partition - I guess this is the only time when this is needed.In 7e58516e @rafael introduced a
slapos node promise
and this command also set$SLAPGRID_INSTANCE_ROOT
when processing promises. I think it's not needed to set it here, so I unset it.Let's see if test is better like this (test always fail when I run locally), but @alain.takoudjou , @rafael I would appreciate if you can review this part.
Let's see if test is better like this (test always fail when I run locally), but @alain.takoudjou , @rafael I would appreciate if you can review this part.
please don't look in detail yet, the tests are showing errors. I'll remove WIP once it's OK
I gave up trying to refactor
$SLAPGRID_INSTANCE_ROOT
, it's too big, we should not address this as part of this MR. the easy way, just unset$SLAPGRID_INSTANCE_ROOT
in the test, like other tests are already doing. It's bad, but I think we should review this$SLAPGRID_INSTANCE_ROOT
implementation.Currently we just set
SLAPGRID_INSTANCE_ROOT
in environment and after this, every time that_updateTransactionFile
will be called after this it will create the transaction file. Because we call_updateTransactionFile
inComputerPartition.__init__
, onceSLAPGRID_INSTANCE_ROOT
was set, every time we instanciate aComputerPartition
it must create a transaction file.So I dropped the changes related to refactoring this.
Edited by Jérome Perrinenabled an automatic merge when the pipeline for 4825a8c4 succeeds
mentioned in commit e0b4339e
mentioned in merge request slapos!774 (merged)
mentioned in commit slapos@00fcd8ea