Commit Graph

449 Commits

Author SHA1 Message Date
Simone Gotti f812597410 runservice: maintenance/export/import
Implement runservice maintenance mode and export/import.

When runservice is set in maintenance mode it'll start only the maintenance and
export/import handlers.

Setting maintenance mode will set a key in etcd so all the runservice instances
will detect it and enter in maintenance mode. This is done asyncronously so it
could take some time (future improvements will add some api to show all the
runservice states)

Export is always available and will export the datamanager contents. Currently
only datamanager contents are exported (no logs and workspace archives).

Import is available only during maintenance, given a datamanager export will
import it and reset etcd to this import state.
2019-07-29 11:52:30 +02:00
Simone Gotti 1034b3afdb
Merge pull request #67 from sgotti/configstore_maintenance_export_import
configstore: maintenance/export/import
2019-07-29 11:11:02 +02:00
Simone Gotti fafa5188c2 configstore: maintenance/export/import
Implement configstore maintenance mode and export/import.

When configstore is set in maintenance mode it'll start only the maintenance and
export/import handlers.

Setting maintenance mode will set a key in etcd so all the configstore instances
will detect it and enter in maintenance mode. This is done asyncronously so it
could take some time (future improvements will add some api to show all the
configstore states)

Export is always available and will export the datamanager contents.

Import is available only during maintenance, given a datamanager export will
import it and reset etcd to this import state.
2019-07-26 10:55:04 +02:00
Simone Gotti f3fa229f6c util: add GoWait function
GoWait will increase the provided waitGroup on start and execute a goroutine
that will run the provided functions and then decrease the waitGroup
2019-07-26 10:55:04 +02:00
Simone Gotti e2526a6399
Merge pull request #66 from sgotti/util_backoff_use_context
util: use context in backoff
2019-07-26 10:54:54 +02:00
Simone Gotti bd035e9840 util: use context in backoff 2019-07-26 10:36:11 +02:00
Simone Gotti 335d1a2aad
Merge pull request #65 from sgotti/readdb_close_open_on_run
readdb: close and open readdb on Run
2019-07-26 10:18:29 +02:00
Simone Gotti ceafc2ef98 readdb: close and open readdb on Run 2019-07-25 17:59:54 +02:00
Simone Gotti d18c878d4d
Merge pull request #64 from sgotti/use_sleep_timers_loops
*: use sleep timer in loops
2019-07-25 17:56:46 +02:00
Simone Gotti 6f3798e8fe *: use sleep timer in loops
So we'll react instantly to a context cancel instead of waiting on time.Sleep
returning.
2019-07-25 16:22:54 +02:00
Simone Gotti 9481b8d67d
Merge pull request #62 from sgotti/db_use_context
db: use context functions
2019-07-25 16:22:10 +02:00
Simone Gotti b8c2b4020a db: use context functions
Use the go sql context functions (ExecContext, QueryContext etc...)

The context is saved inside Tx so the library users should only pass it one time
to the db.Do function.
2019-07-25 14:49:53 +02:00
Simone Gotti 5c87d89c72
Merge pull request #63 from sgotti/datamanager_export_import
datamanager: implement import/export
2019-07-25 14:49:16 +02:00
Simone Gotti 3404cb94b9 datamanager: implement import/export
* export: exports the newest data checkpoint. It forces a checkpoint before
exporting (currently no wals are exported)

* import: cleans up etcd, creates a new datasnaphot from the provided import stream
and then initializes etcd. Currently no old data is removed from the object
storage but it's just ignored.
2019-07-25 11:12:49 +02:00
Simone Gotti af4aa58903
Merge pull request #61 from sgotti/datamanager_maintenance_mode
datamanager: implement maintenance mode
2019-07-25 10:58:40 +02:00
Simone Gotti 3987caf664 datamanager: implement maintenance mode
when datamanager is started in maintenance mode no goroutines are scheduled and
no initial etcd initialization is done
2019-07-24 17:37:27 +02:00
Simone Gotti e0a6e78cf3
Merge pull request #60 from sgotti/go_mod_update_xerrors
go mod: update golang.org/x/xerrors
2019-07-24 17:00:34 +02:00
Simone Gotti 5a16b72adb
Merge pull request #59 from sgotti/db_retry_on_sqlite_locked_err
db: retry on sqlite locked error
2019-07-24 17:00:14 +02:00
Simone Gotti 2800f6cd6e go mod: update golang.org/x/xerrors 2019-07-24 15:23:33 +02:00
Simone Gotti 3297244d5d db: retry on sqlite locked error
Since we are using the shared cache with the lock notify we won't receive
SQLITE_BUSY errors but we could receive SQLITE_LOCKED errors due to deadlocks or
locked tables on concurrent read and write transactions.

This patch catches this kind of errors and retries the tx until maxTxRetries.
2019-07-24 12:20:33 +02:00
Simone Gotti 77ee8d9e7d
Merge pull request #58 from sgotti/readdb_fix_deadlock
readdb: fix deadlock in Run method
2019-07-23 15:47:05 +02:00
Simone Gotti 19706fe485
Merge pull request #57 from sgotti/runservice_stop_also_if_result_is_not_set
runservice: stop run also if result is not set
2019-07-23 15:09:58 +02:00
Simone Gotti 85876310af readdb: fix deadlock in Run method
In runservice readdb Run method we could end with a deadlock if two of the
goroutines that call HandleEvents.* try to write to the errCh at the same
time before the errCh is read. If this happens one of the two will be blocked on
writing to the channel but the read won't happen since it'll blocked by
wg.Wait().

Fix this doing:
* use a buffered channel large as the number of executed goroutines.
* create a new errCh at every loop (so we'll ignore later errors after the first
one)

Note: we could also use a non blocking send to avoid this situation but we
should also start the wg.Wait before the goroutines or earlier errors could be
lost causing another kind of hang.
2019-07-23 14:56:26 +02:00
Simone Gotti 75d68b2b52 runservice: stop run also if result is not set 2019-07-23 12:11:01 +02:00
Simone Gotti ea3e0d1d7c
Merge pull request #56 from sgotti/datamanager_multiple_improvements
datamanager: multiple improvements
2019-07-19 11:12:16 +02:00
Simone Gotti 3a963ef95f readdb: error if there's no wal in etcd 2019-07-18 16:44:28 +02:00
Simone Gotti 3f64bda0cc readdb: save walSequence provided by data file 2019-07-18 16:44:28 +02:00
Simone Gotti 16820e9033 readdb: insert current wal sequence after checking wal status 2019-07-18 16:44:28 +02:00
Simone Gotti f7175c4592 datamanager: save previous wal in waldata 2019-07-18 16:44:28 +02:00
Simone Gotti 18c5ae0492 datamanager: error if there're wals but not a datastatus in ost 2019-07-18 16:44:28 +02:00
Simone Gotti c034819087 datamanager: accept optional datastatus in initEtcd 2019-07-18 16:44:28 +02:00
Simone Gotti df716fccc6 datamanager: create a new wal and checkpoint in initEtcd
When doing an initEtcd (new instance or etcd reset) create a new wal (that will
have a new sequence epoch) and do a checkpoint.

In this way:

* readdb will detect that an epoch change and do a full resync
* we always have a data file (also if empty) that provides the last checkpointed
wal. This information could be used by readdb to resync
2019-07-18 16:44:28 +02:00
Simone Gotti cb2a871be6 datamanager: start initEtcd from last datastatus 2019-07-18 16:44:28 +02:00
Simone Gotti 445ef24daa datamanager: add option to force a checkpoint 2019-07-18 16:44:27 +02:00
Simone Gotti 512162bf98 datamanager: clean etcd data before reinitialization 2019-07-18 16:42:17 +02:00
Simone Gotti 8fbb9fdcbe datamanager: add deleteEtcd method 2019-07-18 16:40:28 +02:00
Simone Gotti 21964f90fd etcd: add DeletePrefix method 2019-07-18 16:40:28 +02:00
Simone Gotti 1927a17857
Merge pull request #52 from sgotti/readme_add_features
README: Add "features" and "documentation" sections
2019-07-15 17:31:55 +02:00
Simone Gotti e3e9e162cd README: Add "features" and "documentation" sections 2019-07-15 17:18:09 +02:00
Simone Gotti 44adad61a4 README: add link to agola introduction post 2019-07-15 00:15:40 +02:00
Simone Gotti 94462e6ee4 README: add screenshot 2019-07-14 18:15:00 +02:00
Simone Gotti 86d822a247 service: handle cors config and use it only on gateway
* Don't make cors enabled on all (*) by default.
* Handle related web.allowedOrigins options
* Only the gateway api should be called by a browser so setup the cors handler
only on it
2019-07-13 23:15:00 +02:00
Simone Gotti 5483620fb0 gateway: return project if the project is public
If the project is public don't require the user to be logged in to show the
project.
2019-07-12 23:41:34 +02:00
Simone Gotti f61a6068c2 cmd/serve: don't make --config required 2019-07-12 17:26:00 +02:00
Simone Gotti 973c72976c README: add contacts and contributing info 2019-07-12 10:13:53 +02:00
Simone Gotti cf0b7f8ded add initial integration tests 2019-05-29 13:35:20 +02:00
Simone Gotti b80710e2f0 k8s driver: start goroutines after setup 2019-07-10 21:55:26 +02:00
Simone Gotti 940264e413 runservice: add lock around compatchangegroups
just to avoid concurrency errors when multiple instances are running
2019-07-10 10:20:35 +02:00
Simone Gotti c064e490b2 datamanager: add lock around compatchangegroups and initetcd
just to avoid concurrency errors when multiple instances are running
2019-07-10 10:20:03 +02:00
Simone Gotti 276c045c3b configstore: add parenttype to related tables
Add the parenttype column to project, projectgroup, secret, variable tables.
2019-07-09 10:16:45 +02:00