Skip to content

Fix fission-cli cmd pkg getdeploy #2960

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

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Fix fission-cli cmd pkg getdeploy #2960

merged 1 commit into from
Jun 20, 2024

Conversation

soharab-ic
Copy link
Contributor

@soharab-ic soharab-ic commented Jun 19, 2024

Description

If the deployment archive is not available in package resource then we see below error. Deployment archive is not available if package is being built or in failed state.
This PR resolve this issue by returning the source archive if deployment archive is not available.

$ fission pkg getdeploy --name hello-6492eb75-0f4e-4916-a47a-2b94a4deeb58
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4b097e]

goroutine 1 [running]:
io.copyBuffer({0x29d8180, 0xc000117488}, {0x0, 0x0}, {0x0, 0x0, 0x0})
	/usr/local/go/src/io/io.go:429 +0x17e
io.Copy(...)
	/usr/local/go/src/io/io.go:388
os.genericReadFrom(0xc000090028?, {0x0, 0x0})
	/usr/local/go/src/os/file.go:179 +0x58
os.(*File).ReadFrom(0xc000090028, {0x0, 0x0})
	/usr/local/go/src/os/file.go:155 +0x9c
io.copyBuffer({0x29d8200, 0xc000090028}, {0x0, 0x0}, {0x0, 0x0, 0x0})
	/usr/local/go/src/io/io.go:415 +0x151
io.Copy(...)
	/usr/local/go/src/io/io.go:388
github.com/fission/fission/pkg/fission-cli/cmd/package.(*GetSubCommand).run(0xc000557c08, {0x2a0faf0, 0xc000154660})
	pkg/fission-cli/cmd/package/get.go:102 +0x545
github.com/fission/fission/pkg/fission-cli/cmd/package.(*GetSubCommand).do(0xc000557c08, {0x2a0faf0, 0xc000154660})
	pkg/fission-cli/cmd/package/get.go:60 +0x45
github.com/fission/fission/pkg/fission-cli/cmd/package.GetDeploy({0x2a0faf0?, 0xc000154660?})
	pkg/fission-cli/cmd/package/get.go:52 +0x55
github.com/fission/fission/pkg/fission-cli/cmd/package.Commands.Wrapper.func3(0xc0003b4d00?, {0xc0003b0b80?, 0x4?, 0x24327e3?})
	pkg/fission-cli/cliwrapper/driver/cobra/cobra.go:51 +0x62
github.com/spf13/cobra.(*Command).execute(0xc000452608, {0xc0003b0b60, 0x2, 0x2})
	/home/soharab/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000600608)
	/home/soharab/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x0?)
	/home/soharab/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x13
main.main()
	cmd/fission-cli/main.go:31 +0x2b

Which issue(s) this PR fixes:

Fixes #2961

Testing

Package resource

apiVersion: fission.io/v1
kind: Package
metadata:
  creationTimestamp: "2024-06-19T07:33:18Z"
  generation: 3
  name: hello-6492eb75-0f4e-4916-a47a-2b94a4deeb58
  namespace: default
  resourceVersion: "789319"
  uid: 3cabf95a-2af9-459f-8d0f-0c5463c02320
spec:
  deployment:
    checksum: {}
  environment:
    name: go-120
    namespace: default
  source:
    checksum: {}
    literal: UEsDBBQACAAIACY801gAAAAAAAAAAAAAAAAIAAkAaGVsbG8uZ29VVAUAAbiJcmY0zD1LxEAQh/E68yn+pkrkuPSCvbUggi/Fmp0kg5fZdWZCCH55Ubz2gedX0/iZZsaaRIlkrcUCHTWtcgxLRG2pJxoGPCTNFzaIIxYGa9iBWkQDUzHEIo5J3KUopk3HkKI0bTpez27Hr3d+ZK9FnZ9Ngu0Ew+1//9rYo8c3NavPuLtH+1RzCs54kVo5n7AXu+SbN22p2c9/QPf6/nEEd6vPfU8/AwBQSwcIuyKb76UAAADOAAAAUEsBAhQDFAAIAAgAJjzTWLsim++lAAAAzgAAAAgACQAAAAAAAAAAALSBAAAAAGhlbGxvLmdvVVQFAAG4iXJmUEsFBgAAAAABAAEAPwAAAOQAAAAAAA==
    type: literal
$ fission pkg getdeploy --name hello-6492eb75-0f4e-4916-a47a-2b94a4deeb58
&<�X    hello.goUT��rf4�=K�@��:�)��J�􂽵 �/Ś�$���uf~yQ����W���fƚD�d��5�r
                                                                      KDm�'�<$�6�#k؁ZDS1�"�Iܥ(�Mǐ�4m:^�nǯw~d�E��M������أ�75�ϸ�G�Ts
�x�Z9����7m���@���qw��}O?P�"���&<�X�"�����hello.goUT��rfPK?�

Checklist:

  • I ran tests as well as code linting locally to verify my changes.
  • I have done manual verification of my changes, changes working as expected.
  • I have added new tests to cover my changes.
  • My changes follow contributing guidelines of Fission.
  • I have signed all of my commits.

```
If deployment archive is empty then command will return source archive.
Deployment can be empty if pkg build failed or in running state.
```

Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.59%. Comparing base (9b978cf) to head (ed475d8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2960      +/-   ##
==========================================
- Coverage   44.59%   44.59%   -0.01%     
==========================================
  Files         236      236              
  Lines       24212    24211       -1     
==========================================
- Hits        10797    10796       -1     
  Misses      12013    12013              
  Partials     1402     1402              
Flag Coverage Δ
unittests 44.59% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@soharab-ic soharab-ic requested a review from sanketsudake June 19, 2024 09:12
@sanketsudake sanketsudake merged commit 4c4b574 into main Jun 20, 2024
@sanketsudake sanketsudake deleted the fix-pkg-getdeploy-cmd branch June 26, 2024 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fission-CLI command pkg getdeploy returns error nil pointer dereference
2 participants