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

Fix panic when listing serverless instances #4

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

krzysdabro
Copy link
Contributor

This change fixes the panics during listing the Aurora Serverless instances (db.serverless). The solution is to print dashes whenever compute data is not available.

rds-health list
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104d31c7c]

goroutine 1 [running]:
github.com/zalando/rds-health/internal/show/minimal.init.func1({{0x1400036a1e0, 0x1d}, {0x140002beae0, 0x28}, {0x140002a5480, 0xd}, {0x14000405000, 0x1, 0x1}, 0x14000426960, ...})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/minimal/minimal.go:36 +0x8c
github.com/zalando/rds-health/internal/show.FromShow[...].Show(...)
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:31
github.com/zalando/rds-health/internal/show.Seq[...].Show(0x1400012a1c0?, {0x140001eb180?, 0x69?, 0x70?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:75 +0xd8
github.com/zalando/rds-health/internal/show.Printer2[...].Show(0x14000534750?, {{0x140002fb580, 0x1d}, 0x140004263e0, {0x140001eb1f0, 0x1?, 0x1?}, {0x140001eb180?, 0x1?, 0x1?}})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:104 +0xc8
github.com/zalando/rds-health/internal/show.Printer2[...].Show(0x0?, {{0x140002fb580, 0x1d}, 0x140004263e0, {0x140001eb1f0, 0x1?, 0x1?}, {0x140001eb180?, 0x1?, 0x1?}})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:115 +0x2c8
github.com/zalando/rds-health/internal/show.Seq[...].Show(0x106864be0?, {0x14000000fc0?, 0x1400036be00?, 0x4?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:75 +0xc8
github.com/zalando/rds-health/internal/show/minimal.init.Region[...].FMap.func32()
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:40 +0x58
github.com/zalando/rds-health/internal/show.FromShow[...].Show(...)
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:31
github.com/zalando/rds-health/internal/show.Printer2[...].Show(0x104b68ae0?, {{0x14000000fc0, 0x4, 0x4}, {0x140001eb490, 0x1?, 0x1?}})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:104 +0xac
github.com/zalando/rds-health/internal/show/minimal.init.Prefix[...].FMap.func24()
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:40 +0x78
github.com/zalando/rds-health/internal/show.FromShow[...].Show(...)
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:31
github.com/zalando/rds-health/cmd.list(0x10685f1c0?, {0xc?, 0x10607b1a0?, 0x1400005b700?}, {0x106098d28?, 0x1400000e480?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/cmd/list.go:58 +0x16c
github.com/zalando/rds-health/cmd.init.WithService.func1(0x10685f1c0, {0x1068cba60, 0x0, 0x0})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/cmd/root.go:230 +0x138
github.com/spf13/cobra.(*Command).execute(0x10685f1c0, {0x1068cba60, 0x0, 0x0})
	/Users/krzysiu/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x568
github.com/spf13/cobra.(*Command).ExecuteC(0x10685f6c0)
	/Users/krzysiu/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x318
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/krzysiu/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
github.com/zalando/rds-health/cmd.Execute({0x140000487b0?, 0x16?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/cmd/root.go:29 +0x54
main.main()
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/main.go:25 +0xc4
rds-health list -v
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10029002c]

goroutine 1 [running]:
github.com/zalando/rds-health/internal/show/verbose.init.func1({{0x14000325720, 0x1d}, {0x140003a4570, 0x28}, {0x14000395110, 0xd}, {0x14000448530, 0x1, 0x1}, 0x1400044db80, ...})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/verbose/verbose.go:46 +0x1cc
github.com/zalando/rds-health/internal/show.FromShow[...].Show(...)
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:31
github.com/zalando/rds-health/internal/show.Seq[...].Show(0x28?, {0x140002690a0?, 0xd?, 0x14000448540?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:75 +0xd8
github.com/zalando/rds-health/internal/show.Printer2[...].Show(0x1015cd4b0?, {{0x14000045980, 0x1d}, 0x1400044d500, {0x14000269110, 0x1?, 0x1?}, {0x140002690a0?, 0x1?, 0x1?}})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:104 +0xc8
github.com/zalando/rds-health/internal/show.Printer2[...].Show(0x0?, {{0x14000045980, 0x1d}, 0x1400044d500, {0x14000269110, 0x1?, 0x1?}, {0x140002690a0?, 0x1?, 0x1?}})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:115 +0x2c8
github.com/zalando/rds-health/internal/show.Seq[...].Show(0x2?, {0x14000001b00?, 0x0?, 0x1?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:75 +0xc8
github.com/zalando/rds-health/internal/show/verbose.init.Region[...].FMap.func16()
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:40 +0x58
github.com/zalando/rds-health/internal/show.FromShow[...].Show(...)
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:31
github.com/zalando/rds-health/internal/show.Printer2[...].Show(0x101074b80?, {{0x14000001b00, 0x4, 0x4}, {0x140002693b0, 0x1?, 0x1?}})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/internal/show/show.go:104 +0xac
github.com/zalando/rds-health/cmd.list(0x140002e8ef0?, {0xc?, 0x1015cf1a0?, 0x140001fd680?}, {0x1015ecd28?, 0x1400019c480?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/cmd/list.go:58 +0x16c
github.com/zalando/rds-health/cmd.init.WithService.func1(0x101db31c0, {0x140001a9420, 0x0, 0x1})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/cmd/root.go:230 +0x138
github.com/spf13/cobra.(*Command).execute(0x101db31c0, {0x140001a9410, 0x1, 0x1})
	/Users/krzysiu/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x568
github.com/spf13/cobra.(*Command).ExecuteC(0x101db36c0)
	/Users/krzysiu/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x318
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/krzysiu/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
github.com/zalando/rds-health/cmd.Execute({0x140001c4720?, 0x16?})
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/cmd/root.go:29 +0x54
main.main()
	/Users/krzysiu/go/pkg/mod/github.com/zalando/[email protected]/main.go:25 +0xc4

@fogfish
Copy link
Member

fogfish commented Mar 3, 2024

Thank you for the bug report and fix.

The root cause for the panic is absence of database instance info for serverless deployments:
https://github.com/zalando/rds-health/blob/main/internal/discovery/discovery.go#L53
https://github.com/zalando/rds-health/blob/main/internal/database/database.go#L67

We have tried to use the graceful degradation strategy to continue on execution if api fails to provide result.

Question: Is it enough for us to fix "view" only? Shall we make improvements in the model itself? What do you think?

The proposed fix on the renderer is good and reasonable.

@krzysdabro
Copy link
Contributor Author

I think long-term solution would be to display ACU per cluster.

The view could look like this (RESOURCES column instead of CPU and MEM)

AZ ENGINE            VSN    INSTANCE        RESOURCES       STORAGE TYPE   RO NAME
   aurora-postgresql 15.3                   120 ACU                           example-production
1b aurora-postgresql 15.3   db.serverless                   1 GiB aurora      example-production-instance-1
1a aurora-postgresql 15.3   db.serverless                   1 GiB aurora   ro example-production-instance-2
   aurora-postgresql 13.8                   4 ACU                             example-stage
1a aurora-postgresql 13.8   db.serverless                   1 GiB aurora      example-stage-instance-1
1a postgres          13.10  db.t4g.small    2 vCPU / 4 GiB  20 GiB gp3        single-instance

This can be achieved by calling DescribeDBClusters and looking up the corresponding field based on the cluster type:

  • Serverless v1: Capacity
  • Serverless v2: ServerlessV2ScalingConfiguration
  • Limitless Database: LimitlessDatabase

@fogfish
Copy link
Member

fogfish commented Mar 4, 2024

👍

@fogfish
Copy link
Member

fogfish commented Mar 4, 2024

@pioneerit Could you please check this fix?

@pioneerit
Copy link
Member

👍

@fogfish fogfish merged commit 8228f28 into zalando:main Mar 4, 2024
4 checks passed
@fogfish
Copy link
Member

fogfish commented Mar 4, 2024

@krzysdabro Thank you for contribution and reporting the issue!

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.

3 participants