Skip to content
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

v3.2.1 not idempotent on Windows 7 sp1 #55

Closed
jugatsu opened this issue Apr 28, 2017 · 5 comments
Closed

v3.2.1 not idempotent on Windows 7 sp1 #55

jugatsu opened this issue Apr 28, 2017 · 5 comments
Milestone

Comments

@jugatsu
Copy link
Contributor

jugatsu commented Apr 28, 2017

install_required? is always true and it never prints

::Chef::Log.info ".NET `#{new_resource.version}' is not needed because .NET `#{current_resource.version}' is already installed"

As a side effect if reboot_pending? is also true and perfrom_reboot attribute istrue then the node will be rebooted.

v3.2.0 with #52 patch works as expected.

I think the cause of this behavior in f585848#diff-a7d2eeb2d086b81cd0d199ea024b68e3

@jugatsu
Copy link
Contributor Author

jugatsu commented Apr 28, 2017

Recipe: ms_dotnet::ms_dotnet4
         * ms_dotnet_framework[4.5.2] action install[2017-04-28T13:59:41+04:00] INFO: Processing ms_dotnet_framework[4.5.2] action install (ms_dotnet::ms_dotnet4 line 24)
       
           * windows_package[Microsoft .NET Framework 4.5.2] action install[2017-04-28T13:59:41+04:00] INFO: Processing windows_package[Microsoft .NET Framework 4.5.2] action install (C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ms_dotnet/resources/framework.rb line 77)
       
           Recipe: <Dynamically Defined Resource>
             * remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache\package\NDP452-KB2901907-x86-x64-AllOS-ENU.exe] action create[2017-04-28T13:59:41+04:00] INFO: Processing remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache\package\NDP452-KB2901907-x86-x64-AllOS-ENU.exe] action create (dynamically defined)
        (up to date)
       (up to date)
           * reboot[Reboot for ms_dotnet package 'Microsoft .NET Framework 4.5.2'] action reboot_now[2017-04-28T13:59:41+04:00] INFO: Processing reboot[Reboot for ms_dotnet package 'Microsoft .NET Framework 4.5.2'] action reboot_now (C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ms_dotnet/resources/framework.rb line 91)
        (skipped due to only_if)
            (up to date)
       Recipe: ms_dotnet::ms_dotnet2
         * ms_dotnet_framework[2.0.SP2] action install[2017-04-28T13:59:41+04:00] INFO: Processing ms_dotnet_framework[2.0.SP2] action install (ms_dotnet::ms_dotnet2 line 24)
        (up to date)
....
Chef Client finished, 0/26 resources updated in 17 seconds

@Annih
Copy link
Contributor

Annih commented Apr 28, 2017

Hello @jugatsu

Thanks for reporting this issue and giving us your feedback. I would like to clarify certain things before giving you answers.

  1. Could you provide us more info about your current setup:
    1.a. The version of chef and the ms_dotnet cookbook
    1.b. The original versions of .NET installed, and the target ones.
    1.c. The setup used to run chef in the output you have copy/paste
  2. About v3.2.1 not idempotent on Windows 7 sp1, could you explain what do you consider idempotent?
    2.a. install_required? returns true
    2.b. Chef::Log.info XXX is not called
    2.c. Reboots may occur if pending_reboot is true
    2.d. Something else?

Regards :)

@jugatsu
Copy link
Contributor Author

jugatsu commented Apr 29, 2017

@Annih

1a. chef version 12.19.36, ms_dotnet - 3.2.1
1b. 4.5.2

attributes:

default['ms_dotnet'] = {
  'v4' => {
    'version' => '4.5.2',
    'perform_reboot' => true,
    'package_sources' => {
      '6c2c589132e830a185c5f40f82042bee3022e721a216680bd9b3995ba86f3781' => 'http://192.168.0.253:8000/Microsoft/dotNet/4.5.2/NDP452-KB2901907-x86-x64-AllOS-ENU.exe',
    },
  },
}

recipe:

ms_dotnet_framework node['ms_dotnet']['v4']['version'] do
  perform_reboot node['ms_dotnet']['v4']['perform_reboot']
  package_sources node['ms_dotnet']['v4']['package_sources']
  action :install
end

2a. Chef::Log.info
https://github.com/criteo-cookbooks/ms_dotnet/blob/master/resources/framework.rb#L48 never outputs even when .Net is installed.
2c. In my case reboot pending triggers another app ( to be clear, removing of this app) :). This is not important right now as it should'n move to https://github.com/criteo-cookbooks/ms_dotnet/blob/master/resources/framework.rb#L74 if .Net is already installed.

I think https://github.com/criteo-cookbooks/ms_dotnet/blob/master/resources/framework.rb#L119 always returns True.

@Annih
Copy link
Contributor

Annih commented Apr 29, 2017

Ok I'll try to explain my point of view, because I wrote this logic :D

Explanations

First, let's talk about the install_required? helper:

  • It is implemented/used to avoid non-idempotent behavior when you try to install .NET 4 when .NET 4.5.2 is installed for instance.
  • If you read the comment I let in the code https://github.com/criteo-cookbooks/ms_dotnet/blob/master/resources/framework.rb#L120, when the detected version is equal to the desired version this method returns false, to ensure chef will check all the packages are installed (prerequisites, packages & patches).
  • this does not mean the resource is not idempotent. If you check the last line of the chef-run's output you copy/past Chef Client finished, 0/26 resources updated in 17 seconds no resource has been updated :)

On the other hand ::Chef::Log.info is printed only if installed_required? returns false; meaning there is clearly nothing to do (.NET 4.6 is installed and you want .NET 4.5).

At last, about the non-desired reboot ... I really don't like it as I implemented it:

  • I would like the package resource to handle the reboot when required (MSI and Installshield returns a different exit code when reboot is required).
  • as you saw, when a reboot is pending for another reason, ms_dotnet_framework will trigger a reboot. This is clearly an idempotency issue, and a behavior I want to fix.

Proposals

The following proposals are not mutually exclusives.

  • Rename the install_required? helper to something clearer, and improve the comments
  • Update the ::Chef::Log.info message to be clearer
  • Implement a reboot solution that only performs reboots when a package is installed

Is it OK for you @jugatsu? :)

Annih added a commit that referenced this issue Apr 29, 2017
The former implementation of the `install_required?` helper was meant
to avoid non-idempotent behavior when a more recent .NET minor version
is already present.

There was ambiguity due to the name of the helper and the value of the
log sent in case it returned `false`.

As discussed in #55, I renamed the helper and reversed the logic to
clarify the behavior. The log message is also updated.
Annih added a commit that referenced this issue Apr 29, 2017
The former implementation of the `install_required?` helper was meant
to avoid non-idempotent behavior when a more recent .NET minor version
is already present.

There was ambiguity due to the name of the helper and the value of the
log sent in case it returned `false`.

As discussed in #55, I renamed the helper and reversed the logic to
clarify the behavior. The log message is also updated.
@jugatsu
Copy link
Contributor Author

jugatsu commented Apr 29, 2017

@Annih I really appreciate your answer.
But my point is that v3.2.0 never hits reboot resource when .Net 4.5.2 was already installed but v3.2.1 does. Even if chef-client reports 0/26 resources

Right now i'm good with setting perform_reboot attribute to false.

@Annih Annih modified the milestone: 4.0.0 May 23, 2017
Annih added a commit that referenced this issue Jun 14, 2017
The ms_dotnet_reboot is not intended to be used by external cookbooks.
It performs reboot on notification only if a reboot is pending.

Fix #55
Annih added a commit that referenced this issue Jun 14, 2017
The ms_dotnet_reboot is not intended to be used by external cookbooks.
It performs reboot on notification only if a reboot is pending.

Fix #55
Annih added a commit that referenced this issue Jun 15, 2017
The ms_dotnet_reboot is not intended to be used by external cookbooks.
It performs reboot on notification only if a reboot is pending.

Fix #55
Annih added a commit that referenced this issue Jun 15, 2017
The ms_dotnet_reboot is not intended to be used by external cookbooks.
It performs reboot on notification only if a reboot is pending.

Fix #55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants