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

Remove Legacy Facts #266

Merged
merged 3 commits into from
Jun 10, 2024
Merged

Remove Legacy Facts #266

merged 3 commits into from
Jun 10, 2024

Conversation

smortex
Copy link
Member

@smortex smortex commented Mar 13, 2023

Puppet 8 defaults to not providing Legacy Facts 1. In order for our
tests to be relevant, we should not provide these facts. We also had
special instructions to ask contributors to add these legacy facts which
are now obsolete.

As a baseline, do not provide any legacy facts. Adjust references to
legacy fact to use non deprecated and still relevant ones in CI, and
provide a script that can asists us in updating the existing factsets.

@smortex smortex marked this pull request as ready for review March 13, 2023 22:48
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Due to its size this is hard to review. Would it make sense to have a commit that removes Facter < 3?

I also wonder if Facter 3 had all the non-legacy facts.

I'd even consider dropping all Facter < 3.14.

@ekohl
Copy link
Member

ekohl commented Mar 13, 2023

I now see you have a commit that does that. It's a bit tricky to see.

Something I do miss is the change to facterdb/get_facts.sh to drop --show-legacy.

@smortex
Copy link
Member Author

smortex commented Mar 14, 2023

Something I do miss is the change to facterdb/get_facts.sh to drop --show-legacy.

Good catch, it looks like I git checkout -- . before committing it 🤦 Fixed!

@alexjfisher
Copy link
Member

Would something in rspec-puppet-facts be better? Like some sort of configurable that would remove the legacy facts??

@alexjfisher
Copy link
Member

It's only a default in Puppet 8 to not have legacy facts. Presumably some people will be happy to turn them back on, so I think I'd prefer if this was done elsewhere if possible???

@alexjfisher
Copy link
Member

I'm thinking something like...

RSpec.configure do |c|
  c.legacy_facts = false
end

(or we could default to false but people could set to true if they want legacy facts).

@alexjfisher
Copy link
Member

In here somewhere??? https://github.com/voxpupuli/rspec-puppet-facts/blob/1418bca958049060a77dd49f10a9a298d15dc438/lib/rspec-puppet-facts.rb#L172-L173

[RspecPuppetFacts.legacy_facts].each { |fact| facts.delete(fact) } unless opts[:legacy_facts])

@ekohl
Copy link
Member

ekohl commented Mar 14, 2023

When I was thinking about this problem I actually thought of creating 2 fact sets: one with and one without legacy facts. Then in RspecPuppetFacts you would create an option to select either one or the other.

My biggest worry was performance, given it's already rather slow due to its size. Nowadays it's mitigated by having a cache, but it's still slow.

So what I'd consider is making it a completely new fact set that's only available opt-in.

Any thoughts on that?

@alexjfisher
Copy link
Member

I thought it was probably easier to conditionally just drop the keys that are legacy facts? It's a published fixed list that isn't about to change.

@ekohl
Copy link
Member

ekohl commented Mar 14, 2023

While that's true, I'm a bit hesitant in generating data while in my head the aim of this is to represent what the real code does.

@alexjfisher
Copy link
Member

I thought it was probably easier to conditionally just drop the keys that are legacy facts? It's a published fixed list that isn't about to change.

Actually it's a little bit more involved. There are some legacy facts that are dynamically generated, eg. https://www.puppet.com/docs/puppet/7/core_facts.html#ipaddress-interface etc.

@alexjfisher
Copy link
Member

Also worth bearing in mind that rspec-puppet-facts currently searches facterdb based on legacy facts. https://github.com/voxpupuli/rspec-puppet-facts/blob/master/lib/rspec-puppet-facts.rb would need a complete overhaul before dropping legacy facts here.

@alexjfisher
Copy link
Member

Something like this perhaps?? voxpupuli/rspec-puppet-facts#143

@yakatz yakatz force-pushed the remove-legacy-facts branch 2 times, most recently from 24d6302 to 1e2cc2a Compare May 16, 2024 21:49
@yakatz
Copy link
Member

yakatz commented May 16, 2024

That's weird - I thought I pushed to my fork - how does it show up here?

yakatz:~/local_git/puppet/modules/facterdb (remove-legacy-facts $=)$ git remote -v
origin  [email protected]:yakatz/facterdb.git (fetch)
origin  [email protected]:yakatz/facterdb.git (push)
yakatz:~/local_git/puppet/modules/facterdb (remove-legacy-facts $=)$

EDIT: I figured out the git client "magic" that made this happen and I will make sure it doesn't happen again.

@yakatz yakatz force-pushed the remove-legacy-facts branch 2 times, most recently from e43e75e to b7d2e17 Compare May 16, 2024 22:01
@yakatz
Copy link
Member

yakatz commented May 16, 2024

Due to its size this is hard to review. Would it make sense to have a commit that removes Facter < 3?

I also wonder if Facter 3 had all the non-legacy facts.

I'd even consider dropping all Facter < 3.14.

Since I accidentally rebased this, it should be easier to read now.

@bastelfreak
Copy link
Member

proposal: the next major release drops support for facter 3 and older and some EoL OS. For the major release after that should we update get_facts.sh to remove all the legacy facts? Or should we do this already in the next major? puppet-lint has a plugin for legacy facts since some time now that's rolled out by default in PDK and at Vox Pupuli. I'm fine with dropping the legacy facts already.

@ekohl
Copy link
Member

ekohl commented May 17, 2024

I think deprecating it in the next major and removing it the major after that can make sense, depending on the timeline.

Do we know when Puppet 7 is going EOL? While not strictly tied to it, it makes sense to me.

@bastelfreak
Copy link
Member

Puppet 7 lifecycle is related to the PE lifecycle: https://www.puppet.com/products/puppet-enterprise/support-lifecycle

PE 2021 contains Puppet 7:

Mainstream Support through August 31, 2024. Overlap Support through February 28, 2025.

@bastelfreak
Copy link
Member

I suggest wo do a major release now and mention in the README.md that legacy facts are deprecated and will be removed in the next major release. And when Puppet 7 is EoL we do another major release without legacy facts.

@TheMeier
Copy link
Contributor

As someone who has the server infrastructure provided by another team in our org, it's to early for me now :(
But I do agree on this proposal #266 (comment)

@bastelfreak
Copy link
Member

As someone who has the server infrastructure provided by another team in our org,

how does that relate to this change? Do they also provide puppet code with legacy facts?

@TheMeier
Copy link
Contributor

sadly yes. But mostly I don't know when I will be able to switch to puppet 8

@bastelfreak
Copy link
Member

Keep in mind that the legacy facts are legacy since Puppet 5 or 6 and since that time the new ones are available. Just puppet 8 finally disables the legacy facts by default (but you can reenable them).

@bastelfreak
Copy link
Member

I don't think anyone actually deprecated them

We (Vox Pupuli) did that a long time ago and so does the pdk since some time.

@yakatz
Copy link
Member

yakatz commented May 17, 2024

The longer this sits, the more I think it should be two separate PRs - one to remove the code to generate the legacy facts and a separate one after that one is merged that actually removes the factsets. That will make this easier to merge. Any objections?

@bastelfreak
Copy link
Member

We made the 2.0.0 release that announced the legacy fact deprecation. I think we can now tackle this and work on the 3.0.0 release which removes the lagacy facts.

@david22swan
Copy link

Just speaking from my own opinion, I think this is a good change to get in.
Anyone that is still using Legacy Facts shouldn't be as they are no longer supported within the latest Puppet.

@bastelfreak
Copy link
Member

@smortex do you have a chance to rebase/redo this PR? I would like to then merge it.

@smortex smortex force-pushed the remove-legacy-facts branch 2 times, most recently from 8877cb0 to 6184373 Compare June 9, 2024 20:19
@smortex
Copy link
Member Author

smortex commented Jun 9, 2024

@smortex do you have a chance to rebase/redo this PR? I would like to then merge it.

Luckily I had the original branch and could cherry-pick / adjust / regenerate / skip commits 😁.

selinux_enforced
selinux_policyversion
serialnumber
sp_boot_mode
Copy link
Member

Choose a reason for hiding this comment

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

okay I've never seen those sp_* facts before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hehe, me neither! Looks like sp stand for system_profiler and is something related to MaxOSX 🤷

Copy link
Member

Choose a reason for hiding this comment

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

jep, its macOS stuff... its now collected as system_profiler structured fact.

Comment on lines 121 to 126
# those are used in newer rspec-puppet-facts versions
# by ensuring those facts exists, we can drop a huge amount of logic in rspec-puppet-facts
it 'contains the mandatory OS facts' do
expect(content['os']['release']['major']).to not_be_nil.and not_be_empty
expect(content['os']['name']).to not_be_nil.and not_be_empty
expect(content['os']['hardware']).to not_be_nil.and not_be_empty
Copy link
Member

Choose a reason for hiding this comment

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

can you maybe keep those checks? we rely on those in rspec-puppet-facts and assume they exist. And there were situations in the past where factsets were provided for operating systems that aren't 100% supported and those facts were missing or null.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, I think that the initial code was looking for the legacy facts, and after rebasing I misread the conflicts that changed them to os.xxx facts and removed them by mistake.

Reintroduced, but I kept the check that ensure legacy facts are not found.

@smortex smortex force-pushed the remove-legacy-facts branch from 6184373 to 513e70e Compare June 9, 2024 20:54
selinux_enforced
selinux_policyversion
serialnumber
sp_boot_mode
Copy link
Member

Choose a reason for hiding this comment

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

jep, its macOS stuff... its now collected as system_profiler structured fact.

facts/4.0/almalinux-8-x86_64.facts Show resolved Hide resolved
smortex added 3 commits June 10, 2024 03:24
Puppet 8 defaults to not providing Legacy Facts [1].  In order for our
tests to be relevant, we should not provide these facts.  We also had
special instructions to ask contributors to add these legacy facts which
are now obsolete.

As a baseline, do not provide any legacy facts.  Adjust references to
legacy fact to use non deprecated and still relevant ones in CI, and
provide a script that can asists us in updating the existing factsets.

[1]: https://github.com/puppetlabs/puppet/wiki/Puppet-8-Compatibility#legacy-facts
This is the result of:
```
bundle exec bin/legacy-facts-striper facts/*/*.facts
```
Remove the `--show-legacy` option and prefer long options to the short
ones.
@smortex smortex force-pushed the remove-legacy-facts branch from 513e70e to f38c29a Compare June 10, 2024 13:25
@smortex smortex requested review from rwaffen and bastelfreak June 10, 2024 13:28
@bastelfreak bastelfreak merged commit 1a3dad5 into master Jun 10, 2024
7 checks passed
@bastelfreak bastelfreak deleted the remove-legacy-facts branch June 10, 2024 15:33
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