Skip to content

removal: configomat (submodule)#3045

Merged
georglauterbach merged 12 commits intomasterfrom
remove-configomat
Feb 5, 2023
Merged

removal: configomat (submodule)#3045
georglauterbach merged 12 commits intomasterfrom
remove-configomat

Conversation

@georglauterbach
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach commented Jan 30, 2023

Description

I wanted to do this for a long time. The submodule has only one script in it, and this script does not adhere to our high standards when it comes to Bash. I rewrote it as a proper helper function. This way, we can get rid of the whole submodule. This makes the LDAP code a bit easier to maintain too; although I got to admit that I didn't do it specifically for this reason; my main concern was code quality and usage of an unnecessary submodule.

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

I wrote a function that ShellCheck does not want to immediately kill
(like `configomat.sh` ..). The new function is written in idiomatic Bash
and properly documented. The behavior is nearly identical to the old
script; the only exception is that you cannot provide more than one file
to adjust contents in. This could be easily done in the future;
currently we don't need it and it would make the function longer than
necessary (I like KISS).
@georglauterbach georglauterbach added area/scripts kind/improvement Improve an existing feature, configuration file or the documentation kind/update Update an existing feature, configuration file or the documentation labels Jan 30, 2023
@georglauterbach georglauterbach added this to the v12.0.0 milestone Jan 30, 2023
@georglauterbach georglauterbach self-assigned this Jan 30, 2023
@georglauterbach georglauterbach requested review from wernerfred and removed request for NorseGaud January 30, 2023 19:33
I noticed we do not need an associative array at all. This makes the
whole thing even easier - nice.
@georglauterbach
Copy link
Copy Markdown
Member Author

Noting here for future inspections: test fails randomly (and this test is not associated with the changes in any way)

not ok 32 checking dovecot mailbox format: mdbox file created in 31119ms
# (from function `repeat_until_success_or_timeout' in file test/test_helper/common.bash, line 51,
#  in test file test/tests/serial/mail_with_mdbox.bats, line 28)
#   `repeat_until_success_or_timeout 30 docker exec mail_with_mdbox_format /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/storage/m.1 | wc -l) -eq 1 ]'' failed

There is parsing of ls involved .. This needs to change :D

@polarathene
Copy link
Copy Markdown
Member

Noting here for future inspections: test fails randomly (and this test is not associated with the changes in any way)

They're due to the Postfix wrapper removal I think, that's where I first saw them pop up, but forgot to PR revised versions of those tests in response 😅

Presumably (I haven't looked at the tests yet) they fail now because Postfix loads faster which likewise broke the amavis spam tests (that did get fixed).

Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see the method use the same test coverage that configomat has, I detailed those in an old issue where I proposed a rust port.

If you're open to introducing rust into the project, it might also be an alternative option. The rust version is a bit more thorough and verbose, but I'd argue easier to maintain for most than all the shell voodoo going on for this utility method 😅 (unless you're @casperklein and @georglauterbach of course who have crazy good shell-fu skills)

I would like similar rust code to handle other areas of the project, especially with the user management, but need other maintainers to be comfortable with rust in the project as I am likely to have reduced availability in the future for DMS.

Comment thread target/scripts/helpers/utils.sh Outdated
@georglauterbach
Copy link
Copy Markdown
Member Author

Noting here for future inspections: test fails randomly (and this test is not associated with the changes in any way)

They're due to the Postfix wrapper removal I think, that's where I first saw them pop up, but forgot to PR revised versions of those tests in response 😅

Presumably (I haven't looked at the tests yet) they fail now because Postfix loads faster which likewise broke the amavis spam tests (that did get fixed).

IIRC I have seen them even before your change to Postfix, so I think they might actually be unrleated. They are a timing issie though, I agree, since our CI is running faster and faster.

@georglauterbach
Copy link
Copy Markdown
Member Author

georglauterbach commented Jan 31, 2023

I would like to see the method use the same test coverage that configomat has, I detailed those in an old issue where I proposed a rust port.

Agreed; I can add such tests.

If you're open to introducing rust into the project, it might also be an alternative option. The rust version is a bit more thorough and verbose, but I'd argue easier to maintain for most than all the shell voodoo going on for this utility method 😅 (unless you're @casperklein and @georglauterbach of course who have crazy good shell-fu skills)

To start things off: I love Rust. I think it is by far the best programming language out there. Im using Rust in private and at work, almost every single day. So from a maintenance point of view, I can definitely handle it.

But I guess this is not enough, not even close. Before we get going with Rust, and I am not against that really, we need to make up our mind what this would look like. In the meantime, I'd go forward with Bash.

We would need to answer a few important questions:

  1. Can people maintain the Rust code? (I actually think that the Bash code we deploy right now is pretty high-class, but sometimes also hard to understand as a consequence. Therefore, maintaining Rust would probably solely depend on the amount of people that can actually program in Rust?)
  2. What would the integration look like? Would there be Rust code in this project? Would you package it, or build it when building the container?

I would like similar rust code to handle other areas of the project, especially with the user management, but need other maintainers to be comfortable with rust in the project as I am likely to have reduced availability in the future for DMS.

I think DMS could profit from Rust as well. But we should have a dedicated maintainers discussion or an issue for this topic IMO.

I noticed that shutting down the whole container in case the file you
want to change stuff in does not exist might not be a good idea after
all. I discovered this because it seems that `/etc/postfix/maps/sender_login_maps.ldap`
is not actually present when running the tests. I added an extra check.
We did not discover this previously because it was hidden by the usage
of `$(...)`, in which the call to `configomat.sh` with a file that
doesnt exist was the last call. The script would call exit, which would
exit the subshell spawned by `$(...)`. We didn't notice it because we do
not use `set -eE`. The new (and proper) function reveiled this flaw.
@georglauterbach
Copy link
Copy Markdown
Member Author

Noting another spurious test failure here:

not ok 42 checking dovecot mailbox format: sdbox file created in 30905ms
# (from function `repeat_until_success_or_timeout' in file test/test_helper/common.bash, line 51,
#  in test file test/tests/serial/mail_with_sdbox.bats, line 28)
#   `repeat_until_success_or_timeout 30 docker exec mail_with_sdbox_format /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1 | wc -l) -eq 1 ]'' failed
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# ls: cannot access '/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1': No such file or directory
# Timed out on command: docker exec mail_with_sdbox_format /bin/sh -c [ $(ls /var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1 | wc -l) -eq 1 ]

@polarathene
Copy link
Copy Markdown
Member

Before we get going with Rust, we need to make up our mind what this would look like. In the meantime, I'd go forward with Bash.
We would need to answer a few important questions:

For quite some time now, the active maintainers have effectively been 3 of us. I've learned more about bash / shell scripts through you two, but if I'm not actively using those skills I forget what the syntax / features are and will need to look up again how to interpret what I'm seeing.

As you're already comfortable with Rust, this mostly flips the DX issue from me to casper. But as I am likely to become less active as a maintainer here, that could be a concern.

On the plus side, I can't say that bash has attracted many contributions, and definitely not more maintainers. There's been multiple times where I've had to lose time into figuring out how to do something with bash / commands that would be much simpler with a language like rust (or even python 😬 ), especially if that's nested arrays and parsing / editing files.

As long as there's already a solid foundation of rust introduced, that upfront knowledge is taken care of and isn't likely to cause much maintenance burden. I think there would be less need to reach out to a search engine / docs as the syntax of what is going on is often more obvious. Plus if something goes wrong the compiler is pretty good at telling you where and often how to fix it.

Rust experience from contributors probably won't be any more common than decent bash, so it may not help attract more maintainers. I do think it is easier to maintain with proper modules vs the "globals" sourcing approach we tend to take with shell scripts. There is also less portability issues (macOS / Windows contributors, and even linux like my local grep misbehaving vs rg).

What would the integration look like? Would there be Rust code in this project? Would you package it, or build it when building the container?

That's a good question. For CLI like programs, those could be separate repos, but once you start porting the bulk of shell scripts, then it would need to be part of this project.

  • When it's CLI programs, you could just have a CI build and publish artifacts that can be pulled into a main Dockerfile.
  • Once replacing core scripts, then it's being updated more frequently and tied more heavily to what goes on in this repo, thus needs PRs for traceability to not fall out of sync like we used to have with features and the old Github wiki. We'd probably be building in the container at that point?

I think DMS could profit from Rust as well. But we should have a dedicated maintainers discussion or an issue for this topic IMO.

Yeah all good. My focus right now is to get the project where I'd like it to be first, so that's with bash.

If I then find time to propose introducing some rust I'll raise a proper maintainer discussion about it 👍


Noting another spurious test failure here:

I'll tackle those tests today if you've not already started 😅

Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I find the bash version daunting to digest, excellent work! 😀

I compared the PR test to the configomat one, looks good + nice improvements! 👍 (and fixes to pass the previously disabled test cases)

Comment thread target/scripts/helpers/utils.sh Outdated
Comment thread target/scripts/startup/setup-stack.sh
Comment thread test/test-files/replace_by_env_in_file.conf
polarathene
polarathene previously approved these changes Feb 1, 2023
Copy link
Copy Markdown
Member

@casperklein casperklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 5, 2023

Documentation preview for this PR is ready! 🎉

Built with commit: 71fd6fa

@georglauterbach georglauterbach merged commit 00b1d88 into master Feb 5, 2023
@georglauterbach georglauterbach deleted the remove-configomat branch February 5, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scripts kind/improvement Improve an existing feature, configuration file or the documentation kind/update Update an existing feature, configuration file or the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants