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

Moving Build Dockerfile to be defined in the ConfigMap #160

Merged

Conversation

yevgeny-shnaidman
Copy link
Contributor

Currently dockerfile is defined a multiline string in the Build field of the KernelMapping. This PR does the following: 1) dockerfile is now defined in a dedicated configmap (created by customer)
with the key being: dockerfile
2) Build struct now contains reference to the ConfigMap, instead of
a string
3) change the flow of e2e workflow for the in-cluster build
to use the new configuration

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yevgeny-shnaidman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2022
@yevgeny-shnaidman
Copy link
Contributor Author

/assign @qbarrand
/assign @ybettan
/assign @mresvanis

@k8s-ci-robot
Copy link
Contributor

@yevgeny-shnaidman: GitHub didn't allow me to assign the following users: mresvanis.

Note that only kubernetes-sigs members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @qbarrand
/assign @ybettan
/assign @mresvanis

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@yevgeny-shnaidman
Copy link
Contributor Author

/cc @mresvanis

@k8s-ci-robot
Copy link
Contributor

@yevgeny-shnaidman: GitHub didn't allow me to request PR reviews from the following users: mresvanis.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @mresvanis

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2022

Codecov Report

Base: 71.86% // Head: 71.60% // Decreases project coverage by -0.26% ⚠️

Coverage data is based on head (3fe00c9) compared to base (351def7).
Patch coverage: 44.44% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #160      +/-   ##
==========================================
- Coverage   71.86%   71.60%   -0.27%     
==========================================
  Files          25       25              
  Lines        2417     2437      +20     
==========================================
+ Hits         1737     1745       +8     
- Misses        597      605       +8     
- Partials       83       87       +4     
Impacted Files Coverage Δ
controllers/module_reconciler.go 67.69% <ø> (ø)
internal/build/helper.go 0.00% <0.00%> (ø)
main.go 3.87% <0.00%> (ø)
internal/build/job/maker.go 87.30% <47.82%> (-5.60%) ⬇️
internal/build/job/manager.go 78.46% <100.00%> (ø)

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.

@qbarrand
Copy link
Contributor

Fixes #115

@@ -60,7 +60,8 @@ type Build struct {
// BuildArgs is an array of build variables that are provided to the image building backend.
BuildArgs []BuildArg `json:"buildArgs"`

Dockerfile string `json:"dockerfile"`
// ConfigMap that holds Dockerfile contents
DockerfileRef *v1.LocalObjectReference `json:"dockerfileRef"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will cause an issue:
Change to the config map won't trigger a reconcile.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yevgeny-shnaidman can we leave Dockerfile as an option? It has the benefit of not breaking the API, which requires a version bump and a conversion webhook...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't want to be triggered by ConfigMap. If the image is already build, then we won't run the Build flow again, and if the build has failed, then the reconcile will be triggered by us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@qbarrand i think that it cause our code to become confusing: we will need to support both option, decide which one to take, which one to replace, we will also have the same issue in kaniko configuration. Since we have not released the official API yet, maybe it is better to change it and not to support all the options just in order to avoid conversion hooks?

Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT about having both fields and failing the reconciliation? When we implement the validating webhook, we can add that check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see the reason to support both options, it is just confusing, both to us and to the customer. Anyway you will have to support both options in the code, which adds to the confusion. Why are you worried about conversion webhook? I think that at this stage we can just tell customers to move to new version and change their code, i think that any customer we have right now is at very starting stage

Copy link
Contributor

Choose a reason for hiding this comment

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

If we are already breaking the API. Do you have any objection to have that one as well without a conversion webhook?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you good with that, @qbarrand ?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK to remove the field per @bthurber's decision.
How about changing the new field name to DockerfileConfigMap?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we are already breaking the API then let's merge this one as well #86.

@@ -60,7 +60,8 @@ type Build struct {
// BuildArgs is an array of build variables that are provided to the image building backend.
BuildArgs []BuildArg `json:"buildArgs"`

Dockerfile string `json:"dockerfile"`
// ConfigMap that holds Dockerfile contents
DockerfileRef *v1.LocalObjectReference `json:"dockerfileRef"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@yevgeny-shnaidman can we leave Dockerfile as an option? It has the benefit of not breaking the API, which requires a version bump and a conversion webhook...

controllers/module_reconciler.go Show resolved Hide resolved
Comment on lines 114 to 121
dockefileData, err := m.getDockerfileContents(ctx, buildConfig, mod.Namespace)
if err != nil {
return nil, fmt.Errorf("failed to get dockerfile contents: %v", err)
}
specTemplate := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"Dockerfile": buildConfig.Dockerfile},
Annotations: map[string]string{"Dockerfile": dockefileData},
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather mount the ConfigMap into the pod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will check if kaniko supports that option

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

Choose a reason for hiding this comment

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

@yevgeny-shnaidman I believe we only need to change the volume there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Please review the changes:

  1. new Volume definition\
  2. new hash calculation
  3. changed build config pickup implementation

@yevgeny-shnaidman yevgeny-shnaidman force-pushed the yevgeny/ISSUE-115 branch 7 times, most recently from b671cd8 to 7bc6abf Compare November 23, 2022 14:12
config/manager/kustomization.yaml Outdated Show resolved Hide resolved
internal/build/helper.go Outdated Show resolved Hide resolved
internal/build/helper.go Outdated Show resolved Hide resolved
internal/build/helper.go Outdated Show resolved Hide resolved
internal/build/job/maker.go Outdated Show resolved Hide resolved
internal/build/job/maker.go Outdated Show resolved Hide resolved
Currently dockerfile is defined a multiline string in the Build
field of the KernelMapping. This PR does the following:
1) dockerfile is now defined in a dedicated configmap (created by customer)
   with the key being: dockerfile
2) Build struct now contains reference to the ConfigMap, instead of
   a string
3) change the flow of e2e workflow for the in-cluster build
   to use the new configuration
@qbarrand
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 24, 2022
@k8s-ci-robot k8s-ci-robot merged commit a3d7e28 into kubernetes-sigs:main Nov 24, 2022
qbarrand added a commit to qbarrand/kernel-module-management that referenced this pull request Jun 2, 2023
…rnetes-sigs#160)

This change renames the
`config/manifests/bases/kmm-operator.clusterserviceversion.yaml` file
to `kernel-module-management.clusterserviceversion.yaml`, in order to
fix `make bundle`. The file name must match the `projectName` defined
in the `PROJECT` file, or `operator generate kustomize manifests -q`
will not find it and ask all the questions to generate it.

This change also update some tools to their latest versions:
- update golangci-lint
- update controller-gen
- update kustomize
- update OPM, to include file based catalog creation
https://olm.operatorframework.io/docs/reference/file-based-catalogs/#design

Signed-off-by: Fabien Dupont <fdupont@redhat.com>

Signed-off-by: Fabien Dupont <fdupont@redhat.com>

Upstream-Commit: 25abfb1

Co-authored-by: Fabien Dupont <fdupont@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants