You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "xichen01 (via GitHub)" <gi...@apache.org> on 2025/04/13 17:50:32 UTC
[PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
xichen01 opened a new pull request, #8276:
URL: https://github.com/apache/ozone/pull/8276
## What changes were proposed in this pull request?
Introduce Lifecycle-related proto message definitions and logic for converting proto objects to java objects.
This PR include https://github.com/apache/ozone/pull/8275, the current code is used for review. Please merge the current code after merge https://github.com/apache/ozone/pull/8275
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-12781
## How was this patch tested?
Unit test
https://github.com/xichen01/ozone/actions/runs/14431257574
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #8276:
URL: https://github.com/apache/ozone/pull/8276#issuecomment-2804600654
Looks like this PR have overlap with #8275. Let's review and merge #8275 first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #8276:
URL: https://github.com/apache/ozone/pull/8276#discussion_r2068526180
##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -2311,6 +2311,51 @@ message DeleteObjectTaggingRequest {
message DeleteObjectTaggingResponse {
}
+/**
+S3 lifecycles (filter, expiration, rule and configuration).
+ */
+message LifecycleFilterTag {
+ required string key = 1;
+ required string value = 2;
+}
+
+message LifecycleRuleAndOperator {
+ optional string prefix = 1;
+ repeated LifecycleFilterTag tags = 2;
+}
+
+message LifecycleFilter {
+ optional string prefix = 1;
Review Comment:
Please add the comment about oneof relationship and proto2 limitation for
1. LifecycleFilter
2. LifecycleExpiration
3. LifecycleRule prefix and filter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "xichen01 (via GitHub)" <gi...@apache.org>.
xichen01 commented on PR #8276:
URL: https://github.com/apache/ozone/pull/8276#issuecomment-2824835906
@jojoochuang Thank you for your review, the current PR consists of two tasks, the first is https://github.com/apache/ozone/pull/8275, please review this PR. The second task will be rebased after https://github.com/apache/ozone/pull/8275 be merged
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "xichen01 (via GitHub)" <gi...@apache.org>.
xichen01 commented on code in PR #8276:
URL: https://github.com/apache/ozone/pull/8276#discussion_r2069037730
##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -2311,6 +2311,51 @@ message DeleteObjectTaggingRequest {
message DeleteObjectTaggingResponse {
}
+/**
+S3 lifecycles (filter, expiration, rule and configuration).
+ */
+message LifecycleFilterTag {
+ required string key = 1;
+ required string value = 2;
+}
+
+message LifecycleRuleAndOperator {
+ optional string prefix = 1;
+ repeated LifecycleFilterTag tags = 2;
+}
+
+message LifecycleFilter {
+ optional string prefix = 1;
Review Comment:
Added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #8276:
URL: https://github.com/apache/ozone/pull/8276#discussion_r2076858811
##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -2311,6 +2311,77 @@ message DeleteObjectTaggingRequest {
message DeleteObjectTaggingResponse {
}
+/**
+S3 lifecycles (filter, expiration, rule and configuration).
+ */
+message LifecycleFilterTag {
+ required string key = 1;
+ required string value = 2;
+}
+
+message LifecycleRuleAndOperator {
+ optional string prefix = 1;
+ repeated LifecycleFilterTag tags = 2;
+}
+
+// TODO: proto 2.5 does not support oneof fields, once we start using protoc 3.x, consider to refactor these message using "oneof"
+/*
+message LifecycleFilter {
+ oneof Filter {
+ string prefix = 1;
+ LifecycleFilterTag tag = 2;
+ LifecycleRuleAndOperator andOperator = 3;
+ }
+}
+
+message LifecycleExpiration {
+ oneof Condition {
+ uint32 days = 1;
+ string date = 2;
+ }
+}
+
+message LifecycleRule {
+ //...
+ oneof Condition {
+ optional string prefix = 4;
+ optional LifecycleFilter filter = 5;
Review Comment:
@ashishkumar50 , I think this is OK, there are fields before oneof is not displayed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "ashishkumar50 (via GitHub)" <gi...@apache.org>.
ashishkumar50 commented on code in PR #8276:
URL: https://github.com/apache/ozone/pull/8276#discussion_r2074743519
##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -2311,6 +2311,77 @@ message DeleteObjectTaggingRequest {
message DeleteObjectTaggingResponse {
}
+/**
+S3 lifecycles (filter, expiration, rule and configuration).
+ */
+message LifecycleFilterTag {
+ required string key = 1;
+ required string value = 2;
+}
+
+message LifecycleRuleAndOperator {
+ optional string prefix = 1;
+ repeated LifecycleFilterTag tags = 2;
+}
+
+// TODO: proto 2.5 does not support oneof fields, once we start using protoc 3.x, consider to refactor these message using "oneof"
+/*
+message LifecycleFilter {
+ oneof Filter {
+ string prefix = 1;
+ LifecycleFilterTag tag = 2;
+ LifecycleRuleAndOperator andOperator = 3;
+ }
+}
+
+message LifecycleExpiration {
+ oneof Condition {
+ uint32 days = 1;
+ string date = 2;
+ }
+}
+
+message LifecycleRule {
+ //...
+ oneof Condition {
+ optional string prefix = 4;
+ optional LifecycleFilter filter = 5;
Review Comment:
```suggestion
optional string prefix = 1;
optional LifecycleFilter filter = 2;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #8276:
URL: https://github.com/apache/ozone/pull/8276#discussion_r2055317914
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCRule.java:
##########
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleAction;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleRule;
+
+/**
+ * A class that encapsulates lifecycle rule.
+ */
+public class OmLCRule {
+
+ public static final int LC_ID_LENGTH = 48;
+ // Ref: https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rule-id
+ public static final int LC_ID_MAX_LENGTH = 255;
+
+ private String id;
+ private String prefix;
+ private boolean enabled;
+ private boolean isPrefixEnable;
+ private boolean isTagEnable;
+ // List of actions for this rule
+ private List<OmLCAction> actions;
+ private OmLCFilter filter;
+
+ OmLCRule(String id, String prefix, boolean enabled,
+ List<OmLCAction> actions, OmLCFilter filter) {
+ this.id = id;
+ this.prefix = prefix;
+ this.enabled = enabled;
+ this.actions = actions;
+ this.filter = filter;
+
+ if (StringUtils.isEmpty(this.id)) {
+ this.id = RandomStringUtils.randomAlphanumeric(LC_ID_LENGTH);
+ }
+
+ OmLifecycleRuleAndOperator andOperator = filter != null ? filter.getAndOperator() : null;
+
+ if (prefix != null ||
+ (filter != null && filter.getPrefix() != null) ||
+ (andOperator != null && andOperator.getPrefix() != null)) {
+ isPrefixEnable = true;
+ }
+
+ if ((filter != null && filter.getTag() != null) ||
+ (andOperator != null && !andOperator.getTags().isEmpty())) {
+ isTagEnable = true;
+ }
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public List<OmLCAction> getActions() {
+ return actions;
+ }
+
+ public void setActions(List<OmLCAction> actions) {
+ this.actions = actions;
+ }
+
+ /**
+ * Get the expiration action if present.
+ * This method is for backward compatibility.
+ *
+ * @return the expiration action if present, null otherwise
+ */
+ public OmLCExpiration getExpiration() {
Review Comment:
this method is used in the test code only. Why is it for backward compatibility?
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCExpiration.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleAction;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleExpiration;
+
+/**
+ * A class that encapsulates lifecycle rule expiration action.
+ * This class extends OmLCAction and represents the expiration
+ * action type in lifecycle configuration.
+ */
+public class OmLCExpiration extends OmLCAction {
+
+ private int days;
+ private String date;
+
+ OmLCExpiration(int days, String date) {
+ this.days = days;
+ this.date = date;
+ }
+
+ public int getDays() {
+ return days;
+ }
+
+ public void setDays(int days) {
+ this.days = days;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ @Override
+ public ActionType getActionType() {
+ return ActionType.EXPIRATION;
+ }
+
+ /**
+ * Validates the expiration configuration.
+ * - Days must be a positive number greater than zero
+ * - Either days or date should be specified, but not both or neither
+ * - The date value must conform to the ISO 8601 format
+ * - The date value must be in the future
+ * - The date value must be at midnight UTC (00:00:00Z)
+ *
+ * @throws OMException if the validation fails
+ */
+ @Override
+ public void valid() throws OMException {
Review Comment:
this validation check can be refactored to make it cleaner. Right now the complexity makes corner case harder to spot.
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCRule.java:
##########
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleAction;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleRule;
+
+/**
+ * A class that encapsulates lifecycle rule.
+ */
+public class OmLCRule {
+
+ public static final int LC_ID_LENGTH = 48;
+ // Ref: https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html#intro-lifecycle-rule-id
+ public static final int LC_ID_MAX_LENGTH = 255;
+
+ private String id;
+ private String prefix;
+ private boolean enabled;
+ private boolean isPrefixEnable;
+ private boolean isTagEnable;
+ // List of actions for this rule
+ private List<OmLCAction> actions;
+ private OmLCFilter filter;
+
+ OmLCRule(String id, String prefix, boolean enabled,
+ List<OmLCAction> actions, OmLCFilter filter) {
+ this.id = id;
+ this.prefix = prefix;
+ this.enabled = enabled;
+ this.actions = actions;
+ this.filter = filter;
+
+ if (StringUtils.isEmpty(this.id)) {
+ this.id = RandomStringUtils.randomAlphanumeric(LC_ID_LENGTH);
+ }
+
+ OmLifecycleRuleAndOperator andOperator = filter != null ? filter.getAndOperator() : null;
+
+ if (prefix != null ||
+ (filter != null && filter.getPrefix() != null) ||
+ (andOperator != null && andOperator.getPrefix() != null)) {
+ isPrefixEnable = true;
+ }
+
+ if ((filter != null && filter.getTag() != null) ||
+ (andOperator != null && !andOperator.getTags().isEmpty())) {
+ isTagEnable = true;
+ }
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public List<OmLCAction> getActions() {
+ return actions;
+ }
+
+ public void setActions(List<OmLCAction> actions) {
+ this.actions = actions;
+ }
+
+ /**
+ * Get the expiration action if present.
+ * This method is for backward compatibility.
+ *
+ * @return the expiration action if present, null otherwise
+ */
+ public OmLCExpiration getExpiration() {
+ if (actions == null || actions.isEmpty()) {
+ return null;
+ }
+
+ for (OmLCAction action : actions) {
+ if (action instanceof OmLCExpiration) {
+ return (OmLCExpiration) action;
+ }
+ }
+ return null;
Review Comment:
Right now, null is not expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on PR #8276:
URL: https://github.com/apache/ozone/pull/8276#issuecomment-2825041411
Yes thanks for the reminder. Will review that one today.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12781. Implement LifecycleConfiguration proto [ozone]
Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi merged PR #8276:
URL: https://github.com/apache/ozone/pull/8276
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org