I’ve just run into a strange error trying to run tests immediately after spinning up a Couchbase Server container. This is how I initialize it:
podman run -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11210:11210 -p 11280:11280 --name couchbase couchbase:7.2.3
if ! podman exec couchbase curl http://127.0.0.1:8091/pools -s --retry 15 --retry-all-errors > /dev/null; then
podman container rm -f couchbase
exit 1
fi
podman exec couchbase \
couchbase-cli cluster-init -c 127.0.0.1 \
--cluster-username Administrator \
--cluster-password password \
--cluster-ramsize 2048 \
--services data,index,query,backup
podman exec couchbase \
couchbase-cli bucket-create -c 127.0.0.1 -u Administrator -p password \
--bucket default \
--bucket-type couchbase \
--bucket-replica 0 \
--bucket-ramsize 2048 \
--compression-mode active
I then call waitUntilReady()
like so (pretty sure the defaultBucket
one is redundant):
private Cluster cluster;
private Bucket defaultBucket;
public Couchbase(String connectionString, String username, String password) {
var timeout = Duration.ofSeconds(10);
var options = ClusterOptions.clusterOptions(username, password)
.environment(environment -> environment.compressionConfig(config -> config.enable(true))
.loggerConfig(config -> config.enableDiagnosticContext(false))
.loggingMeterConfig(config -> config.enabled(false)));
cluster = Cluster.connect(connectionString, options);
cluster.waitUntilReady(timeout);
defaultBucket = cluster.bucket("default");
defaultBucket.waitUntilReady(timeout);
}
…and get this at the first cluster.query()
:
com.couchbase.client.core.error.ServiceNotAvailableException: The query service is not available in the cluster. {“completed”:true,“coreId”:“0xa951e6df00000001”,“idempotent”:false,“requestId”:13,“requestType”:“QueryRequest”,“retried”:0,“service”:{“operationId”:“null”,“statement”:“CREATE SCOPE default.
videoland
\n”,“type”:“query”},“timeoutMs”:75000,“timings”:{“totalMicros”:7183}}
Same thing happens when I set the second parameter so as to exclude the services I don’t use:
var waitOptions = WaitUntilReadyOptions.waitUntilReadyOptions()
.serviceTypes(ServiceType.KV, ServiceType.QUERY)
.desiredState(ClusterState.ONLINE);
Is there another curl --retry
that I could add to my init script to actually wait for the services to be ready?