Skip to content

Conversation

rokatyy
Copy link
Contributor

@rokatyy rokatyy commented Sep 29, 2025

📝 Description

Bug was found during writing tests in #3821

We did docker rm -f instead of docker stop, which didn’t allow to run termination callback properly

Docker stop docs: docker container stop
docker rm docs: docker container rm


✅ Checklist

  • I updated the documentation (if applicable)
  • I have tested the changes in this PR

🧪 Testing

tested as part of #3821


🔗 References


🚨 Breaking Changes?

  • Yes (explain below)
  • No

Copy link
Collaborator

@weilerN weilerN left a comment

Choose a reason for hiding this comment

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

LGTM with a small suggestion

"functionName", createFunctionOptions.FunctionConfig.Meta.Name,
"containerID", container.ID)
if err := p.dockerClient.StopContainer(container.ID); err != nil {
if err := p.dockerClient.StopContainer(container.ID, int(p.GetConfig().Local.FunctionContainersGracefulTerminationTimeout.Seconds())); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest to add a handler function- p.GetConfig().GetFunctionContainersGracefulTerminationTimeout (or shorter name) to verifies backward compitibilty if this value is missing, like this for example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@weilerN I believe those are different scenarios. I don't see any BC issues here, we always enrich if it's empty in enrich platform step.

Comment on lines 1250 to 1251
if err := p.dockerClient.StopContainer(container.ID, int(p.GetConfig().Local.FunctionContainersGracefulTerminationTimeout.Seconds())); err != nil {
return 0, errors.Wrap(err, "Failed to stop a container")
Copy link
Contributor

Choose a reason for hiding this comment

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

If 1 container fails but there are still others left, we'll skip them don't try to stop them.
I know that was the previous implementation, but maybe we can continue before failing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, will change that

@github-actions github-actions bot added the ci label Sep 29, 2025
Comment on lines 1084 to 1086
wg.Add(1)
go func() {
defer wg.Done()
Copy link
Contributor

Choose a reason for hiding this comment

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

wg.Go() ?

Copy link
Contributor

@TomerShor TomerShor left a comment

Choose a reason for hiding this comment

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

LGTM, minor suggestion

Copy link
Collaborator

@weilerN weilerN left a comment

Choose a reason for hiding this comment

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

Looking good, a few minor comments

if errPtr := errDuringStop.Load(); errPtr != nil {
return *errPtr
}
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return nil
p.Logger.InfoWithCtx(ctx, "Successfully deleted function",
"name", functionName)
return nil

// no need to fail the entire operation if stopping failed
// we will retry to stop with SIGKILL below
if err = p.dockerClient.StopContainer(containerInfo.ID, int(p.GetConfig().Local.FunctionContainersGracefulTerminationTimeout.Seconds())); err != nil {
errDuringStop.CompareAndSwap(nil, &err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If multiple containers fail to stop, only the first error is returned. I’d suggest collecting all errors instead of keeping just the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's fine to return only the first one as we anyway logged the others

@rokatyy rokatyy merged commit 06f4d60 into nuclio:development Oct 1, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants