Repository navigation
WIP(openshift builds extension): add Shipwright Build and Shared Res… - #4130
sayan-biswas wants to merge 1 commit into
Conversation
…ource Replace the OpenShiftBuild component with two dedicated components: ShipwrightBuild, reconciled on both Kubernetes and OpenShift, and SharedResource. Add their API types, defaults, validation, lifecycle helpers, reconcilers, generated clients, and CRDs, and wire them into TektonConfig and the platform component lists. Signed-off-by: Sayan Biswas <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4130 +/- ##
==========================================
- Coverage 27.64% 26.01% -1.64%
==========================================
Files 477 520 +43
Lines 25458 27114 +1656
==========================================
+ Hits 7039 7054 +15
- Misses 17696 19336 +1640
- Partials 723 724 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| func IsEnabled(config *v1alpha1.TektonConfig) bool { | ||
| if v1alpha1.IsOpenShiftPlatform() { | ||
| return *config.Spec.Platforms.OpenShift.ShipwrightBuild.Enabled |
There was a problem hiding this comment.
check for nil dereference if config.Spec.Platforms.OpenShift.ShipwrightBuild is nil
There was a problem hiding this comment.
Line 44, the Kubernetes side, has the same problem, and it crashes the operator on a default Kubernetes install.
I deployed this branch to kind with ko and the default Kubernetes overlay. The TektonConfig the operator creates for itself has no shipwrightBuild block. The tekton-operator-lifecycle container restarted twice in 10 minutes with panic: runtime error: invalid memory address or nil pointer dereference at shipwrightbuild.go:44, called from PostReconcile at extension.go:76.
After I set shipwrightBuild.enabled: true, it did not restart again in the next 7 minutes.
| case $version in | ||
| latest) | ||
| dirVersion=$(curl -sL https://api.github.com/repos/$github_component/releases | jq -r ".[].tag_name" | sort -Vr | head -n1) | ||
| dirVersion=$(curl -sL https://api.github.com/repositorys/$github_component/releases | jq -r ".[].tag_name" | sort -Vr | head -n1) |
There was a problem hiding this comment.
why this change ? it will break gh api call
There was a problem hiding this comment.
Same, not intended. Shipwright will need a separate pull mechanism, because there are different file names and more files to pull. Will clean up in final PR.
| ##@ Apply | ||
| .PHONY: apply | ||
| apply: | $(KO) $(KUSTOMIZE) get-releases ; $(info $(M) ko apply on $(TARGET)) @ ## Apply config to the current cluster | ||
| apply: #| $(KO) $(KUSTOMIZE) get-releases ; $(info $(M) ko apply on $(TARGET)) @ ## Apply config to the current cluster |
There was a problem hiding this comment.
#? this is breakin apply command
There was a problem hiding this comment.
This is not intended. Commented for local testing. Will clean up in the final PR.
| return func(ctx context.Context, manifest *manifestival.Manifest, component v1alpha1.TektonComponent) (*manifestival.Manifest, error) { | ||
| sr := component.(*v1alpha1.SharedResource) | ||
| *manifest = manifest.Filter(manifestival.Not(manifestival.ByKind("Namespace"))) | ||
| images := common.ToLowerCaseKeys(common.ImagesFromEnv(common.ShipwrightBuildImagePrefix)) |
There was a problem hiding this comment.
common.ShipwrightBuildImagePrefix ?? isnt it sharedresource here
| multicluster-proxy-aae: | ||
| github: openshift-pipelines/multicluster-proxy-aae | ||
| version: v0.1.1 | ||
| shipwright-build: |
There was a problem hiding this comment.
missing sharedresource component entry ?
| ) | ||
|
|
||
| // FilterAndTransform installs the Builds manifests into the openshift-builds | ||
| // namespace. The upstream operator applies the same InjectNamespace transform; |
There was a problem hiding this comment.
remove openshift-builds namespace, lets have evrything in openshfit-pipelines namespace if possible
|
|
||
| // Package sharedresource installs the Shared Resource component whose desired | ||
| // state is expressed through the SharedResource CRD. It is an OpenShift-only | ||
| // component sourced from the upstream openshift-builds operator. |
There was a problem hiding this comment.
probably not mention legacy openshift-builds operator
| // targetNamespace is the namespace where the OpenShift Builds components are | ||
| // installed. It matches the namespace used by the upstream openshift-builds | ||
| // operator. | ||
| //const targetNamespace = "openshift-builds" |
|
|
||
| func (sr *SharedResource) SetDefaults(ctx context.Context) { | ||
| // Both components default to Enabled when their block is present but the | ||
| // state is unset, mirroring the upstream openshift-builds operator. |
There was a problem hiding this comment.
same here, we need to remove reference to upstream builds operator
|
|
||
| // Ensure Shipwright Build CR | ||
| if shipwrightbuild.IsEnabled(configInstance) { | ||
| if _, err := shipwrightbuild.CreateOrUpdate(ctx, ke.operatorClientSet.OperatorV1alpha1().ShipwrightBuilds(), configInstance, configInstance.Status.Version); err != nil { |
There was a problem hiding this comment.
Please ensure here that function doesnt create tektonconfig (thinking about some code in builds) , the ownership should look like this: TektonConfig (parent) → ShipwrightBuild / SharedResource CRs → InstallerSets → operand
There was a problem hiding this comment.
Right. But I believe that part in the Shipwright Operator, which we have bypassed here and directly deploying controller. I'll check and confirm. this.
| ControllerTektonResults: injection.NamedControllerConstructor{ | ||
| Name: string(ControllerTektonResults), | ||
| ControllerConstructor: k8sResult.NewController}, | ||
| platform.ControllerShipwrightBuild: injection.NamedControllerConstructor{ |
There was a problem hiding this comment.
Neither operator Deployment starts this controller. The -controllers lists in config/kubernetes/base/operator.yaml and config/openshift/base/operator.yaml have no shipwrightbuild or sharedresource.
I deployed this branch to kind with ko and set shipwrightBuild.enabled: true with profile all. The operator created the ShipwrightBuild CR, but nothing reconciled it. Its status stayed empty, and TektonConfig stayed Ready=False with ShipwrightBuild: reconcile again and proceed for 8 minutes.
When I added shipwrightbuild to the Kubernetes list, the controller picked up the CR and installed Shipwright. Could we add it to both lists, and sharedresource to the OpenShift one?
| } | ||
|
|
||
| // Create Post InstallerSet of installing Build Strategies | ||
| if err := r.installerSetClient.PostSet(ctx, sb, r.strategyManifest, NilFilterAndTransform(r)); err != nil { |
There was a problem hiding this comment.
The operator's service account can't install the ClusterBuildStrategies this post set applies, because no role under config/ grants shipwright.io.
On kind, with this branch deployed with ko and shipwrightbuild added to -controllers, the post InstallerSet failed with clusterbuildstrategies.shipwright.io "buildah-shipwright-managed-push" is forbidden: User "system:serviceaccount:tekton-operator:tekton-operator" cannot get resource "clusterbuildstrategies". TektonConfig stayed not ready.
After I bound a ClusterRole for shipwright.io to that account, the ShipwrightBuild CR and TektonConfig were both Ready within 3 minutes. Could the operator's ClusterRole get these rules?
| WebhookSecretName = "shipwright-build-webhook-cert" | ||
| WebhookServiceName = "shp-build-webhook" | ||
| WebhookSecretDuration = 365 * 24 * time.Hour | ||
| WebhookVersionFlag = "-version" |
There was a problem hiding this comment.
The Shipwright webhook reads its flags with pflag, which treats a single dash as a short flag. So -version is read as -v and the pod exits with unknown shorthand flag: 'v' in -version.
On a kind cluster, the operator from this branch left shipwright-build-webhook in CrashLoopBackOff. With --version the pod runs. The OpenShift -tls-min-version and -tls-cipher-suites flags fail the same way (unknown shorthand flag: 't').
Could these use --?
Changes
Replace the OpenShiftBuild component with two dedicated components: ShipwrightBuild, reconciled on both Kubernetes and OpenShift, and SharedResource. Add their API types, defaults, validation, lifecycle helpers, reconcilers, generated clients, and CRDs, and wire them into TektonConfig and the platform component lists.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make test lintbefore submitting a PRSee the contribution guide for more details.
Release Notes