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

Add vendor for obs integration #198

Merged
merged 2 commits into from
Oct 7, 2022
Merged

Conversation

davidcassany
Copy link
Contributor

@davidcassany davidcassany commented Oct 6, 2022

These changes are required to facilitate OBS code updates and builds by simply triggering OBS services. This allows updating code and rebuild in OBS based on github events such as on tag, on merge, on push...

As a side effect the vendors folder had to be included as part of the sources. The same happened in rancher/elemental-cli...

Note there are two commits, one for the vendors folder and another one to slightly adapt the helm chart files so they are properly rendered for OBS.

Part of rancher/elemental#361

@davidcassany davidcassany marked this pull request as draft October 6, 2022 11:04
@github-actions github-actions bot added the area/chart Chart related changes label Oct 6, 2022
@kkaempf
Copy link
Contributor

kkaempf commented Oct 6, 2022

5000+ changed files 🙈

@kkaempf
Copy link
Contributor

kkaempf commented Oct 6, 2022

Can't we trigger a service run on OBS instead ?

@Itxaka
Copy link
Contributor

Itxaka commented Oct 6, 2022

1 MILLION LINES!!!

Its gonna take me a bit of time to review the PR......

apiVersion: v2
name: elemental-operator
description: Rancher Elemental Operator
version: 0.0.0
appVersion: 0.0.0
version: 0.0.0-noversion
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a valid helm version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, helm chart requires semver 2 and this is a valid version for semver2. It is a preversion of 0.0.0 😅 Yes I know it is not very nice... in any case having a version 0.0.0 is not much better 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Good enough for me, as long as it's a valid version, nothing will break

@Itxaka
Copy link
Contributor

Itxaka commented Oct 6, 2022

Check failure on line 42 in vendor/github.com/google/go-tpm-tools/simulator/internal/internal_cgo.go
GitHub Actions / build

fatal error: Platform.h: No such file or directory

Oh fuck no. Again with this crap lol, @kkaempf you are the expert in dealing with the go-tpm-tools shenanigans, please advise :P

@Itxaka
Copy link
Contributor

Itxaka commented Oct 6, 2022

I guess building the go-tpm-tools package will now require the proper headers and such? (libssl-dev, libc6-dev)

@davidcassany
Copy link
Contributor Author

5000+ changed files see_no_evil

yes I know... But this is the nature of golang, included in repos or not, this code is all part of the binaries we ship 😱

Can't we trigger a service run on OBS instead ?

Depends if you want automated updates or not, go-modues obs service is not allowed in OBS servers... the alternative is just doing it manually instead of relaying it to some sort of automation. I mean, all this is to allow automatic service trigger on github events. If we assume this is not worth enough we can remove this vendor folder and assume any OBS update for every package will require

osc co <prj> <pkg>
cd <prj>/<pkg>
rm "<pkg>-*.tar.gz"
osc service rundisabled
osc addremove
osc commit

Having this job done manually allows having gaps between OBS and github repos (probably not that bad) and the worst part, IMHO, is that maintaining multiple OBS environments (dev, staging, stable) manually is tedious.

That said manual updates are also a valid alternative, it would affect:

elemental, elemental-toolkit, elemental-operator, elemental-operator-helm and elemental-cli OBS packages

The goal was to enable automated builds in OBS (at least it was on rancher/elemental-cli#266), however this can be revisited. I really do not have a very strong opinion, none of the alternatives is fully satisfying to my eyes. I like automated updates and rebuilds in OBS, however I agree having the vendor folder around sucks.

@kkaempf @Itxaka any further thoughts?

@Itxaka
Copy link
Contributor

Itxaka commented Oct 6, 2022

@kkaempf @Itxaka any further thoughts?

No other than I hate it but I understand it :)

Also check the deps for the build/lint/basically everything that needs to compile the binary environment. This could be problematic as we basically needs the full env to compile a golang package that includes C :/

@davidcassany
Copy link
Contributor Author

Also check the deps for the build/lint/basically everything that needs to compile the binary environment. This could be problematic as we basically needs the full env to compile a golang package that includes C :/

Yes this is pretty annoying from the Makefile perspective, making it work in my env could be relatively simple, but having some sort of generic approach is tricky.

@kkaempf
Copy link
Contributor

kkaempf commented Oct 6, 2022

Oh fuck no. Again with this crap lol, @kkaempf you are the expert in dealing with the go-tpm-tools shenanigans, please advise :P

That's simple. Add another 5000+ files and 1 Million+ lines with go-tpm-tools. 😜

@kkaempf
Copy link
Contributor

kkaempf commented Oct 6, 2022

I mean, all this is to allow automatic service trigger on github events.

Can't we create the vendor tarball in a GH action (on the fly) and upload this ?

@Itxaka
Copy link
Contributor

Itxaka commented Oct 6, 2022

Can't we create the vendor tarball in a GH action (on the fly) and upload this ?

That makes no sense to have in GH if its not used in GH, does it? at least by having the vendor dir in here builds will use that and we can get reproducible builds even and build offline (althougth not much of an issue tbh)

@davidcassany
Copy link
Contributor Author

I mean, all this is to allow automatic service trigger on github events.

Can't we create the vendor tarball in a GH action (on the fly) and upload this ?

For this we need an operative and logged in osc in github runners. Last time I tried this I could not find a way to include the OBS usr and password without storing it in plain text in ~/.config/osc/oscrc. I doubt we want something like that in public github runners 😅

@davidcassany
Copy link
Contributor Author

Oh fuck no. Again with this crap lol, @kkaempf you are the expert in dealing with the go-tpm-tools shenanigans, please advise :P

Found the issue go mod vendor is not compatible with CGO... go mod vendor only pulls golang packages, hence C code is ignored. This has to be included manually, all this could be solved with a make vendor target in Makefile to manually pull all files. It is just a matter of few more files, so this is not the real problem here. The issue is vendor vs no vendor.

Between I noted an inconsistency with OBS and github builds, go.mod asks for go-tpm-tools v0.3.2 and in OBS we included v0.3.8 :/

@kkaempf
Copy link
Contributor

kkaempf commented Oct 6, 2022

Can't we create the vendor tarball in a GH action (on the fly) and upload this ?

That makes no sense to have in GH if its not used in GH, does it?

We're adding the complete (unpacked) vendor tarball in this PR ... just say'in 😉

@Itxaka
Copy link
Contributor

Itxaka commented Oct 6, 2022

We're adding the complete (unpacked) vendor tarball in this PR ... just say'in wink

Sure but that kind of works for github builds as well. But a fat tar.gz is useless in this context :D

@github-actions github-actions bot added area/build build related changes area/tests test related changes labels Oct 6, 2022
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Base: 39.70% // Head: 39.70% // No change to project coverage 👍

Coverage data is based on head (8daa391) compared to base (0253a89).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #198   +/-   ##
=======================================
  Coverage   39.70%   39.70%           
=======================================
  Files          10       10           
  Lines         889      889           
=======================================
  Hits          353      353           
  Misses        510      510           
  Partials       26       26           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

# SPDX-License-Identifier: Apache-2.0
#!BuildTag: elemental/elemental-operator:latest
#!BuildTag: elemental/elemental-operator:0.0.0-noversion
#!BuildTag: elemental/elemental-operator:0.0.0-noversion-build%RELEASE%
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed for OBS to support multiple tags

version: 0.0.0
appVersion: 0.0.0
version: 0.0.0-noversion
appVersion: 0.0.0-noversion
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is done because the 0.0.0-noversion is used a needle in a regex for replacement at build time in OBS, using 0.0.0 alone is not safe as there could be other occurrences of this such a simple string.

.PHONY: vendor
vendor:
go mod vendor
curl -L 'https://github.com/google/go-tpm-tools/archive/refs/tags/$(GO_TPM_TAG).tar.gz' --output go-tpm-tools.tar.gz
Copy link
Contributor Author

Choose a reason for hiding this comment

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

go mod vendor does not include CGO code, hence we need to get source tarball manually and include it. So in order to properly build a functional vendor folder make vendor is required.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about about having a git submodule for the go-tpm-tools inside the vendor dir? Would that work or does the go mod vendor overwrite it?

I know we can replace the module in the go.mod to point to a local sir, so that would avoid having to download the tar on the makefile which is a bit yuck

Copy link
Contributor

Choose a reason for hiding this comment

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

Damn, this crap has been going on for 4 years! golang/go#26366

There is a couple of simple fixes but those need to go upstream.. I will check tonigth to see if there is a saner way to get this proper

Copy link
Contributor Author

@davidcassany davidcassany Oct 6, 2022

Choose a reason for hiding this comment

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

Damn, this crap has been going on for 4 years! golang/go#26366

lol, I've been there too 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦🏻‍♂️

@davidcassany
Copy link
Contributor Author

Note after merging this PR isv:Rancher:Elemental/elemental-operator OBS package cannot be build from sources any more

This commit sets repository and version well known values in
Chart.yaml and values.yaml files so they can be dynamically replaced by some
sort of automation at build time.

Signed-off-by: David Cassany <[email protected]>
@davidcassany davidcassany enabled auto-merge (squash) October 7, 2022 14:13
@davidcassany davidcassany merged commit 1af1d07 into main Oct 7, 2022
@davidcassany davidcassany deleted the add_vendor_for_obs_integration branch October 7, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build build related changes area/chart Chart related changes area/tests test related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants