Skip to content

Conversation

@Galsza
Copy link
Contributor

@Galsza Galsza commented Nov 17, 2022

What changes were proposed in this pull request?

Create a command line tool to remove expired certificates from the SCM metadata store.

What is the link to the Apache JIRA

HDDS-7398

How was this patch tested?

Added unit test for the command. There is also an ongoing test with a real cluster to see if the certs really get removed.

@Galsza Galsza changed the title Hdds 7398 tool to remove old certs from the scm db HDDS-7398. Tool to remove old certs from the scm db Nov 17, 2022
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @Galsza for the patch. Looks good overall.

Executing the following command (even on a datanode) returns success (rc=0), no error messages.

ozone admin cert clean --db /tmp --name asdf

I guess it should complain about not being able to open the DB.

Comment on lines 31 to 38
import org.apache.hadoop.hdds.utils.db.cache.TableCache.CacheType;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid moving around imports.

Copy link
Contributor

@ChenSammi ChenSammi Dec 1, 2022

Choose a reason for hiding this comment

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

There are also imports movings in other java files.

Comment on lines 51 to 59
@CommandLine.Option(names = {"--db"},
required = true,
description = "Database metadata directory")
private String dbDirectory;

@CommandLine.Option(names = {"--name"},
required = true,
description = "Database file name")
private String dbName;
Copy link
Contributor

Choose a reason for hiding this comment

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

For convenience I would prefer having a single option, then splitting dirname/filename.

*/
@CommandLine.Command(
name = "clean",
description = "Clean expired certificates from the SCM metadata",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add description about that this command only support to run when scm is shutdown.

configuration, new File(dbDirectory), dbName, new SCMDBDefinition())) {
removeExpiredCertificates(dbStore);
} catch (IOException e) {
System.out.println("Error trying to open" + dbName +
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include the exception reason or message in the output error message.

}
}
} catch (IOException e) {
System.out.println("Error when trying to open certificate table from db");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include the detail error cause.

@symious
Copy link
Contributor

symious commented Dec 1, 2022

@Galsza Thanks for the work.

I was just wondering, is it also an option to add this feature as a daemon service in SCM, so that we don't have to do the cleaning manually?

Restore import order, add detailed exception message and use only one parameter for the db.
@Galsza
Copy link
Contributor Author

Galsza commented Dec 5, 2022

@Galsza Thanks for the work.

I was just wondering, is it also an option to add this feature as a daemon service in SCM, so that we don't have to do the cleaning manually?

@symious Thanks for the comment. This is more of a housekeeping tool for older certificates. There is no need to add this feature as a daemon in SCM. The current plan for certificate rotation is that whenever a certificate is about the expire a new one will be created. This new certificate is used after instead of the old one. After some propagation time, when we can finally ensure that the old certificate is successfully replaced everywhere by the new one, the old certificate can be safely removed, which would be done there.

Restore import order, add detailed exception message and use only one parameter for the db.
metaTable = META.getTable(store);

checkAndPopulateTable(moveTable, META.getName());
checkAndPopulateTable(metaTable, META.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch...
Fortunately this affects just metrics as I see the tableMap that is populated here is not used elsewhere...

I believe this is irrelevant for the CLI tool, and this should be in a separate patch under a separate JIRA describing the problem we fix, and we should not hide it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, this is already fixed in HDDS-7490.

Copy link
Contributor

@fapifta fapifta left a comment

Choose a reason for hiding this comment

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

Hi @Galsza thank you for taking this on, the patch overall seems to be good, and you had a very nice catch in the db definition. Let's extract that from this patch as it is irrelevant, and I am happy to +1 and commit this change.

As noted for that typo fix we should have a separate JIRA outlining the issue we had due to the typo ;)

Copy link
Contributor

@fapifta fapifta left a comment

Choose a reason for hiding this comment

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

Thank you for your work on this @Galsza the changes look good, and as I see all the comments were addressed.

@ChenSammi @adoroszlai @symious please let me know if you have any further comments. if not, I will merge this before EOW.

@fapifta fapifta merged commit 2ac31e1 into apache:master Dec 19, 2022
errose28 added a commit to errose28/ozone that referenced this pull request Dec 21, 2022
* master: (88 commits)
  HDDS-7463. SCM Pipeline scrubber never able to cleanup allocated pipeline. (apache#4093)
  HDDS-7683. EC: ReplicationManager - UnderRep maintenance handler should not request nodes if none needed (apache#4109)
  HDDS-7635. Update failure metrics when allocate block fails in preExecute. (apache#4086)
  HDDS-7565. FSO purge directory for old bucket can update quota for new bucket (apache#4021)
  HDDS-7654. EC: ReplicationManager - merge mis-rep queue into under replicated queue (apache#4099)
  HDDS-7621. Update SCM term in datanode from heartbeat without any commands (apache#4101)
  HDDS-7649. S3 multipart upload EC release space quota wrong for old version (apache#4095)
  HDDS-7399. Enable specifying external root ca (apache#4053)
  HDDS-7398. Tool to remove old certs from the scm db (apache#3972)
  HDDS-6650. S3MultipartUpload support update bucket usedNamespace. (apache#4081)
  HDDS-7605. Improve logging in Container Balancer (apache#4067)
  HDDS-7616. EC: Refactor Unhealthy Replicated Processor (apache#4063)
  HDDS-7426. Add a new acceptance test for Streaming Pipeline. (apache#4019)
  HDDS-7478. [Ozone-Streaming] NPE in when creating a file with o3fs. (apache#3949)
  HDDS-7425. Add documentation for the new Streaming Pipeline feature. (apache#3913)
  HDDS-7438. [Ozone-Streaming] Add a createStreamKey method to OzoneBucket. (apache#3914)
  HDDS-7431. [Ozone-Streaming] Disable data steam by default. (apache#3900)
  HDDS-6955. [Ozone-streaming] Add explicit stream flag in ozone shell (apache#3559)
  HDDS-6867.  [Ozone-Streaming] PutKeyHandler should not use streaming to put EC key. (apache#3516)
  HDDS-6842. [Ozone-Streaming] Reduce the number of watch requests in StreamCommitWatcher. (apache#3492)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants