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
fix: Remove all client side validation for OLM, allow nonspecific lif… #1160
Changes from 1 commit
07c66be
e9baf28
a6ed553
35741bb
01b1407
219c04f
6e19fe2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -548,8 +548,12 @@ static LifecycleRule fromPb(Rule rule) { | |
StorageClass.valueOf(action.getStorageClass())); | ||
break; | ||
default: | ||
throw new UnsupportedOperationException( | ||
"The specified lifecycle action " + action.getType() + " is not currently supported"); | ||
log.warning( | ||
"Creating a lifecycle rule with no supported actions: " | ||
+ rule | ||
+ ". Attempting to update with this rule may cause errors. Please " | ||
+ "update to the latest version of google-cloud-storage."); | ||
lifecycleAction = LifecycleAction.newLifecycleAction(action.getType()); | ||
} | ||
|
||
Rule.Condition condition = rule.getCondition(); | ||
|
@@ -799,13 +803,25 @@ public LifecycleCondition build() { | |
} | ||
|
||
/** | ||
* Base class for the Action to take when a Lifecycle Condition is met. Specific Actions are | ||
* Base class for the Action to take when a Lifecycle Condition is met. Supported Actions are | ||
* expressed as subclasses of this class, accessed by static factory methods. | ||
*/ | ||
public abstract static class LifecycleAction implements Serializable { | ||
public static class LifecycleAction implements Serializable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to remove the modifier abstract in this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Abstract classes can't be instantiated so we do if we want to allow for unsupported action types to be created in this way. The alternative would be to make an implementation of LifecycleAction for that purpose, like "CustomLifecycleAction" or something, but I'm worried that doing that would be confusing, or imply that this is the correct way to use action types that aren't in the library (when in actuality users should upgrade to the latest version of the library) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, totally missed that. Thanks Jesse, I would confirm what happens when a say setStorageClass doesn't have storageClass in the rule (the case an action type is added that requires additional parameters) and see how GCS handles the request on a PATCH request. I suspect it will fail; so we may want to clarify if we want the library not to create an instance for that unknown action type. |
||
private static final long serialVersionUID = 5801228724709173284L; | ||
|
||
public abstract String getActionType(); | ||
private final String actionType; | ||
|
||
public String getActionType() { | ||
return actionType; | ||
} | ||
|
||
private LifecycleAction(String actionType) { | ||
BenWhitehead marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this constructor |
||
this.actionType = actionType; | ||
} | ||
|
||
public static LifecycleAction newLifecycleAction(String actionType) { | ||
BenWhitehead marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return new LifecycleAction(actionType); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
@@ -836,11 +852,8 @@ public static class DeleteLifecycleAction extends LifecycleAction { | |
public static final String TYPE = "Delete"; | ||
private static final long serialVersionUID = -2050986302222644873L; | ||
|
||
private DeleteLifecycleAction() {} | ||
|
||
@Override | ||
public String getActionType() { | ||
return TYPE; | ||
private DeleteLifecycleAction() { | ||
super(TYPE); | ||
} | ||
} | ||
|
||
|
@@ -851,14 +864,10 @@ public static class SetStorageClassLifecycleAction extends LifecycleAction { | |
private final StorageClass storageClass; | ||
|
||
private SetStorageClassLifecycleAction(StorageClass storageClass) { | ||
super(TYPE); | ||
this.storageClass = storageClass; | ||
} | ||
|
||
@Override | ||
public String getActionType() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
|
@@ -1007,7 +1016,11 @@ static class RawDeleteRule extends DeleteRule { | |
|
||
@Override | ||
void populateCondition(Rule.Condition condition) { | ||
throw new UnsupportedOperationException(); | ||
log.warning( | ||
BenWhitehead marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"The lifecycle condition " | ||
+ condition | ||
+ " is not currently supported. Please update to the latest version of google-cloud-java." | ||
+ " Also, use LifecycleRule rather than the deprecated DeleteRule."); | ||
} | ||
|
||
private void writeObject(ObjectOutputStream out) throws IOException { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add tests to ensure unknown types no longer throw exceptions?