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

(MODULES-3758) Fix: chocolateysource user ensure sync #42

Merged

Conversation

ferventcoder
Copy link

@ferventcoder ferventcoder commented Sep 1, 2016

During the check for insync, user keeps getting detected for synchronize
due to the default value being set to '' as compared to a nil value
being returned from the existing items.

This can cause errors as it could set a source to enabled, even if the
source should be disabled. Instead we should set a default for the
existing item so it matches the default in the user property.

Still needs:

  • acceptance tests
  • ensure when a value is changed for a disabled source that it stays disabled

Fixes for MODULES-3430 have also been included.

@ferventcoder ferventcoder changed the title (MODULES-3758) Fix: chocolateysource user ensure sync {WIP}(MODULES-3758) Fix: chocolateysource user ensure sync Sep 1, 2016
@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3758-user_empty branch 2 times, most recently from 0b23385 to c2c9b82 Compare September 4, 2016 17:02
@ferventcoder
Copy link
Author

Kicked off adhoc for this at https://jenkins-modules.puppetlabs.com/view/3.%20windows%20only/view/ad%20hoc/view/chocolatey/job/forge-windows_puppetlabs-chocolatey_init-manual-parameters_adhoc/23/.

It probably won't pass due to the current failure in the pipeline, but hoping that it doesn't present any new issues.

@ferventcoder ferventcoder changed the title {WIP}(MODULES-3758) Fix: chocolateysource user ensure sync (MODULES-3758) Fix: chocolateysource user ensure sync Sep 4, 2016
@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3758-user_empty branch from c2c9b82 to 641d384 Compare September 6, 2016 18:27
# act
step 'Apply manifest a second time'
apply_manifest(chocolatey_src, :catch_failures => true) do |result|
assert_not_match(/Chocolateysource\[chocolatey\]\/user\: defined 'user' as ''/, result.stdout, "User was adjusted and should not have been")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this error message. "adjust" -> "adjusted"

@ferventcoder ferventcoder changed the title (MODULES-3758) Fix: chocolateysource user ensure sync {WIP}(MODULES-3758) Fix: chocolateysource user ensure sync Sep 6, 2016
During the check for insync, user keeps getting detected for synchronize
due to the default value being set to '' as compared to a nil value
being returned from the existing items.

This can cause errors as it could set a source to enabled, even if the
source should be disabled. Instead we should set a default for the
existing item so it matches the default in the user property.
@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3758-user_empty branch from 641d384 to 44f8bea Compare September 15, 2016 02:56
When validating at the type level, typically all parameters/properties
has been set. The only instance of this not being true is with `puppet
resource`. With puppet resource, values are initially set to their
defaults when validation is called. This means location is sometimes
empty coming from the resource path. When validation runs, the resource
creation has not actually set the properties from the property_hash.
This causes the top-level resource validation to fail.

The resource is created and passed to provider.initialize,
which sets the property_hash differently than when run through the
normal manifest. https://github.com/puppetlabs/puppet/blob/5bb93f0c06cca6cd16f693e9dbaf2066d43a7b6a/lib/puppet/provider.rb#L499-L519

This is due to the call to self.instances resulting in initializing the
instances prior to setting properties - see
https://github.com/puppetlabs/puppet/blob/5bb93f0c06cca6cd16f693e9dbaf2066d43a7b6a/lib/puppet/type.rb#L1179-L1180.
Then it calls initialize still not having set the properties, it runs
validate -
https://github.com/puppetlabs/puppet/blob/5bb93f0c06cca6cd16f693e9dbaf2066d43a7b6a/lib/puppet/type.rb#L2391

This only happens during `puppet resource type` - when running Puppet
normally, it does not run into this issue. This seems to be a small
issue in how puppet resource works with self.instances and validation
at the type level.

Look in multiple places to find the value of `location`.
When flushing values, be sure the value of ensure is found. It may not
be part of what is changing for the flush - it could be another
property. It is imperative to know the value of the ensure, so start
with `property_hash[:ensure]` value, then look at
`property_flush[:ensure]` if it is available.
If ensure is still not found, look at `resource[:ensure]`.

When disabling a source, that source must first exist. Disabling a
source removes two calls to choco, one on the version and another for
adding the source prior to disabling. Unfortunately it doesn't easily
allow bringing on a new machine with the same manifests when wanting to
disable a source that hasn't priorly existed. This is a very slight
edge case. Typically few sources would be disabled, most would
outright be removed.
@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3758-user_empty branch from 44f8bea to edcd94b Compare September 15, 2016 11:23
@ferventcoder ferventcoder changed the title {WIP}(MODULES-3758) Fix: chocolateysource user ensure sync (MODULES-3758) Fix: chocolateysource user ensure sync Sep 15, 2016
@jpogran
Copy link

jpogran commented Sep 15, 2016

👍 verified working

@jpogran jpogran merged commit 684fc9c into puppetlabs:master Sep 15, 2016
@ferventcoder ferventcoder deleted the ticket/master/MODULES-3758-user_empty branch September 15, 2016 16:49
ThoughtCrhyme pushed a commit to ThoughtCrhyme/puppetlabs-chocolatey that referenced this pull request Mar 20, 2017
…5/refactor

(QA-2805) Refactor Code into Python Package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants