Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

kfctl mirror should recourse over dependencies #342

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

jlewi
Copy link
Contributor

@jlewi jlewi commented Jun 1, 2020

kfctl mirror should recourse over dependencies

  • The current implementation of kfctl mirror was not looking
    at dependent packages that were out of tree. This change
    causes the mirror command to look at the resources directive
    inside the kustomization.yaml and follow those links.

    • This is necessary to support blueprints and some of the refactoring
      of the kustomize manifests intended to better support Day 2 operations.
  • Fix kfctl mirror images should not hardcode the kustomize directory #340 kfctl mirror shouldn't hard code the directory to search
    for images but instead allow it to be provided via a flag.

@kubeflow-bot
Copy link

This change is Reviewable

@jlewi
Copy link
Contributor Author

jlewi commented Jun 1, 2020

/assign @yanniszark

@jlewi
Copy link
Contributor Author

jlewi commented Jun 2, 2020

Actually it looks like we can parameterize the functions:
https://googlecontainertools.github.io/kpt/reference/fn/run/

So we shouldn't actually need to add annotations to all the objects we can just add an appropriate parameter to the function.

@jlewi
Copy link
Contributor Author

jlewi commented Jun 2, 2020

/hold

I'm going to split this up into two PRs

  1. PR to add flags to the mirror command
  2. PR to add transforms to replace image prefixes.

@jlewi jlewi changed the title kustomize fn to transform images; kfctl mirror should recourse over dependencies [WIP] kustomize fn to transform images; kfctl mirror should recourse over dependencies Jun 2, 2020
@jlewi jlewi changed the title [WIP] kustomize fn to transform images; kfctl mirror should recourse over dependencies kfctl mirror should recourse over dependencies Jun 2, 2020
@jlewi
Copy link
Contributor Author

jlewi commented Jun 2, 2020

@yanniszark this is ready for review. I scoped down the PR as mentioned in my earlier comment.

@jlewi
Copy link
Contributor Author

jlewi commented Jun 2, 2020

/hold cancel

@jlewi
Copy link
Contributor Author

jlewi commented Jun 2, 2020

/test all

@yanniszark
Copy link
Contributor

@jlewi thanks a lot for taking the time to improve kfctl.
Unfortunately, I don't have the cycles right now to review this PR and I don't want to be the one blocking it.
It would be very helpful if another community member could take up the review of this PR.

@jlewi
Copy link
Contributor Author

jlewi commented Jun 3, 2020

/assign @Tomcli

@Tomcli Could you review this please?

/unassign @yanniszark

@jlewi
Copy link
Contributor Author

jlewi commented Jun 9, 2020

/assign @adrian555 Could you PTAL?

@jlewi
Copy link
Contributor Author

jlewi commented Jun 9, 2020

/assign @pdmack

Copy link
Member

@adrian555 adrian555 left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 11 files at r1, 3 of 3 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jlewi and @Tomcli)


pkg/mirror/mirror_image.go, line 210 at r2 (raw file):

		}

		p := path.Join(absPath, r)

maybe check whether r is a filepath first?


pkg/mirror/mirror_image.go, line 215 at r2 (raw file):

			log.Errorf("Error occurred while processing %v; error %v", p, err)
		}
	}

According to kustomize definition of resources, it can include file, path and uri. This code does not handle uri case. And the file can be json too. Fine if they are not possible/expected in Kubeflow scenario. But maybe better add a comment here.


pkg/utils/diff.go, line 65 at r2 (raw file):

	}
	return "X"
}

Have seen this code a couple of places. Wondering if somehow they can be put in a common package to be shared.

@adrian555
Copy link
Member

@jlewi sorry for the delay, reviewed above. Thanks.

Copy link
Contributor Author

@jlewi jlewi left a comment

Choose a reason for hiding this comment

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

Reviewable status: 10 of 12 files reviewed, 3 unresolved discussions (waiting on @adrian555 and @Tomcli)


pkg/mirror/mirror_image.go, line 210 at r2 (raw file):

Previously, adrian555 (Adrian Zhuang) wrote…

maybe check whether r is a filepath first?

Good catch


pkg/mirror/mirror_image.go, line 215 at r2 (raw file):

Previously, adrian555 (Adrian Zhuang) wrote…

According to kustomize definition of resources, it can include file, path and uri. This code does not handle uri case. And the file can be json too. Fine if they are not possible/expected in Kubeflow scenario. But maybe better add a comment here.

Checked if its remote


pkg/utils/diff.go, line 65 at r2 (raw file):

Previously, adrian555 (Adrian Zhuang) wrote…

Have seen this code a couple of places. Wondering if somehow they can be put in a common package to be shared.

I think that's a good idea long term and added a TODO. Its a bit of work to refactor it into its own go module. I don't think we would want to reuse it without putting it in its own go module. Right now we would pull in all the dependencies for kfctl which slows down builds of very simple utilities. So in many cases it can be easier to just copy paste.

Copy link
Member

@adrian555 adrian555 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jlewi and @Tomcli)


pkg/mirror/mirror_image.go, line 213 at r3 (raw file):

		p := path.Join(absPath, r)

		if b, err :=utils.IsRemoteFile(p); b || err != nil {

add space after :=

Copy link
Member

@adrian555 adrian555 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @jlewi and @Tomcli)


pkg/mirror/mirror_image.go, line 230 at r3 (raw file):

		p := path.Join(absPath, r)

		if b, err :=utils.IsRemoteFile(p); b || err != nil {

add space after :=

@jlewi
Copy link
Contributor Author

jlewi commented Jun 11, 2020

Thanks @adrian555

I ran go fmt.
I believe there are issues open to do this as part of presubmits.

* The current implementation of kfctl mirror was not looking
  at dependent packages that were out of tree. This change
  causes the mirror command to look at the resources directive
  inside the kustomization.yaml and follow those links.

  * This is necessary to support blueprints and some of the refactoring
    of the kustomize manifests intended to better support Day 2 operations.

* Fix kubeflow#340 kfctl mirror shouldn't hard code the directory to search
  for images but instead allow it to be provided via a flag.

* mirror pipelines should only apply the exclude prefix if it is the
  non empty string.
  * exclude will be empty if we want to match all images.

* On error print stack trace to help locate source of error.

  * If filename is empty throw an error as well.

* kfctl mirror needs to check bases as well.
@adrian555
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrian555

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 merged commit 7be0541 into kubeflow:master Jun 12, 2020
vpavlin pushed a commit to vpavlin/kfctl that referenced this pull request Jul 10, 2020
* The current implementation of kfctl mirror was not looking
  at dependent packages that were out of tree. This change
  causes the mirror command to look at the resources directive
  inside the kustomization.yaml and follow those links.

  * This is necessary to support blueprints and some of the refactoring
    of the kustomize manifests intended to better support Day 2 operations.

* Fix kubeflow#340 kfctl mirror shouldn't hard code the directory to search
  for images but instead allow it to be provided via a flag.

* mirror pipelines should only apply the exclude prefix if it is the
  non empty string.
  * exclude will be empty if we want to match all images.

* On error print stack trace to help locate source of error.

  * If filename is empty throw an error as well.

* kfctl mirror needs to check bases as well.
vpavlin pushed a commit to vpavlin/kfctl that referenced this pull request Jul 20, 2020
* The current implementation of kfctl mirror was not looking
  at dependent packages that were out of tree. This change
  causes the mirror command to look at the resources directive
  inside the kustomization.yaml and follow those links.

  * This is necessary to support blueprints and some of the refactoring
    of the kustomize manifests intended to better support Day 2 operations.

* Fix kubeflow#340 kfctl mirror shouldn't hard code the directory to search
  for images but instead allow it to be provided via a flag.

* mirror pipelines should only apply the exclude prefix if it is the
  non empty string.
  * exclude will be empty if we want to match all images.

* On error print stack trace to help locate source of error.

  * If filename is empty throw an error as well.

* kfctl mirror needs to check bases as well.
vpavlin pushed a commit to vpavlin/kfctl that referenced this pull request Jul 22, 2020
* The current implementation of kfctl mirror was not looking
  at dependent packages that were out of tree. This change
  causes the mirror command to look at the resources directive
  inside the kustomization.yaml and follow those links.

  * This is necessary to support blueprints and some of the refactoring
    of the kustomize manifests intended to better support Day 2 operations.

* Fix kubeflow#340 kfctl mirror shouldn't hard code the directory to search
  for images but instead allow it to be provided via a flag.

* mirror pipelines should only apply the exclude prefix if it is the
  non empty string.
  * exclude will be empty if we want to match all images.

* On error print stack trace to help locate source of error.

  * If filename is empty throw an error as well.

* kfctl mirror needs to check bases as well.
vpavlin pushed a commit to vpavlin/kfctl that referenced this pull request Jul 22, 2020
* The current implementation of kfctl mirror was not looking
  at dependent packages that were out of tree. This change
  causes the mirror command to look at the resources directive
  inside the kustomization.yaml and follow those links.

  * This is necessary to support blueprints and some of the refactoring
    of the kustomize manifests intended to better support Day 2 operations.

* Fix kubeflow#340 kfctl mirror shouldn't hard code the directory to search
  for images but instead allow it to be provided via a flag.

* mirror pipelines should only apply the exclude prefix if it is the
  non empty string.
  * exclude will be empty if we want to match all images.

* On error print stack trace to help locate source of error.

  * If filename is empty throw an error as well.

* kfctl mirror needs to check bases as well.
crobby pushed a commit to crobby/kfctl that referenced this pull request Feb 25, 2021
* The current implementation of kfctl mirror was not looking
  at dependent packages that were out of tree. This change
  causes the mirror command to look at the resources directive
  inside the kustomization.yaml and follow those links.

  * This is necessary to support blueprints and some of the refactoring
    of the kustomize manifests intended to better support Day 2 operations.

* Fix kubeflow#340 kfctl mirror shouldn't hard code the directory to search
  for images but instead allow it to be provided via a flag.

* mirror pipelines should only apply the exclude prefix if it is the
  non empty string.
  * exclude will be empty if we want to match all images.

* On error print stack trace to help locate source of error.

  * If filename is empty throw an error as well.

* kfctl mirror needs to check bases as well.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kfctl mirror images should not hardcode the kustomize directory
7 participants