Skip to content

Orchestrated VM Scheduler - #7289

Closed
rahulbcn27 wants to merge 19 commits into
apache:mainfrom
rahulbcn27:FR-Schedule
Closed

Orchestrated VM Scheduler#7289
rahulbcn27 wants to merge 19 commits into
apache:mainfrom
rahulbcn27:FR-Schedule

Conversation

@rahulbcn27

@rahulbcn27 rahulbcn27 commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

Description

This PR is for feature Orchestrated VM Scheduler where action is scheduled on VM in given period time. A new VM Schedule
festure is implemented to ochestrate stop/start on VMs.

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?

@yadvr yadvr left a comment

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.

initial review

RoleType[] authorized() default {};

Class<?>[] entityType() default {};

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.

nit - unnecessary change, you may want to use git add -p to check what's being commited.

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.

Fixed.

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.

nit - still see newline changes in APICommand

Comment thread engine/schema/src/main/java/com/cloud/vm/schedule/VMScheduleVO.java Outdated
Comment thread engine/schema/src/main/java/com/cloud/vm/schedule/VMScheduleVO.java Outdated

--- Create table for Virtual Machine Schedule Entity

CREATE TABLE IF NOT EXISTS `cloud`.`vm_schedule` (

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.

note - after 4.18 is released, this would need to be moved to a new sql upgrade path (4.18->4.19)

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.

Noted

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.

Now is the time :)

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.

@nvazquez I did not understand.

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.

To move the DB update code to the 4.18 -> 4.19 update script, @rahulbcn27 !

Comment thread engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql Outdated
Comment thread server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java Outdated
@weizhouapache

Copy link
Copy Markdown
Member

@rahulbcn27
you do not need to add "FR-194"

@weizhouapache

Copy link
Copy Markdown
Member

@rahulbcn27
there are conflicts with main branch

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@rahulbcn27 rahulbcn27 changed the title FR-194-Orchestrated VM Schedule Orchestrated VM Scheduler Feb 24, 2023
@codecov

codecov Bot commented Feb 25, 2023

Copy link
Copy Markdown

Codecov Report

Merging #7289 (b424919) into main (c2e1731) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               main    #7289      +/-   ##
============================================
- Coverage     12.68%   12.67%   -0.02%     
  Complexity     8656     8656              
============================================
  Files          2718     2721       +3     
  Lines        256172   256534     +362     
  Branches      39926    39972      +46     
============================================
  Hits          32504    32504              
- Misses       219534   219896     +362     
  Partials       4134     4134              
Impacted Files Coverage Δ
.../main/java/com/cloud/vm/schedule/VMScheduleVO.java 0.00% <0.00%> (ø)
...a/com/cloud/vm/schedule/dao/VMScheduleDaoImpl.java 0.00% <0.00%> (ø)
...src/main/java/com/cloud/api/ApiResponseHelper.java 3.81% <0.00%> (-0.02%) ⬇️
...a/com/cloud/vm/schedule/VMScheduleManagerImpl.java 0.00% <0.00%> (ø)
...rg/apache/cloudstack/backup/BackupManagerImpl.java 5.65% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@GutoVeronezi

Copy link
Copy Markdown
Contributor

@rahulbcn27, please, add a description to the PR explaining the proposal.

@GutoVeronezi
GutoVeronezi self-requested a review February 26, 2023 22:49
Comment on lines +64 to +67
@Override
public String getCommandName() {
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
}

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.

Since PR #7022, BaseCmd implements API name in lowercase + suffix 'response' as default behavior of method getCommandName; therefore, it is not necessary to override the method.

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

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.

will you remove this call, as @GutoVeronezi advises @rahulbcn27 ?

requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class CreateVMScheduleCmd extends BaseAsyncCreateCmd {
public static final String APINAME = "createVMSchedule";

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.

Following the behavior in other API classes, we can remove this property and hardcode the API name right in the APICommand annotation. The same applies to the other API commands being introduced.

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.

I haven't been following generic changes wrt API implementation if there's a new pattern we should use that. @GutoVeronezi if there's a new agreed policy feel free to raise a PR to https://github.com/shapeblue/hackerbook/blob/main/hack/api.md and discuss on dev@ML (if not already discussed). Thanks.

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.

@rohityadavcloud ,
there was a PR merged into 4.18 #7022

@rahulbcn27 please use the new format as @DaanHoogland @GutoVeronezi advised

@boring-cyborg boring-cyborg Bot added the Python Warning... Python code Ahead! label Mar 1, 2023
Comment thread api/src/main/java/com/cloud/event/EventTypes.java Outdated

@yadvr yadvr left a comment

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.

Left some remarks thanks @rahulbcn27

Comment thread api/src/main/java/com/cloud/event/EventTypes.java Outdated
start, stop, forcestop, reboot
}

public String getUuid();

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.

Is this necesasry if VMSchedule extends Identity and InternalIdentity?

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.

yes

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.

Don't think getUuid needs to be defined if you are extending Identity

RoleType[] authorized() default {};

Class<?>[] entityType() default {};

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.

nit - still see newline changes in APICommand

public static final String PRIVATE_MTU = "privatemtu";
public static final String MTU = "mtu";
public static final String LIST_APIS = "listApis";
public static final String VM_SCHEDULE_DESCRIPTION = "description";

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.

VM_ prefix isn't necessary unless the parameter is specifically for VM Schedule feature, this for example can simply be description (it's possible the DESCRIPTION param already exists that you can simply reuse).

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.

Fixed

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.

Fixed

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.

I don´t see this fixed yet.

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.

@rahulbcn27 as others mentioned you can use existing constants instead of defining new ones

public static final String VM_SCHEDULE_TIMEZONE = "timezone";
public static final String VM_SCHEDULE_ID = "vmscheduleid";

public static final String VM_SCHEDULE_IDS = "vmscheduleids";

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.

suggestion - such a param name isn't necessary when called for an API that's related to VM Schedule, however, this can be useful if the params are not used with VM Scheduler APIs.


public interface VMScheduleDao extends GenericDao<VMScheduleVO, Long> {

List<VMScheduleVO> findByVm(Long vmId);

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.

suggestion - a helper method to find the next schedule action based on current time could be useful

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.

Did it next commit change.

Comment thread server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java Outdated
Comment thread api/src/main/java/org/apache/cloudstack/api/ApiConstants.java Outdated
Comment thread api/src/main/java/com/cloud/event/EventTypes.java Outdated

--- Create table for Virtual Machine Schedule Entity

CREATE TABLE IF NOT EXISTS `cloud`.`vm_schedule` (

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.

Now is the time :)

Comment thread server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java Outdated
@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr 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 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 5793

@yadvr

yadvr commented Mar 29, 2023

Copy link
Copy Markdown
Member

@blueorangutan package

1 similar comment
@yadvr

yadvr commented Mar 29, 2023

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rohityadavcloud a Jenkins job has been kicked to build packages. It will be bundled with

SystemVM template(s). I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 5797

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache 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 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 5798

@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.

generally looks good, some points of polishing, and it does not packages at the moment (might be environmental)

Map<String,String> Tag = new HashMap<>();
if (!vmSchedule.getTag().isEmpty()) {
Tag.put("ScheduleMessage", vmSchedule.getTag());
Tag.put("ScheduleMessage" + currentTimestamp, vmSchedule.getTag());

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 a code comment but more of a functional comment; I would not use tags for this but annotations/comments.

public static final String PRIVATE_MTU = "privatemtu";
public static final String MTU = "mtu";
public static final String LIST_APIS = "listApis";
public static final String VM_SCHEDULE_DESCRIPTION = "description";

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.

I don´t see this fixed yet.

Comment on lines +64 to +67
@Override
public String getCommandName() {
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
}

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.

will you remove this call, as @GutoVeronezi advises @rahulbcn27 ?

import org.apache.cloudstack.api.response.VMScheduleResponse;
import org.apache.log4j.Logger;

@APICommand(name = DisableVMScheduleCmd.APINAME, description = "Updates a VM Schedule", responseObject = SuccessResponse.class,

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.

I do not see an indetation problem here.

String displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, currentTimestamp);
LOGGER.debug("VM poll is being called at " + displayTime);

final List<VMScheduleVO> vmsToBeExecuted = vmScheduleDao.listAll();

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.

This list can become very long, should we have a more precise search method for this? i.e. all schedules to perform in the near future?

Comment on lines +487 to +504
if (vmInstance.getState() == VirtualMachine.State.Running) {
LOGGER.debug("Virtual Machine is already running" + vmInstance.getId());
break;
}
final Long eventStartId = ActionEventUtils.onScheduledActionEvent(User.UID_SYSTEM, vmInstance.getAccountId(),
EventTypes.EVENT_VM_START, "Starting a VM for VM ID:" + vmInstance.getUuid(),
vmInstance.getId(), ApiCommandResourceType.VirtualMachine.toString(),
true, 0);
vmManager.start(vmInstance.getUuid(), params);
vmTag = setVMTag(vmSchedule);
createTagForVMInstance(vmTag, vmInstance);
if (CallContext.current().getCallingUser().getEmail() != null) {
String subject = "VM START";
String message = "VM started on " + vmSchedule.getScheduleType() + " at " + vmSchedule.getSchedule();
alertManager.sendAlert(AlertManager.AlertType.ALERT_TYPE_VM_START, vmInstance.getDataCenterId(),
vmInstance.getPodIdToDeployIn(),subject,message);
}
jobId = setAsyncJobForVMSchedule(vmInstance, eventStartId);

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.

I would like to see these blocks in separate methods for each type of action.

Comment on lines +113 to +118
@classmethod
def tearDownClass(cls):
try:
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % 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.

Suggested change
@classmethod
def tearDownClass(cls):
try:
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@classmethod
def tearDownClass(cls):
super(TestVmSchedule, cls).tearDownClass()

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.

Fixed

serviceofferingid=cls.service_offering.id,
mode=cls.zone.networktype
)
# cls.cleanup.append(cls.virtual_machine)

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.

why code in comment? take it our or uncomment, I'd say

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.

Fixed

Comment on lines +135 to +139
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % 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.

Suggested change
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
def tearDown(self):
super(TestVmSchedule, self).tearDown()

Comment thread usage/pom.xml
Comment on lines -120 to -132
<target>
<copy overwrite="true" todir="${basedir}/target/transformed">
<fileset dir="${basedir}/conf">
<include name="*.in" />
</fileset>
<globmapper from="*.in" to="*" />
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="${cs.replace.properties}" />
</filterreader>
</filterchain>
</copy>
</target>

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.

why does this need removing?

response.success,
True,
"VM schedule is not removed "
"check the response action of vm schedule is start!"

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.

your comment here is "minor change ..." but you remove 4 test cases. Is that on purpose?

@yadvr

yadvr commented Mar 29, 2023

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rohityadavcloud 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.

@sonarqubecloud

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 34 Code Smells

6.8% 6.8% Coverage
2.0% 2.0% Duplication

requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.19.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class DisableVMScheduleCmd extends BaseAsyncCmd {
public static final String APINAME = "disableVMSchedule";

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.

Do we really need three APIs - update, enable and disable?
Would it be better if the update API handles state change as well?

quickViewEnabled () {
return new RegExp(['/vm', '/kubernetes', '/ssh', '/userdata', '/vmgroup', '/affinitygroup', '/autoscalevmgroup',
'/volume', '/snapshot', '/vmsnapshot', '/backup',
'/volume', '/snapshot', '/vmsnapshot', '/backup', '/schedule',

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.

Suggested change
'/volume', '/snapshot', '/vmsnapshot', '/backup', '/schedule',
'/volume', '/snapshot', '/vmsnapshot', '/backup', '/vmschedule',

enableGroupAction () {
return ['vm', 'alert', 'vmgroup', 'ssh', 'userdata', 'affinitygroup', 'autoscalevmgroup', 'volume', 'snapshot',
'vmsnapshot', 'guestnetwork', 'vpc', 'publicip', 'vpnuser', 'vpncustomergateway',
'vmsnapshot', 'schedule', 'guestnetwork', 'vpc', 'publicip', 'vpnuser', 'vpncustomergateway',

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.

Suggested change
'vmsnapshot', 'schedule', 'guestnetwork', 'vpc', 'publicip', 'vpnuser', 'vpncustomergateway',
'vmsnapshot', 'vmschedule', 'guestnetwork', 'vpc', 'publicip', 'vpnuser', 'vpncustomergateway',

},
generateHumanReadableEntityType (record) {
switch (record.entitytype) {
case 'VMSCHEDULE' : return 'schedule'

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.

Suggested change
case 'VMSCHEDULE' : return 'schedule'
case 'VMSCHEDULE' : return 'VM Schedule'

},
entityTypeToPath (entitytype) {
switch (entitytype) {
case 'VMSCHEDULE' : return 'schedule'

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.

Suggested change
case 'VMSCHEDULE' : return 'schedule'
case 'VMSCHEDULE' : return 'vmschedule'

// specific language governing permissions and limitations
// under the License.

<template>

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.

This UI element can be further improved for generic use.

List of actions can be passed as property. This may take some work

"start",
"check the response action of vm schedule is start!"
)
return

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.

May cover other APIs - update, enable, disable, delete

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class VMScheduleManagerImpl extends ManagerBase implements VMScheduleManager, Configurable, PluggableService {

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.

Are there any unit tests for this class?

requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class CreateVMScheduleCmd extends BaseAsyncCreateCmd {
public static final String APINAME = "createVMSchedule";

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.

@rohityadavcloud ,
there was a PR merged into 4.18 #7022

@rahulbcn27 please use the new format as @DaanHoogland @GutoVeronezi advised


@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;

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.

the value would be the id of caller or owner
(the same issue in other APIs)

final AsyncJobVO asyncJob = asyncJobManager.getAsyncJob(asyncJobId);
switch (asyncJob.getStatus()) {
case SUCCEEDED:
case FAILED:

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.

may add "case CANCELLED" as well

for (final VMScheduleVO vmSchedule : vmsToBeExecuted) {
final long timeDifference = DateUtil.getTimeDifference(vmSchedule.getScheduledTimestamp(), currentTimestamp);

if (timeDifference <= 1) {

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.

@rahulbcn27
can you explain what this check does if (timeDifference <= 1)?
should VMSchedulerInterval.value() be used here ?

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.

it is used to check the condition in which time difference between scheduledtimestamp and currentimestamp is mininum <
1 min so that action can be performed on action.


private Map<String, String> setVMTag(VMScheduleVO vmSchedule) {
Map<String,String> Tag = new HashMap<>();
if (!vmSchedule.getTag().isEmpty()) {

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.

might getTag be null ? if so, NPE will be thrown
can use CollectionUtils instead

return jobId;
}

private Long performActionOnVM(String action, VMInstanceVO vmInstance, VMScheduleVO vmSchedule) throws ResourceUnavailableException, InsufficientCapacityException {

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.

+1 with @DaanHoogland

@yadvr

yadvr commented Mar 29, 2023

Copy link
Copy Markdown
Member

Discussed with Rahul and passed some feedback. We'll revisiting this with another iteration in future.

@yadvr yadvr closed this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants