Commit Graph

196 Commits

Author SHA1 Message Date
Alan Baghumian 59efce8bc8 Restore original paste files if glance-common
re-installation does not restore them.

Implemented a unit test function for the above
scenario.

Call apt_update from upgrade_charm().

Closes-Bug: #2042792

Change-Id: I57c5fa293b421483b0879f24ddac260e47c7cbef
2023-11-08 16:45:21 -08:00
Alex Kavanagh ad0097b5e6 Improve platform mocking
Patch out charmhelpers.osplatform.get_platform() and
charmhelpers.core.host.lsb_release() globally in the unit tests to
insulate the unit tests from the platform that the unit tests are being
run on.

Change-Id: I7b0d02c915e2f7ae1d6d86cd829895530643de45
2023-10-24 20:04:08 +01:00
Rafael Lopez 0a1d645000 Add configuration option for custom image properties
Added configuration for injecting default image properties using the
interoperable image import process. This change adds 1 configuration
option to the charm:
- 'custom-import-properties' to specify the desired custom properties

Note: current glance docs example shows incorrect quoting, the
implemented format in this change (no quotes) is correct. Docs fix
in: https://review.opendev.org/c/openstack/glance/+/890423

Release note: https://review.opendev.org/c/openstack/charm-guide/+/891010

Closes-Bug: 1994053
Related-Bug: 2028895
Change-Id: I9548c90e663285c6e7a70eebc8c135a5568974bc
2023-08-10 04:47:17 +00:00
Guillaume Boutry ef5d6de615
Backup glance registry configuration files on upgrade >= Stein
Glance Registry has been deprecated in Stein release.
Leftover configuration files can still be read and
configure wrong settings, breaking deployment.

Closes-Bug: 1979090
Change-Id: I54b72aef0fd49b036cf1783ef9887fa9243c93f8
2023-02-14 08:09:23 +01:00
Gabriel Cocenza 96a2bb3af9 Add support for HAProxy L7 checks
This change add several configuration options to enable HTTP checks
to the HAProxy configuration, instead of the default TCP connection
checks (which continue to be the default)

Closes-Bug: #1880610
Change-Id: I81d7fd67029dd5025f95b41d788b03ce4b6038bb
2023-01-17 18:06:05 -03:00
Hemanth Nakkina c2f877a7d4 Add support for cinder storage backend
Create new glance_api.conf template from Ussuri release to
use default_backend and enabled_backends configuration
parameters instead of deprecated stores, default_store
parameters.
Add new config option cinder-volume-types to specify the
volume types in cinder that can be used to store glance
images.
Add logic to update cinder in glance-api configurations
if cinder-volume-service relation is joined.

Also add two flags, cinder_http_retries and
cinder_state_transition_timeout

Closes-Bug: #1905042
Change-Id: Ife649defc9b765b433d7973ab31778f9cb1efdd9
2022-02-07 08:46:14 +05:30
Hervé Beraud 4c7ebb7cf9 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: I3286f03d977e6f602f0f50dac0646534d1d6f305
2021-12-15 10:22:40 +00:00
Nobuto Murata cacc3d5a5b Disable expose_image_locations whenever S3 is enabled
This is a follow-up change on Id2e9d4351513341b5ee41fa8a8d677aca6580fca
Instead of relying users to set expose-image-locations=false which is
error prone, disable expose_image_locations from the charm side whenever
S3 backend is enabled not to expose credentials.

Closes-Bug: 1935743
Change-Id: Iac0f27418eec6c818df8cc3fa1c133db38d26069
2021-09-22 22:09:37 +09:00
Nobuto Murata a6dc972b09 Allow enabling S3 object storage backend
S3 backend has been available (again) since Ussuri in the upstream
Glance. We will enable the backend with config options for an external
S3 storage information.

Co-authored-by: Connor Chamberlain <connor.chamberlain@canonical.com>
Co-authored-by: Vladimir Grevtsev <vladimir.grevtsev@canonical.com>
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/574
Closes-Bug: #1919338
Change-Id: Id76a74cc6041b9c3364399254681138475f19935
2021-06-10 21:26:14 +09:00
Ionut Balutoiu 7a69693752 Fix race condition with the object-store relation
The `CONFIGS.write(GLANCE_SWIFT_CONF)` is missing in the object-store
hook. This config file is used when the `swift` backend is enabled.

This bug is only encountered on some deployments, because there are multiple
places where `CONFIGS.write_all()` is called.

If the `object-store` relation is established, and another hook calls
`CONFIGS.write_all()`, this problem wouldn't reproduce. However, if
`object-store` relation is executed last, this issue will pop up.

Closes-Bug: #1915300
Change-Id: Ie52b18fc4dc637dbeec5ecfb8d5930a24c5f72cf
2021-03-19 22:58:47 +00:00
Liam Young 6c6d491280 Waiting state if broker request is incomplete
When assessing the charms status check that the current
ceph broker request has been complete. If it has not
put the charm in a 'waiting' state and update the status
message.

Change-Id: I779b6933242ce88cb1577ae11ca258b96ec46b38
Closes-Bug: #1899918
2020-10-15 14:34:57 +00:00
Liam Young bc273a59e1 Send application name to ceph-mon
Send application name to ceph-mon as ceph-mon cannot derive it from
CMR relations.

Change-Id: I2bd1062b6aa05eab4eb3bd8d602a2d02f085f531
2020-10-01 10:32:35 +00:00
Zuul 6e667242aa Merge "Add multi backend support" 2020-09-24 10:58:09 +00:00
Frode Nordahl 8f3dfb184b
Add Ceph BlueStore Compression support
Func-Test-Pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/398
Change-Id: I997bb15c692c442db2db79d96882a2204186dbe1
2020-09-15 08:35:43 +02:00
Gabriel Adrian Samfira be8c4e00a9 Add multi backend support
Adds multi-backend support to Glance. Currently supported backends
are local, Swift and RBD. The order of preference for default backend
is RBD --> Swift --> Local. Backend can be selected explicitly by the
operator when creating an image.

Change-Id: I78ecad0e8e12fc1ff7d716b7e43d84ca4d5b0ee1
2020-09-14 22:19:22 +00:00
Frode Nordahl 65d66ecb58
Unpin flake8, fix lint
Change-Id: Id899936da7721fcc359e63db455a5349603fe559
2020-08-28 16:11:18 +02:00
James Page ed8bdede6f Add support for erasure coded ceph pools
Add standard configuration options for erasure coded pool
creation and profile configuration.

Update ceph relation joined handled to support erasure
coded pools - a replicated pool is created at 1% of the
total data weight alongside the erasure coding profile and
supporting erasure coded data pool.

Update ceph context to use the metadata pool name in the
glance configuration files when erasure-coded pool-type
is configured.

Resync charmhelpers to update Ceph Broker request support
for erasure coding.

Change-Id: If4a31a2adf8080af66885adb970fbb3cdd82f573
Depends-On: Iec4de19f7b39f0b08158d96c5cc1561b40aefa10
2020-08-07 10:41:40 +01:00
Liam Young 1433f32c3a Make the rbd pool name configurable
Allow the rbd pool name to be set via config. This brings glance
inline with other openstack ceph clients such as cinder.

Change-Id: I93b28c1b1276cca73348fd421024ef3ce0241258
2020-07-11 07:49:32 +00:00
Alex Kavanagh 848eb535a4 Remove policy.json from charm for ussuri
Glance (in ussuri) uses policy-in-code, and so that policy.json file
doesn't ship with the package.  This means that the charm can't rely on
the file existing ussuri onwards.  This patchset changes the way the
charm uses policy.json by switching it to a charm determined policy.yaml
file (preferred format) with the only 3 options that the charm
determines to enforce.

Also add yaml vars to focal-ussuri bundle

This brings it into line with the other charms that are part of the the
enable-focal topic.  This makes it easier to add a new bundle just by
changing a couple of variables.

Closes-Bug: #1872996
Change-Id: I47f19272a4e0af3781843608b76304ce8ba1e2b8
2020-04-23 16:17:35 +01:00
Corey Bryant a0f5d548f8 Add minimal policy.json template for Ussuri
As of OpenStack Ussuri, Glance has removed policy.json in favor
of using default policy in code. In order to continue supporting
the restrict-image-location-operations config option, a minimal
policy.json template is rendered for Ussuri and above. This allows
update_image_location_policy() to continue making modifications
to get_image_location, set_image_location, and delete_image_location
policy.

Change-Id: I7e3693ffda01d6a6269e771ecfd232ad2c87ce74
2020-04-01 21:16:38 +00:00
Zuul e54ed63e59 Merge "Disable Apache port 80" 2020-01-31 15:49:43 +00:00
Liam Young 3cdd235144 Do not access DB when it is in maintenance mode.
If the database is in maintenace mode do not attempt to access
it.

Depends-On: I5d8ed7d3935db5568c50f8d585e37a4d0cc6914f
Change-Id: I9550452e78608589592265fca9549a51c88d65bc
2020-01-30 12:38:03 +00:00
tpsilva 8eb305f3f1 Disable Apache port 80
Currently, Apache ports.conf file is not being configured by this
charm. This patch changes the ports.conf default file with another one
that does not open port 80 on SSL environments.

Change-Id: I3f8eb69813058a9291540634ad262bfdaa7b8731
Closes-bug: #1845665
2020-01-28 14:53:01 +00:00
Liam Young 9d60f159e7 When resuming, exclude haproxy
When resuming services exclude those managed by hacluster, in
this case haproxy. If pacemaker lacks quorum it may shut haproxy
down which will cause this charm to error.

Charmhelper sync included to bring in required
get_managed_services_and_ports method.

Change-Id: I9ede7d45e1d4da457d2228caf0367bf374bd51ea
2020-01-25 07:40:22 +00:00
Liam Young fcde1b022b Only run db migration once
This change follows the existing pattern that the keystone charm uses to only
run db migration once. To ensure it only runs once a flag is placed in the
leader db once it has run.

Change-Id: Iaba10cc70f60faa33e00cc5d33e03626f54374f9
2020-01-16 17:51:18 +00:00
Tiago Pasqualini da Silva bcadb3f450 Revert "Disable Apache default ports"
This reverts commit dcd9a269dc.

Change-Id: I842a67a7e167036ddd7fd529b35ef5d5c03f7c53
2019-12-20 02:05:33 +00:00
tpsilva dcd9a269dc Disable Apache default ports
Openstack services don't use the default ports (80 and 443), so
change Apache to not open them.

Change-Id: I543e3309c5522d7bc865133f8ec5ecc79542112c
Closes-bug: #1845665
2019-11-27 12:51:50 +00:00
Alex Kavanagh 97152f55a1 Policyd override implementation
This patchset implements policy overrides for glance.  It uses the
code in charmhelpers.

Change-Id: I0586326ff87fdf03f2c88e4c459627f4085c3367
Closed-Bug: #1741723
2019-10-07 22:04:00 +01:00
Edward Hope-Morley 160e5d2d9f Ensure glance-registry-paste.ini exists for <= Q
Change-Id: I84360db1522b735a20f4141235b111700935fe58
Closes-Bug: #1812972
2019-05-14 11:28:39 +01:00
Liam Young c9f44a7cec Check Apache ssl dir when determining restart map
If the certificates that Apache is using change then services needs
to be restarted. This change adds the SSL directory to the restart
map to ensure any certificate changes trigger a restart.

Change-Id: Idbdceb5acd80c06a2bde02f9df88a9d9fd2404fb
Closes-Bug: 1828530
2019-05-10 12:48:01 +00:00
Frode Nordahl 37bb5bf8f6
Request appropriate Ceph application name for pools created
Change-Id: I66c7ff150df936a765d753ba0c8eb93631a8da23
2019-03-13 16:13:47 +01:00
Corey Bryant 3d566f7762 Drop glance-registry from restart_map as of stein
This aligns with upstream's removal of glance-registry in the
stein release.

Change-Id: Ie6d618582cd5063738a965d36e7d766633e1a607
2019-02-26 11:18:50 +00:00
Andre Ruiz 6e6b492485 Implement new option: filesystem-store-datadir
This change implements a new option in config.yaml that can be used
to change the location of the images store on the filesystem.

Change-Id: I0d8e7409b8eb4e5e403455db03d73020f741afc4
Closes-Bug: #1657165
2019-02-21 09:41:06 -03:00
James Page c24e2cf423 upgrade: preserve glance-registry for Queens
The glance-registry daemon was deprecated at Queens, but was still
installed for the Queens charm release; ensure that any re-install
of paste.ini files accomodates this as part of the charm upgrade
process, resolving issues with glance-registry not running due to
missing paste configuration files.

Change-Id: Iaaea4907ce4ef9d1e17b8ef9719e8bb0e0001946
Closes-Bug: 1812972
2019-01-23 16:59:28 +00:00
Przemysław Hausman 046f20f3bc Add support for image_size_cap in charm config
Glance supports image_size_cap setting. This setting controls maximum
size of image a user can upload. An image upload greater than the size
mentioned here would result in an image creation failure.

This commit adds support for setting image_size_cap parameter in charm
config. It can be manipulated during the runtime with `juju config'
command.

Change-Id: I0af1c6a503a87941b7c8ee34255583652e54f0cc
Closes-Bug: #1720040
2018-12-11 23:04:16 +01:00
Liam Young 730fdf716c Use chelper generate_ha_relation_data for ha rel
Use the generate_ha_relation_data helper from charmhelpers to
generate the data to send down the relation to the hacluster
charm.

This results in a few changes in behaviour:

1) The charm will no longer specify a nic name to bind the vip. This
   is because Pacemaker VIP resources are able to automatically
   detect and configure correct iface and netmask parameters based
   on local configuration of the unit.
2) The original iface named VIP resource will be stopped and deleted
   prior to the creation of the new short hash named VIP resource.

Change-Id: I0ab095fdcb42dbfd2c64595e7390130500600190
2018-12-04 18:28:11 +00:00
Liam Young 9ddaa45565 Purge old packages on upgrade-charm
On charm upgrade the charm may switch to py3 packages. If so, ensure
the old py2 packages are purged. If the purge occurs then restore
the glance-api-paste.ini from packages and restart services.

Closes-Bug: 1803451
Change-Id: Ib258873fb2be95821e8f8c22fd1f3d19666b3181
2018-11-15 11:03:14 +00:00
Ryan Beisner 59359df933
Fix lint in unit test
Change-Id: Ia7a49ecdec95cc64ac82d85ae530d6dbde63aa26
2018-11-01 14:55:23 -05:00
James Page 6001f58a48 py3: Switch to using Python 3 for rocky or later
Switch package install to Python 3 for OpenStack Rocky or later.

When upgrading, remove any python-* packages that where explicitly
installed and then autoremove --purge any dependencies that are
no longer required.

Tidy install on ceph relation joined - python-ceph is a dependency
of ceph-common, so no need to explicitly install.

Change-Id: I7b66bb3ab9f9130c9054411819d51434480cac97
2018-09-21 16:28:48 +02:00
Edward Hope-Morley 9e2af26b6d Make image location ops policy configurable
Some users may not want *_image_location operations to be
restricted to role:admin so this patch allows that to be
configurable and sets the default to be False since
enabling this by default is breaking RBD COW clones in
Nova for non-admin users (and anywhere else that relies
on that information).

Change-Id: I8c293d6036bc1d6104dab5458f6915968459a09e
Closes-Bug: #1786144
2018-08-31 15:44:00 +01:00
Liam Young 19aaffaa81 Update to run under Python 3
Updating charm to support execution under Python 3.

Change-Id: I1429d1c6b634959e0062a8e9f4bc615c58bf31e0
2018-08-01 14:11:56 +02:00
Liam Young 8a301c8fd4 Add support for tls-certificates relation
Add support for the charm to request and receive certificates from
the tls-certificates relation.

Change-Id: Ifb1c45c8a5e59fcadd320d81ff30c062e26fd5c4
2018-05-15 14:49:34 +00:00
David Ames b45cd2ae74 Enable Bionic as a gate test
Change bionic test from dev to gate for 18.05.

Change-Id: I21fdefe0aa0b019d5b211bb54d0a2fa9e38c2864
2018-05-11 14:29:27 -07:00
James Page 4d1d7f5a3f Fix keystone v3 support with swift backend
Refactor configuration for mitaka onwards, where the
authentication details for swift storage are in a new
glance-swift.conf configuration file.

Update for Keystone v3 support as required for
queens or later, where the v2 API has been dropped.

Closes-Bug: 1752027
Depends-On: Ie6e2733f34de10a4d34b18dbf1fd9ba623af0e18
Change-Id: Ibcc36ca22d72d310921f840e6081608be1fbc7e1
2018-02-28 08:55:08 +00:00
Zuul f202d93c5b Merge "Remove deploy from source support" 2018-01-12 14:50:18 +00:00
James Page bd7375104e Remove deploy from source support
Drop support for deployment from Git repositories, as deprecated
in the 17.02 charm release.  This feature is unmaintained and has
no known users.

Change-Id: Ic9a74991973863b2cf61fc5368bbe3664af90ef4
2018-01-08 15:11:54 +00:00
James Page f45e5edeed Drop postgresql support
Remove postgresql DB support; This feature is untested as part
of the charms, is not in use and was deprecated as part of
the 1708 charms release.

Change-Id: Ia197a37cbfe9c11538f272437d95cfc836768cc9
2017-12-21 11:59:07 +00:00
Liam Young 4b9e5c393b Request class-read object_prefix rbd_children perm
When using ceph as a backend request the additional privilege
class-read on rbd_children. This fixes bug 1696073.

Change-Id: Ie4341eb834ae6fe02424c75e31f16f1cf5411f21
Closes-Bug: #1696073
Depends-On: Icf844ec7d33f2e558dee7935fe5fa3d7f08e0d59
2017-12-15 11:05:31 +00:00
Jorge Niedbalski b95ad9c023 Restrict get_image_location policy to role:admin
This patch will cause /etc/glance/policy.json to
be updated so that *_image_location rules are
set to role:admin so that only admins can see
that info. On first update the original values are
stored on the local kvstore in case they need to
be retrieved for later restoring or comparison.

Closes-Bug: #1699565
Change-Id: Id6198d534af95013af47c0c1292ac65c79470af4
2017-12-12 22:05:24 +00:00
Liam Young be3fcbcad3 Block endpoint reg if cluster partially formed
When an existing cluster of the service is scaled out the new unit
will join with keystone before it is fully clustered. In identity
joined hook the charmhelpers function canonical_url is called which
in turn uses another charmhelpers function, resolve_address.
resolve_address will only return the vip if the vip is set in config
AND the unit is clustered. This means that the units local address
is returned and that is then registered with keystone.

This change gates registering an endpoint if the cluster is
partially formed.

Change-Id: I85e7304b1480a95c784f46490dbcc0c4cc1c3129
Partial-Bug: #1544959
2017-10-06 13:19:28 +00:00