This message was deleted.
# google-cloud
s
This message was deleted.
r
We are also using Cloud Run with a Docker build in Go, so I figured I should chime in here. I should qualify that I didn’t actually write the code that I’m reading while answering this question, my colleague did. First we either use the supplied docker image and tag (if already built and pushed to artifacts registry)
Copy code
docker.NewImage(ctx, getName(ctx), &docker.ImageArgs{
	ImageName: pulumi.String(imageName),
	Build:     &docker.DockerBuildArgs{
        Context: pulumi.String(dockerCtx),
    },
	// Empty registry args to use auto gcloud credentials
	Registry: docker.ImageRegistryArgs{},
})
This image is then used to obtain an image name and is fed into a ServiceTemplateArgs object to fulfill the Template argument of the service. (Image attached) At this point, we use a
pulumi.DependsOn(ctx.DockerImage)
object like you’ve mentioned when constructing the
cloudrunv2.NewService
object. (Image attached)
👍 1
It would appear this seems to work in our case. It sounds like it included all the same steps you took. If you need specific details or lines of code, I’m willing to help. Just let me know where it might be fuzzy for you.
@bitter-train-58221
b
Hi, Tim. According to pulumi’s doc, the depends parameter is the key to have cloud run service to hold on updating until the image is pushed. Try log the dockerImage variable you passed in and make sure it’s not null. Brian has shown most of the details how we did it. LMK if you still need more help
r
Hey @rich-motorcycle-3089 and @bitter-train-58221 appreciate the insights. I’ll review the code you have shared and explore my implementation. If you don’t mind I might hit you both up if I can’t work it out and see if you can give me any additional insights. Thanks so much for your help!
👍 1
r
Yep, feel free
r
Cheers Gents
Yeah; So I went back and tried this. I have put the dependency in; I am certain it is there. I am not sure what is going on. But the Cloud Run objects still don’t seem to wait for the Build AND push of the image ti complete. It’s really strange. I will include some screenshots.
This is the Build object
The Cloud Run service references this image:
with the dependency defined as follows:
Pulumi Up; Builds the Images on preview.
apply
It doesn’t wait..
Okay; So after Smashing my head against the wall for some hours… There is a subtle but important difference between “ImageName” and “BaseImageName” I was referencing BaseImageName and this isn’t correct. I needed to reference the ImageName in my CloudRunService.
b
by looking at the error, It seems more like the image is not found tho, and the cloudrun deployment indeed ran after the docker image is pushed 1. Are you sure the image is in that registry? 2. Can you try only deploying the cloudrun with certain existing image name and see if that works?
r
Sorry Tim, apparently my Slack notifications are off for the Pulumi workspace haha. It sounds like you may have discovered the underlying issue. Is your environment running now? I’m not sure what
BaseImageName
is referencing, but perhaps Pulumi was concluding the image that it points to did in fact exist and the dependency was met so it didn’t need to wait any further.
Based on the docs, it reads to me that it might be the image name minus any tagging or sha annotations. Therefore, dependsOn may have been checking for any version of the image to exist in the registry. https://www.pulumi.com/registry/packages/docker/api-docs/image/#outputs
I turned on notification for threads as well. Maybe that’s why I didn’t see this. If I go dark feel free to DM me to get my attention
r
Heys all; No problems about the notifications. Its also a battle of the timezones. It was driving me crazy but you are right it is now solved. ImageName” vs “BaseImageName” was the underlying issue. To clarify further. The Image was 100% in the Repository by the end of all things. However in the original configuration when using BaseImageName was not working for dependency. So I could see it pushing the image after all my CloudRun services had updated. Having switched to ImageName all was resolved immediately. The dependancy graph worked exactly as you would expect it too and with the correct Tags also. Which would have been the next sticking point.
👍 1