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

The version of the function is wrong when publishing with the specified function tag. #505

Open
Bryce-huang opened this issue Oct 26, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@Bryce-huang
Copy link
Contributor

Description
A clear and concise description of what the bug is.
Specify the image tag when publishing the function. The actual function version will always be the previous version built based on the source code.
Environmental
Tell us what your cluster environment is like, e.g.

  • Operating System Information linux
  • kubernetes version v1.24
  • OpenFunction version v1.10
  • knative 1.10

Expected behavior
Tell us what should happen.
The right version wil run in serving.

Actual behavior

The actual function version will always be the previous version built based on the source code.

To Reproduce
Steps to reproduce the behavior:

  1. Build function version 1 from source code
  2. Access function,It return version 1
  3. Specify image tag to function with version 2
  4. Access function,it will return version 1

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@Bryce-huang Bryce-huang added the bug Something isn't working label Oct 26, 2023
@benjaminhuo
Copy link
Member

This happens on the version you built by yourself including this PR #490 ?

@Bryce-huang
Copy link
Contributor Author

This happens on the version you built by yourself including this PR #490 ?

Yes, but it doesn't matter.

func getServingImage(fn *openfunction.Function) string {
	if fn.Status.Revision == nil ||
		fn.Status.Revision.ImageDigest == "" {
		return fn.Spec.Image
	}

	array := strings.Split(fn.Spec.Image, "@")
	repo := fn.Spec.Image
	if len(array) > 1 {
		repo = array[0]
	}

	return repo + "@" + fn.Status.Revision.ImageDigest
}

@Bryce-huang
Copy link
Contributor Author

When the build is skiped, the Revision.ImageDigest still exist。

@Bryce-huang
Copy link
Contributor Author

This problem will not occur if you specify the tag alone or use the source code to build alone.

@Bryce-huang
Copy link
Contributor Author

Would it be better to not include the Revision.ImageDigest when calculating the serving hash?

func (r *FunctionReconciler) createServingSpec(fn *openfunction.Function) openfunction.ServingSpec {
	if fn.Spec.Serving == nil {
		return openfunction.ServingSpec{}
	}

	spec := openfunction.ServingSpec{
		Version:          fn.Spec.Version,
		Image:            getServingImage(fn),
		ImageCredentials: fn.Spec.ImageCredentials,
		ServingImpl:      *fn.Spec.Serving.DeepCopy(),
	}

	return spec
}
util.Hash(servingSpec)

Bryce-huang added a commit to Bryce-huang/OpenFunction that referenced this issue Oct 26, 2023
Signed-off-by: Bryce-Huang <44901318+Bryce-huang@users.noreply.github.com>
@benjaminhuo
Copy link
Member

Would it be better to not include the Revision.ImageDigest when calculating the serving hash?

func (r *FunctionReconciler) createServingSpec(fn *openfunction.Function) openfunction.ServingSpec {
	if fn.Spec.Serving == nil {
		return openfunction.ServingSpec{}
	}

	spec := openfunction.ServingSpec{
		Version:          fn.Spec.Version,
		Image:            getServingImage(fn),
		ImageCredentials: fn.Spec.ImageCredentials,
		ServingImpl:      *fn.Spec.Serving.DeepCopy(),
	}

	return spec
}
util.Hash(servingSpec)

@wanjunlei @wrongerror what do you think?

@wanjunlei
Copy link
Member

I think the best solution is to clean up the revision when the image changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants