Skip to content

Log exception on keystore build for custom certificate - #6394

Merged
nvazquez merged 2 commits into
apache:4.16from
shapeblue:fixaddlogscertexception
May 18, 2022
Merged

nvazquez merged 2 commits into
apache:4.16from
shapeblue:fixaddlogscertexception

Conversation

@nvazquez

Copy link
Copy Markdown
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 nvazquez added this to the 4.17.0.0 milestone May 17, 2022
@nvazquez
nvazquez requested a review from yadvr May 17, 2022 14:35
@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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
Copy Markdown

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

@sureshanaparti sureshanaparti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

code LGTM

@yadvr

yadvr commented May 18, 2022

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@Pearl1594 Pearl1594 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 ?

@DaanHoogland DaanHoogland May 18, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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
Copy Markdown

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

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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