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

Log exception on keystore build for custom certificate #6394

Merged
merged 2 commits into from
May 18, 2022

Conversation

nvazquez
Copy link
Contributor

Description

If CloudStack fails to build and save keystore using the keystone certificate then it silently fails with just the following line:

2022-05-17 15:09:02,859 WARN  [o.a.c.f.s.k.KeystoreManagerImpl] (AgentConnectTaskPool-21:ctx-6795fce2) (logid:d7b1fab5) Unable to build keystore for CPVMCertificate due to CertificateException

This PR adds the exception to the logger

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 3419

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

code LGTM

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rohityadavcloud a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

Copy link
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

it is not appropriate to add exception stack traces to warn level logging. If the stack traces are needed add a debug statement with the stack trace but don´t add it to warn level.

@@ -109,15 +109,15 @@ public byte[] getKeystoreBits(String name, String aliasForCertificateInStore, St
try {
return CertificateHelper.buildAndSaveKeystore(certs, storePassword);
} catch (KeyStoreException e) {
s_logger.warn("Unable to build keystore for " + name + " due to KeyStoreException");
s_logger.warn("Unable to build keystore for " + name + " due to KeyStoreException", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing like this,

Suggested change
s_logger.warn("Unable to build keystore for " + name + " due to KeyStoreException", e);
s_logger.warn(String.format("Unable to build keystore for %s due to %s", name, e.getClass().getSimpleName()));
if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("Unable to build keystore for %s due to %s", name, e.getClass().getSimpleName()), e);
}

the catch clauses can be unified to one

            } catch (KeyStoreException | CertificateException | InvalidKeySpecException | IOException e) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done

Copy link
Member

Choose a reason for hiding this comment

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

@DaanHoogland
I have a question, is the check if (s_logger.isDebugEnabled()) { necessary ?

Copy link
Contributor

@DaanHoogland DaanHoogland May 18, 2022

Choose a reason for hiding this comment

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

not if the string is generated separately anyway. I think in this case (as @nvazquez implemented it) we could leave it out, @weizhouapache

Copy link
Member

Choose a reason for hiding this comment

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

OK. thanks @DaanHoogland

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 3435

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@nvazquez nvazquez merged commit 006473c into apache:4.16 May 18, 2022
@blueorangutan
Copy link

Trillian test result (tid-4201)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 29590 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6394-t4201-kvm-centos7.zip
Smoke tests completed. 92 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants