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

Use exec in registryctl so signals are passed properly #16642

Merged
merged 1 commit into from
May 25, 2022

Conversation

mac-chaffee
Copy link
Contributor

@mac-chaffee mac-chaffee commented Apr 3, 2022

When containers are terminated in Kubernetes, Kubernetes will send a SIGTERM to PID1, wait for terminationGracePeriodSeconds, then SIGKILL it.

But since PID1 in registryctl is bash, that SIGTERM signal is not automatically passed to the registryctl process, forcing Kubernetes to wait the whole terminationGracePeriodSeconds to update the registry Pod.

This PR fixes that issue by using exec, which makes registryctl itself be PID1 so that it receives the SIGTERM signal.

Wasn't able to test this locally, I think the build system needs some TLC, especially for testing individual components. Like for example, I need a local copy of registry to build the registryctl image which is downloaded from https://storage.googleapis.com/harbor-builds/bin/registry/release-v2.8.0-patch-redis/registry, but that URL 404s.

Signed-off-by: Mac Chaffee <machaffe@renci.org>
@mac-chaffee
Copy link
Contributor Author

Friendly bump :)

Copy link
Member

@Vad1mo Vad1mo left a comment

Choose a reason for hiding this comment

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

thx, this was super annoying.

Copy link
Contributor

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

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

lgtm

@wy65701436 wy65701436 closed this May 25, 2022
@wy65701436 wy65701436 reopened this May 25, 2022
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #16642 (bfba827) into main (a5b5e21) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16642      +/-   ##
==========================================
+ Coverage   67.31%   67.33%   +0.01%     
==========================================
  Files         953      968      +15     
  Lines       79028    81132    +2104     
  Branches     2331     2550     +219     
==========================================
+ Hits        53198    54630    +1432     
- Misses      22259    22823     +564     
- Partials     3571     3679     +108     
Flag Coverage Δ
unittests 67.33% <ø> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...ortal/src/app/shared/pipes/harbor-datetime.pipe.ts 36.00% <0.00%> (-39.00%) ⬇️
...ortal/src/app/oidc-onboard/oidc-onboard.service.ts 60.00% <0.00%> (-15.00%) ⬇️
src/pkg/audit/manager.go 87.50% <0.00%> (-12.50%) ⬇️
...ponents/label/label-piece/label-piece.component.ts 71.42% <0.00%> (-11.91%) ⬇️
...hared/components/global-message/message.service.ts 80.00% <0.00%> (-10.00%) ⬇️
...settings/account-settings-modal-service.service.ts 40.00% <0.00%> (-10.00%) ⬇️
src/portal/src/app/app.component.ts 75.00% <0.00%> (-9.62%) ⬇️
src/server/middleware/util/util.go 91.66% <0.00%> (-8.34%) ⬇️
...es/vulnerability/vulnerability-config.component.ts 54.07% <0.00%> (-7.84%) ⬇️
...-confirmation-dialog/confirmation-batch-message.ts 50.00% <0.00%> (-7.15%) ⬇️
... and 278 more

@wy65701436 wy65701436 merged commit ecc8c59 into goharbor:main May 25, 2022
sluetze pushed a commit to sluetze/harbor that referenced this pull request Oct 29, 2022
@mac-chaffee
Copy link
Contributor Author

So it seems that code for handing graceful shutdown might be bugged:

log.Infof("Registry controller is shut down properly")

When registryctl receives SIGTERM, it just logs the following but doesn't actually shut down:

2022-11-10T23:10:17Z [INFO] [/registryctl/main.go:68]: Got an interrupt, shutting down...
2022-11-10T23:10:17Z [INFO] [/registryctl/main.go:72]: Registry controller is shut down properly

The bug isn't obvious to me as a golang novice, but is there some context we're not cancelling or a goroutine still running or something?

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