Closed davigar15 closed 4 years ago
There's not enough in the traceback to help diagnose the issue. Can you provide the args to the API call; was there an error logged server side; what was the actual content of the error raised client side etc. I assume the same deployment can be done via the CLI?
Hello @wallyworld, sorry, I will send you more information about the issue.
I've just discovered that this only happens when a a bundle with an application using storage is used. If I deploy an standalone k8s charm using storage, it works fine.
Also, if you do the same with juju cli, instead of libjuju, it will work. This only affects libjuju.
I'm adding the steps to reproduce the error:
sudo snap install juju --classic
sudo snap install mcirok8s --classic --channel 1.14/stbale
sudo usermod -a -G microk8s $USER
newgrp microk8s
microk8s.status --wait-ready
microk8s.enable storage dns
juju bootstrap microk8s
juju add-model testing
description: K8s bundle with Redis
bundle: kubernetes
applications:
prometheus-k8s:
charm: 'cs:~charmed-osm/prometheus-k8s'
scale: 1
series: kubernetes
storage:
database: 100M
from juju import loop
from juju.model import Model
from pathlib import Path
import logging
import pdb
async def main(): model = Model() await model.connect() application = await model.deploy(str('local:' / Path(file).absolute().parent / "bundle") ) pdb.set_trace() await model.disconnect()
if name == 'main': logging.basicConfig(level=logging.DEBUG) ws_logger = logging.getLogger('websockets.protocol') ws_logger.setLevel(logging.INFO) loop.run(main())
**Complete log:**
(venv) davigar15@Canonical:~/code/python-libjuju$ python3 examples/deploy_k8s_storage.py
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:juju.client.connection:Driver connected to juju wss://10.152.183.114:17070/model/daf66827-273a-4c20-8302-23a4c550b234/api
DEBUG:juju.client.connection:connection 140377524379944 -> {
"type": "Admin",
"request": "Login",
"version": 3,
"params": {
"auth-tag": "user-admin",
"credentials": "c73fdec25704b4c0c23da2260bcc4d14"
},
"request-id": 1
}
DEBUG:juju.client.connection:connection 140377524379944 <- {'request-id': 1, 'response': {'servers': [[{'value': '10.152.183.114', 'type': 'ipv4', 'scope': 'local-cloud', 'port': 17070}]], 'model-tag': 'model-daf66827-273a-4c20-8302-23a4c550b234', 'controller-tag': 'controller-0a672e62-9e0f-43a2-82dd-b4aced4b0080', 'user-info': {'display-name': '', 'identity': 'user-admin', 'controller-access': 'superuser', 'model-access': 'admin'}, 'facades': [{'name': 'Action', 'versions': [2, 3]}, {'name': 'ActionPruner', 'versions': [1]}, {'name': 'Agent', 'versions': [2]}, {'name': 'AgentTools', 'versions': [1]}, {'name': 'AllWatcher', 'versions': [1]}, {'name': 'Annotations', 'versions': [2]}, {'name': 'Application', 'versions': [1, 2, 3, 4, 5, 6, 7, 8, 9]}, {'name': 'ApplicationScaler', 'versions': [1]}, {'name': 'Backups', 'versions': [1, 2]}, {'name': 'Block', 'versions': [2]}, {'name': 'Bundle', 'versions': [1, 2, 3]}, {'name': 'CAASAgent', 'versions': [1]}, {'name': 'CAASFirewaller', 'versions': [1]}, {'name': 'CAASOperator', 'versions': [1]}, {'name': 'CAASOperatorProvisioner', 'versions': [1]}, {'name': 'CAASOperatorUpgrader', 'versions': [1]}, {'name': 'CAASUnitProvisioner', 'versions': [1]}, {'name': 'CharmRevisionUpdater', 'versions': [2]}, {'name': 'Charms', 'versions': [2]}, {'name': 'Cleaner', 'versions': [2]}, {'name': 'Client', 'versions': [1, 2]}, {'name': 'CredentialManager', 'versions': [1]}, {'name': 'CredentialValidator', 'versions': [1, 2]}, {'name': 'CrossModelRelations', 'versions': [1]}, {'name': 'Deployer', 'versions': [1]}, {'name': 'DiskManager', 'versions': [2]}, {'name': 'EntityWatcher', 'versions': [2]}, {'name': 'ExternalControllerUpdater', 'versions': [1]}, {'name': 'FanConfigurer', 'versions': [1]}, {'name': 'FilesystemAttachmentsWatcher', 'versions': [2]}, {'name': 'FirewallRules', 'versions': [1]}, {'name': 'Firewaller', 'versions': [3, 4, 5]}, {'name': 'HighAvailability', 'versions': [2]}, {'name': 'HostKeyReporter', 'versions': [1]}, {'name': 'ImageManager', 'versions': [2]}, {'name': 'ImageMetadata', 'versions': [3]}, {'name': 'InstanceMutater', 'versions': [1, 2]}, {'name': 'InstancePoller', 'versions': [3]}, {'name': 'KeyManager', 'versions': [1]}, {'name': 'KeyUpdater', 'versions': [1]}, {'name': 'LeadershipService', 'versions': [2]}, {'name': 'LifeFlag', 'versions': [1]}, {'name': 'LogForwarding', 'versions': [1]}, {'name': 'Logger', 'versions': [1]}, {'name': 'MachineActions', 'versions': [1]}, {'name': 'MachineManager', 'versions': [2, 3, 4, 5, 6]}, {'name': 'MachineUndertaker', 'versions': [1]}, {'name': 'Machiner', 'versions': [1]}, {'name': 'MeterStatus', 'versions': [1]}, {'name': 'MetricsAdder', 'versions': [2]}, {'name': 'MetricsDebug', 'versions': [2]}, {'name': 'MetricsManager', 'versions': [1]}, {'name': 'MigrationFlag', 'versions': [1]}, {'name': 'MigrationMaster', 'versions': [1]}, {'name': 'MigrationMinion', 'versions': [1]}, {'name': 'MigrationStatusWatcher', 'versions': [1]}, {'name': 'ModelConfig', 'versions': [1, 2]}, {'name': 'ModelGeneration', 'versions': [1, 2]}, {'name': 'ModelUpgrader', 'versions': [1]}, {'name': 'NotifyWatcher', 'versions': [1]}, {'name': 'OfferStatusWatcher', 'versions': [1]}, {'name': 'Payloads', 'versions': [1]}, {'name': 'PayloadsHookContext', 'versions': [1]}, {'name': 'Pinger', 'versions': [1]}, {'name': 'Provisioner', 'versions': [3, 4, 5, 6, 7, 8, 9]}, {'name': 'ProxyUpdater', 'versions': [1, 2]}, {'name': 'Reboot', 'versions': [2]}, {'name': 'RelationStatusWatcher', 'versions': [1]}, {'name': 'RelationUnitsWatcher', 'versions': [1]}, {'name': 'RemoteRelations', 'versions': [1]}, {'name': 'Resources', 'versions': [1]}, {'name': 'ResourcesHookContext', 'versions': [1]}, {'name': 'Resumer', 'versions': [2]}, {'name': 'RetryStrategy', 'versions': [1]}, {'name': 'SSHClient', 'versions': [1, 2]}, {'name': 'Singular', 'versions': [2]}, {'name': 'Spaces', 'versions': [2, 3]}, {'name': 'StatusHistory', 'versions': [2]}, {'name': 'Storage', 'versions': [3, 4, 5, 6]}, {'name': 'StorageProvisioner', 'versions': [3, 4]}, {'name': 'StringsWatcher', 'versions': [1]}, {'name': 'Subnets', 'versions': [2]}, {'name': 'Undertaker', 'versions': [1]}, {'name': 'UnitAssigner', 'versions': [1]}, {'name': 'Uniter', 'versions': [4, 5, 6, 7, 8, 9, 10, 11, 12]}, {'name': 'UpgradeSeries', 'versions': [1]}, {'name': 'UpgradeSteps', 'versions': [1]}, {'name': 'Upgrader', 'versions': [1]}, {'name': 'VolumeAttachmentPlansWatcher', 'versions': [1]}, {'name': 'VolumeAttachmentsWatcher', 'versions': [2]}], 'server-version': '2.6.10'}}
DEBUG:juju.model:Starting watcher task
DEBUG:juju.client.connection:connection 140377524379944 -> {
"type": "Pinger",
"request": "Ping",
"version": 1,
"params": {},
"request-id": 2
}
DEBUG:juju.client.connection:connection 140377524379944 -> {
"type": "Client",
"request": "WatchAll",
"version": 2,
"params": {},
"request-id": 3
}
DEBUG:juju.client.connection:connection 140377524379944 <- {'request-id': 2, 'response': {}}
DEBUG:juju.client.connection:connection 140377524379944 <- {'request-id': 3, 'response': {'watcher-id': '1'}}
DEBUG:juju.client.connection:connection 140377524379944 -> {
"type": "AllWatcher",
"request": "Next",
"version": 1,
"params": {},
"Id": "1",
"request-id": 4
}
DEBUG:juju.client.connection:connection 140377524379944 <- {'request-id': 4, 'response': {'deltas': []}}
DEBUG:juju.client.connection:connection 140377524379944 -> {
"type": "Client",
"request": "ModelInfo",
"version": 2,
"params": {},
"request-id": 5
}
DEBUG:juju.client.connection:connection 140377524379944 -> {
"type": "AllWatcher",
"request": "Next",
"version": 1,
"params": {},
"Id": "1",
"request-id": 6
}
DEBUG:juju.client.connection:connection 140377524379944 <- {'request-id': 5, 'response': {'name': 'testing', 'type': 'caas', 'uuid': 'daf66827-273a-4c20-8302-23a4c550b234', 'controller-uuid': 'controller-0a672e62-9e0f-43a2-82dd-b4aced4b0080', 'is-controller': False, 'provider-type': 'kubernetes', 'default-series': 'bionic', 'cloud-tag': 'cloud-microk8s', 'cloud-region': 'localhost', 'cloud-credential-tag': 'cloudcred-microk8s_admin_microk8s', 'owner-tag': 'user-admin', 'life': 'alive', 'status': {'status': '', 'info': '', 'since': None}, 'users': None, 'machines': None, 'sla': {'level': 'unsupported', 'owner': ''}, 'agent-version': '2.6.10'}}
DEBUG:juju.model:Got ModelInfo: {'agent_version':
I think this issue is because libjuju
doesn't pre-process the constrains string like Juju CLI does before adding the contraints to the API payload.
It's not CaaS
related.
To fix it, change the bundle to
description: K8s bundle with Redis
bundle: kubernetes
applications:
prometheus-k8s:
charm: 'cs:~charmed-osm/prometheus-k8s'
scale: 1
series: kubernetes
storage:
database:
size: 100
@ycliuhw Thanks a lot for the response. I'm glad that's something easy to fix.
But I'm getting this error when using your bundle. Any ideas?
DEBUG:juju.client.connection:connection 140030016311080 <- {'request-id': 8, 'error': 'cannot read bundle YAML: cannot unmarshal bundle data: yaml: unmarshal errors:\n line 7: cannot unmarshal !!map into string', 'response': {}}
Traceback (most recent call last):
File "examples/deploy_k8s_storage.py", line 19, in <module>
loop.run(main())
File "/home/davigar15/code/python-libjuju/juju/loop.py", line 38, in run
raise task.exception()
File "examples/deploy_k8s_storage.py", line 10, in main
application = await model.deploy(str('local:' / Path(__file__).absolute().parent / "bundle2") )
File "/home/davigar15/code/python-libjuju/juju/model.py", line 1374, in deploy
await handler.fetch_plan(entity_id)
File "/home/davigar15/code/python-libjuju/juju/bundle.py", line 140, in fetch_plan
yaml=yaml.dump(self.bundle))
File "/home/davigar15/code/python-libjuju/juju/client/facade.py", line 472, in wrapper
reply = await f(*args, **kwargs)
File "/home/davigar15/code/python-libjuju/juju/client/_client3.py", line 1314, in GetChanges
reply = await self.rpc(msg)
File "/home/davigar15/code/python-libjuju/juju/client/facade.py", line 608, in rpc
result = await self.connection.rpc(msg, encoder=TypeEncoder)
File "/home/davigar15/code/python-libjuju/juju/client/connection.py", line 455, in rpc
raise errors.JujuAPIError(result)
juju.errors.JujuAPIError: cannot read bundle YAML: cannot unmarshal bundle data: yaml: unmarshal errors:
line 7: cannot unmarshal !!map into string
And also, one more question. Is there any way to make a bundle compatible with the juju client and libjuju?
Thanks a lot!
I'm deploying that bundle you said with the juju client, the following error happens too:
juju.errors.JujuAPIError: cannot read bundle YAML: cannot unmarshal bundle data: yaml: unmarshal errors:
line 7: cannot unmarshal !!map into string
My impression is that the juju api-server expects something like this:
storage:
database: 100M
And the libjuju expects:
storage:
database:
size: 100
Also, this only affects to the bundles. With the applications, something like this works:
application = await model.deploy(
'cs:~charmed-osm/prometheus-k8s',
application_name='prometheus',
series='kubernetes',
channel='stable',
storage={
'database': {
'size': 100
}
}
)
Hi @davigar15 This is a known gap in libjuju(it doesn't preprocess the constraint strings before calling the facade), we will fix it.
Everytime I deploy an application with storage with libjuju, I'm getting this error: