Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/283 virtual mailbox fetch metadata #284

Merged
merged 6 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .travis.yml_old → .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ language: cpp
services:
- docker
env:
- DOVECOT="release-2.2.21"
- DOVECOT="master-2.3"
- DOVECOT="master-2.2"
before_install:
- docker volume create --name ceph_config
- docker network create --driver=bridge --subnet=192.168.100.0/24 --gateway=192.168.100.1 ceph_network
- travis_wait 30 docker run -d --net=ceph_network --name ceph_demo --mount type=tmpfs,destination=/etc/ceph -v ceph_config:/root/cfg -e MON_IP=192.168.100.2 -e CEPH_PUBLIC_NETWORK=192.168.100.0/24 -e CEPH_DEMO_UID=$DOVECOT ceph/daemon:latest demo

- travis_wait 30 docker run -itd --name build --net=ceph_network -e SOURCE_VERSION=$DOVECOT -v ceph_config:/etc/ceph -v $(pwd):/repo cephdovecot/travis-build-$DOVECOT:latest sh
- docker exec build sh -c 'printf "nameserver 8.8.8.8\n" > /etc/resolv.conf'
- docker exec build apt-get -qq update
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [0.0.25](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.25) (2022-02-23)

- virtual_mailbox: bugfix fetch fields (x-guid, date.saved..)

## [0.0.24](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.24) (2022-02-07)

- list namespace object only once, in case of force-resync
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

AC_PREREQ([2.59])

AC_INIT([dovecot-ceph-plugin], [0.0.24], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])
AC_INIT([dovecot-ceph-plugin], [0.0.25], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
4 changes: 1 addition & 3 deletions rpm/dovecot-ceph-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

Name: dovecot-ceph-plugin
Summary: Dovecot Ceph RADOS plugins
Version: 0.0.24
Version: 0.0.25
Release: 0%{?dist}
URL: https://github.com/ceph-dovecot/dovecot-ceph-plugin
Group: Productivity/Networking/Email/Servers
Expand Down Expand Up @@ -121,7 +121,5 @@ find %{buildroot}%{_libdir}/dovecot/ -type f -name \*.a -delete
%files -n rmb-tools
%defattr(-,root,root)
%attr(0755, root, root) %{_bindir}/rmb
%doc %{_mandir}/man1/rmb.1*

%changelog

6 changes: 3 additions & 3 deletions src/librmb/tools/rmb/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ rmb_SOURCES = \

rmb_LDADD = $(shlibs)

man1_MANS = rmb.man
#man1_MANS = rmb.man

EXTRA_DIST = \
$(man1_MANS)
#EXTRA_DIST = \
# $(man1_MANS)

4 changes: 2 additions & 2 deletions src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ static int iterate_mailbox(const struct mail_namespace *ns, const struct mailbox
[oid](librmb::RadosMail *m) { return m->get_oid()->compare(oid) == 0; });

if (it_mail == mail_objects.end()) {
//std::cout << " missing mail object: uid=" << mail->uid << " guid=" << guid << " oid : " << oid
// << " available: " << (it_mail != mail_objects.end()) << std::endl;
std::cout << " missing mail object: uid=" << mail->uid << " guid=" << guid << " oid : " << oid
<< " available: " << (it_mail != mail_objects.end()) << std::endl;

++mail_count_missing;
} else {
Expand Down
49 changes: 43 additions & 6 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,36 @@ static int rbox_mail_metadata_get(struct rbox_mail *rmail, enum rbox_metadata_ke
FUNC_END();
return -1;
}

// update metadata storage io_ctx and load metadata
if (alt_storage) {
r_storage->ms->get_storage()->set_io_ctx(&r_storage->alt->get_io_ctx());
} else {
r_storage->ms->get_storage()->set_io_ctx(&r_storage->s->get_io_ctx());
}

/*#283: virtual mailbox needs this (different initialisation path)*/
if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
rmail->rados_mail = r_storage->s->alloc_rados_mail();
if (rbox_get_index_record(mail) < 0) {
i_error("Error rbox_get_index_record uid(%d)", mail->uid);
FUNC_END();
return -1;
}
}

int ret_load_metadata = r_storage->ms->get_storage()->load_metadata(rmail->rados_mail);
if (ret_load_metadata < 0) {
std::string metadata_key = librmb::rbox_metadata_key_to_char(key);
if (ret_load_metadata == -ENOENT) {
i_warning("Errorcode: %d cannot get x_attr(%s,%c) from object %s, process %d", ret_load_metadata,
metadata_key.c_str(), key, rmail->rados_mail->get_oid()->c_str(), getpid());
rbox_mail_set_expunged(rmail);
} else {
} else {
i_error("Errorcode: %d cannot get x_attr(%s,%c) from object %s, process %d", ret_load_metadata,
metadata_key.c_str(), key, rmail->rados_mail->get_oid()->c_str(), getpid());
metadata_key.c_str(), key, rmail->rados_mail != NULL ? rmail->rados_mail->get_oid()->c_str() : " no oid", getpid());
}
FUNC_END();
return -1;
Expand Down Expand Up @@ -164,6 +176,17 @@ static int rbox_mail_get_received_date(struct mail *_mail, time_t *date_r) {
// in case we already read the metadata this gives us the value
// void get_metadata(rbox_metadata_key key, std::string* value) {

if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
rmail->rados_mail = r_storage->s->alloc_rados_mail();
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
return -1;
}
}
librmb::RadosUtils::get_metadata(rbox_metadata_key::RBOX_METADATA_RECEIVED_TIME, rmail->rados_mail->get_metadata(),
&value);

Expand Down Expand Up @@ -223,6 +246,19 @@ static int rbox_mail_get_save_date(struct mail *_mail, time_t *date_r) {
FUNC_END_RET("ret == 0");
return 0;
}

if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
rmail->rados_mail = r_storage->s->alloc_rados_mail();
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
return -1;
}
}

if (rmail->rados_mail->get_rados_save_date() != -1) {
*date_r = data->save_date = rmail->rados_mail->get_rados_save_date();
return 0;
Expand Down Expand Up @@ -391,19 +427,20 @@ static int rbox_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, s
int ret = -1;
enum mail_flags flags = index_mail_get_flags(_mail);
bool alt_storage = is_alternate_storage_set(flags) && is_alternate_pool_valid(_mail->box);

if (data->stream == NULL) {
if (rbox_open_rados_connection(_mail->box, alt_storage) < 0) {
FUNC_END_RET("ret == -1; connection to rados failed");
return -1;
}

librmb::RadosStorage *rados_storage = alt_storage ? ((struct rbox_storage *)_mail->box->storage)->alt
: ((struct rbox_storage *)_mail->box->storage)->s;
if (alt_storage) {
rados_storage->set_namespace(rados_storage->get_namespace());
}

/* Pop3 needs this. it looks like rbox_index_mail_set_seq is not called. */
/* Pop3 and virtual box needs this. it looks like rbox_index_mail_set_seq is not called. */
if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
Expand Down Expand Up @@ -605,7 +642,7 @@ static int rbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field
if (ret == 0) {
index_pop3_uidl_update_exists(&mail->imail.mail.mail, (*value_r)[0] != '\0');
}
#endif
#endif
return ret;
case MAIL_FETCH_POP3_ORDER:
if (!rbox_header_have_flag(_mail->box, mbox->hdr_ext_id, offsetof(struct rbox_index_header, flags),
Expand Down