GutoVeronezi commented on code in PR #6507:
URL: https://github.com/apache/cloudstack/pull/6507#discussion_r963113757


##########
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java:
##########
@@ -2126,13 +2131,33 @@ public boolean finalizeVirtualMachineProfile(final 
VirtualMachineProfile profile
             }
         }
 
+        String routerLogrotateFrequency = 
RouterLogrotateFrequency.valueIn(router.getDataCenterId());
+        if (!checkLogrotateTimerPattern(routerLogrotateFrequency)) {
+            s_logger.debug(String.format("Setting [%s] with value [%s] do not 
match with the used regex [%s], or any acceptable value ('hourly', 'daily', 
'monthly'); " +
+                            "therefore, we will use the default value [%s] to 
configure the logrotate service on the virtual 
router.",RouterLogrotateFrequency.key(),
+                    routerLogrotateFrequency, LOGROTATE_REGEX, 
RouterLogrotateFrequency.defaultValue()));
+            routerLogrotateFrequency = RouterLogrotateFrequency.defaultValue();
+        }
+        s_logger.debug(String.format("The setting [%s] with value [%s] for the 
zone with UUID [%s], will be used to configure the logrotate service frequency" 
+
+                " on the virtual router.", RouterLogrotateFrequency.key(), 
routerLogrotateFrequency, dc.getUuid()));
+        buf.append(String.format(" logrotatefrequency=%s", 
routerLogrotateFrequency));
+
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Boot Args for " + profile + ": " + buf.toString());
         }
 
         return true;
     }
 
+    /**
+     * @param routerLogrotateFrequency The string to be checked if matches 
with any acceptable values.
+     * Checks if the value in the global configuration is an acceptable value 
to be informed to the Virtual Router.
+     * @return true if the passed value match with any acceptable value based 
on the regex ((?i)(hourly)|(daily)|(monthly))|(\*|\d{2})\:(\*|\d{2})\:(\*|\d{2})

Review Comment:
   ```suggestion
        * Checks if the value in the global configuration {@link 
VirtualNetworkApplianceManager#RouterLogrotateFrequency} is an acceptable value 
to be informed to the Virtual Router.
        * @param routerLogrotateFrequency The string to be checked.
        * @return true if the passed value matches with any acceptable value 
based on the regex {@value VirtualNetworkApplianceManagerImpl#LOGROTATE_REGEX}.
   ```



##########
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java:
##########
@@ -2126,13 +2131,33 @@ public boolean finalizeVirtualMachineProfile(final 
VirtualMachineProfile profile
             }
         }
 
+        String routerLogrotateFrequency = 
RouterLogrotateFrequency.valueIn(router.getDataCenterId());
+        if (!checkLogrotateTimerPattern(routerLogrotateFrequency)) {
+            s_logger.debug(String.format("Setting [%s] with value [%s] do not 
match with the used regex [%s], or any acceptable value ('hourly', 'daily', 
'monthly'); " +

Review Comment:
   ```suggestion
               s_logger.debug(String.format("Setting [%s] with value [%s] does 
not match with the regex [%s], or any acceptable value ('hourly', 'daily', 
'monthly'); " +
   ```



##########
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java:
##########
@@ -2126,13 +2131,33 @@ public boolean finalizeVirtualMachineProfile(final 
VirtualMachineProfile profile
             }
         }
 
+        String routerLogrotateFrequency = 
RouterLogrotateFrequency.valueIn(router.getDataCenterId());
+        if (!checkLogrotateTimerPattern(routerLogrotateFrequency)) {
+            s_logger.debug(String.format("Setting [%s] with value [%s] do not 
match with the used regex [%s], or any acceptable value ('hourly', 'daily', 
'monthly'); " +
+                            "therefore, we will use the default value [%s] to 
configure the logrotate service on the virtual 
router.",RouterLogrotateFrequency.key(),
+                    routerLogrotateFrequency, LOGROTATE_REGEX, 
RouterLogrotateFrequency.defaultValue()));
+            routerLogrotateFrequency = RouterLogrotateFrequency.defaultValue();
+        }
+        s_logger.debug(String.format("The setting [%s] with value [%s] for the 
zone with UUID [%s], will be used to configure the logrotate service frequency" 
+

Review Comment:
   ```suggestion
           s_logger.debug(String.format("The setting [%s] with value [%s] for 
the zone with UUID [%s] will be used to configure the logrotate service 
frequency" +
   ```



##########
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java:
##########
@@ -289,6 +290,10 @@ public class VirtualNetworkApplianceManagerImpl extends 
ManagerBase implements V
     private static final String FILESYSTEM_WRITABLE_TEST = 
"filesystem.writable.test";
     private static final String READONLY_FILESYSTEM_ERROR = "Read-only file 
system";
     private static final String BACKUP_ROUTER_EXCLUDED_TESTS = 
"gateways_check.py";
+    /**
+     * Used regex to ensure that the value that will be passed to the VR is an 
acceptable value

Review Comment:
   ```suggestion
        * Regex used to ensure that the value that will be passed to the VR is 
an acceptable value.
   ```



##########
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java:
##########
@@ -2126,13 +2131,33 @@ public boolean finalizeVirtualMachineProfile(final 
VirtualMachineProfile profile
             }
         }
 
+        String routerLogrotateFrequency = 
RouterLogrotateFrequency.valueIn(router.getDataCenterId());
+        if (!checkLogrotateTimerPattern(routerLogrotateFrequency)) {
+            s_logger.debug(String.format("Setting [%s] with value [%s] do not 
match with the used regex [%s], or any acceptable value ('hourly', 'daily', 
'monthly'); " +
+                            "therefore, we will use the default value [%s] to 
configure the logrotate service on the virtual 
router.",RouterLogrotateFrequency.key(),

Review Comment:
   ```suggestion
                               "therefore, we will use the default value [%s] 
to configure the logrotate service on the virtual router.", 
RouterLogrotateFrequency.key(),
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to