WaelHamze / xrm-ci-framework

xRM CI Framework provides you with the tools automate the build and deployment of your CRM Solution. Using the framework to implement a fully automated DevOps pipeline will allow you to deploy more frequently with added consistency and quality.
MIT License
186 stars 116 forks source link

Delete And Promote / Apply Solution Upgrade #93

Closed bo-stig-christensen closed 6 years ago

bo-stig-christensen commented 6 years ago

It is a known feature that the Import Solution request takes the HoldingSolution parameter. This is equal to "Stage for Upgrade" in the UI. - However, this does not actually apply the upgrade after import.

There is a DeleteAdnPromoteRequest available: https://msdn.microsoft.com/de-de/library/microsoft.crm.sdk.messages.deleteandpromoterequest.aspx

It would be extremely useful if the VSTS Build Tasks would have this as a separate task: "MSCRM Delete And Promote Solution" or "MSCRM Apply Solution Upgrade".

WaelHamze commented 6 years ago

Great idea, will add support for this in the next version.

cseymr commented 6 years ago

So if I understand this correctly @WaelHamze - your script is creating the holding solution, but never applying it? This symptom matches what we are seeing in our deployment process (more or less - we seem to hit the 900s timeout on the 'Import Solution' task and get the error string from here:

    if ($solution.Version -ne $solutionInfo.Version) 
    {
        throw "Import Failed. Check the solution import log file in the logs subfolder of the Drop folder."
    }

By the way - we've literally no idea where this 'Drop' folder is :-)

bo-stig-christensen commented 6 years ago

@craigseymour Currently, the build tasks simply create the holding solution, but they do not apply it. So this feature would improve on this either as a separate build/release task or as a parameter in the existing import task. However, I would probably prefer it as a separate build/release task, as it has more flexibility to make additional steps in between import and apply, as well as the fact that they are 2 separate long-running requests.

Regarding your Drop folder, please refer to the following: How do I access hosted agent drop folder?

cseymr commented 6 years ago

I think I'm inclined to agree with you @bo-stig-christensen on having a separate task, if only for the duration aspect; and I suppose there may be situations like you say where you want to do something before applying the upgrade.

Thanks also for the pointer to the drop folder - I must confess I'd assumed this was a TFS thing and didn't even look to see if VSTS supported it as well.

WaelHamze commented 6 years ago

@bo-stig-christensen @craigseymour thanks a lot for your feedback. I will look at creating a separate task. Note that timeout is a parameter that is configurable and can be changed on long running tasks depending on your needs.

WaelHamze commented 6 years ago

By the way what kind of steps do you think you could perform between import and apply?

bo-stig-christensen commented 6 years ago

@WaelHamze The "Apply for Upgrade" is in many cases just a way to ensure that deleted components will actually be deleted/cleaned by the import process, so in this case I usually do not need anything in between.

However, I could imagine situations/processes in which you would have a Post-Deployment approval by a test team before you apply the upgrade. - This way you have a way of rolling back in case something is not right.

One could imagine this easily:

  1. Import solution (stage, but not apply)
  2. Run automated integration tests
  3. Post-Deployment approval after QA tests by Project Manager / Product Owner
  4. Apply upgrade

If it's not that big of a deal, it could be implemented both as a checkbox option on the import task, as well as a separate "Apply Solution Upgrade" task (or similar name). - If only implementing one of the options, I would go for the separate task for flexibility.

WaelHamze commented 6 years ago

@bo-stig-christensen @craigseymour I have created a separate task will publish in the next release. let me know if you would like a preview before.

bo-stig-christensen commented 6 years ago

@WaelHamze Sounds great! :) About the preview version, it depends... when are you planning next release? ;-) I wouldn't need the CI Framework itself, but rather the VSTS build/release tasks as this is where we have our DevOps :-)

cseymr commented 6 years ago

Related note: not sure if you want it here or as separate issue: Because the existing code will create the solution, but not apply it, then the version check near the bottom fails. So if you make applying the solution as a separate task, you need to review that version check code to be conditional on there not being a holding solution parameter set; and if there is a parameter set, to check that an upgrade now exists in CRM and is of the right version.

WaelHamze commented 6 years ago

@bo-stig-christensen I am expecting the task deployed to market place in a week or so. Just fixing some issues on another task.

@craigseymour Good spot. I am aware of that and this has already been changed to look at the holding solution parameter. There is also another issue for it :)

WaelHamze commented 6 years ago

Released to Marketplace 9.0.24. Let me know if any issues.

cseymr commented 6 years ago

@WaelHamze Tried this out today. It successfully applied the solution, but the task reported a time-out error as below. We've got the default timeouts of 120s (connection) and 900s (async) set, so it looks to us like the wrong timeout is triggering? If it makes any difference, we're connecting to a v8.2 instance.

2018-04-19T10:23:07.4367332Z ##[section]Starting: Apply [redacted] Solution Upgrade
2018-04-19T10:23:07.4367332Z ==============================================================================
2018-04-19T10:23:07.4367332Z Task         : MSCRM Apply Solution Upgrade (preview)
2018-04-19T10:23:07.4367332Z Description  : Applies a solution upgrade after solution is import using stage for upgrade option
2018-04-19T10:23:07.4367332Z Version      : 9.0.3
2018-04-19T10:23:07.4523897Z Author       : Wael Hamze
2018-04-19T10:23:07.4523897Z Help         : This task invokes DeleteAndPromoteRequest in Async mode
2018-04-19T10:23:07.4523897Z ==============================================================================
2018-04-19T10:23:08.5616992Z Solution Upgrade Starting. Import Job Id: 6730066c-69e7-42d8-8bd1-868c5114de7a
2018-04-19T10:25:17.1653480Z ##[error]The request channel timed out while waiting for a reply after 00:02:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
2018-04-19T10:25:17.1965582Z ##[section]Finishing: Apply [redacted] Solution Upgrade
WaelHamze commented 6 years ago

@craigseymour The connection timeout is set to 2 minutes by default which means each individual sync call can't take longer than 2 minutes.

Once the apply starts it will finish if there are no errors regardless of the timeout.

I looked at the script and it seems like I forget the add the async param so at present this is happening sync, I have just made a change and will include it in the next release. In the meantime increase the 2 minute timeout.

Thx for the feedback.

WaelHamze commented 6 years ago

@craigseymour correction, async upgrade is not supported. I have remove the async settings, please increase connection timeout

cseymr commented 6 years ago

A-hah! Thanks,

ciaomatteo commented 5 years ago

image

I use the "MS CRM Package deployer" vsts task and run always in this error message. How can I increase this timeout in D365 online? Or is there a way to disable this upgrade option? By the way: I don't get the timeout if I run package deployer locally.

tarunmicrosoft commented 5 years ago

image

I use the "MS CRM Package deployer" vsts task and run always in this error message. How can I increase this timeout in D365 online? Or is there a way to disable this upgrade option? By the way: I don't get the timeout if I run package deployer locally.

I am also facing the same issue. Did you figure it out?

ciaomatteo commented 5 years ago

Yes, downgrading the vsts build task helped in my case.

On Tue, 4 Dec 2018, 11:36 tarunmicrosoft <notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/13016624/48611989-e9f7fb80-e987-11e8-9df7-7614d7a8b68e.png

I use the "MS CRM Package deployer" vsts task and run always in this error message. How can I increase this timeout in D365 online? Or is there a way to disable this upgrade option? By the way: I don't get the timeout if I run package deployer locally.

I am also facing the same issue. Did you figure it out?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WaelHamze/xrm-ci-framework/issues/93#issuecomment-444053523, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaeMPA3ugTVcMEl7Jj-ZP-BXbOVyLJQks5u1lA3gaJpZM4StLwh .

tarunmicrosoft commented 5 years ago

@CrmDev23 Thanks for quick response, the failure is in MS CRM Package deployer task. Which build task exactly did you downgrade.

HIREN-AITC commented 5 years ago

image I use the "MS CRM Package deployer" vsts task and run always in this error message. How can I increase this timeout in D365 online? Or is there a way to disable this upgrade option? By the way: I don't get the timeout if I run package deployer locally.

I am also facing the same issue. Did you figure it out?

I am facing the same issue with version 10. I am connecting to CRM 9.0 How can I increate timeout to overcome this issue?

MerivaIe commented 5 years ago

image I use the "MS CRM Package deployer" vsts task and run always in this error message. How can I increase this timeout in D365 online? Or is there a way to disable this upgrade option? By the way: I don't get the timeout if I run package deployer locally.

I am also facing the same issue. Did you figure it out?

I am facing the same issue with version 10. I am connecting to CRM 9.0 How can I increate timeout to overcome this issue?

I am also facing the same issue with the holding solution deletion step (version 10 of the MSCRM Package Deployer task). The exact error message is: "The request channel timed out while waiting for a reply after 00:02:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. => The HTTP request to 'https://{instance-name}.{crmX}.dynamics.com/XRMServices/2011/Organization.svc' has exceeded the allotted timeout of 00:02:00. The time allotted to this operation may have been a portion of a longer timeout"

On the MSCRM Package Deployer task, I have set the Package Deployment Timeout to an hour and a half. This deployment fails after less than 20 minutes with this error though.

totrickl commented 5 years ago

Why does Package deployer task create a Holding solution at the first place? Is this really needed? If a lot of people face this issue maybe it would be better not to create one?

rojorioko commented 4 years ago

Hi @WaelHamze,

Is it possible to let Package Deployer to stage the solution for upgrade and have new task apply the solution upgrade?

Now, our package deployer package executes both action immediately.

Kind Regards,