Skip to content

feat: Automatically update default images on operator startup.#254

Merged
hessjcg merged 5 commits intomainfrom
gh-87-stack
Mar 8, 2023
Merged

feat: Automatically update default images on operator startup.#254
hessjcg merged 5 commits intomainfrom
gh-87-stack

Conversation

@hessjcg
Copy link
Copy Markdown
Collaborator

@hessjcg hessjcg commented Mar 7, 2023

When the operator starts, run a function that will list all AuthProxyWorkloads, find ones that are using the
default proxy image, and trigger an update on those AuthProxyWorkloads. This will cause the Reconcile
function to ensure that the AuthProxyWorkloads are running the latest default version of the proxy image.

Fixes #87

Client: testintegration.Client,
Namespace: testhelpers.NewNamespaceName(name),
ConnectionString: "region:project:inst",
ProxyImageURL: "proxy-image:latest",
Copy link
Copy Markdown
Collaborator Author

@hessjcg hessjcg Mar 7, 2023

Choose a reason for hiding this comment

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

Don't set an explicit proxy image url in tests, use the default.

if err != nil {
t.Fatal(err)
}
func TestUpdateWorkloadContainerWhenDefaultProxyImageChanges(t *testing.T) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the test that demonstrates that when the operator's default image changes, it will automatically update the proxy container image on existing deployments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's definitely add this comment into the code. It really helps.


// Start lists all the AuthProxyWorkload resources and triggers the update on
// the resources with a default proxy image.
func (c *upgradeDefaultProxyOnStartup) Start(ctx context.Context) error {
Copy link
Copy Markdown
Collaborator Author

@hessjcg hessjcg Mar 7, 2023

Choose a reason for hiding this comment

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

The Start() function will be called by ControllerRuntime once the operator is initialized.

case <-ctx.Done():
return nil
default:
err := c.c.List(ctx, l, client.Continue(l.Continue))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

c.c.List() fills l with a paginated list of AuthProxyWorkloads. The token in l.Continue field is used get the next page of the list.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the comment here. Should we add it into the code?

@hessjcg hessjcg changed the title feat: Automatically update default images on operator startup feat: Automatically update default images on operator startup. Mar 8, 2023
@hessjcg hessjcg force-pushed the gh-87-stack branch 2 times, most recently from 7cd1eee to 63bcd4c Compare March 8, 2023 19:11
Base automatically changed from gh-87-default-image-updates to main March 8, 2023 19:19
hessjcg added a commit that referenced this pull request Mar 8, 2023
…iners should be updated. (#253)

When an AuthProxyWorkload uses the default proxy image, use the operator's default proxy image
and the AuthProxyWorkload.Generation together as a key to determine if a workload's proxy containers
need to be updated.

Add tests to ensure that when the default image hardcoded into the operator changes, workloads using
the old default will be identified and reconfigured properly.

There is another PR coming #254 which will automatically check and apply configuration
changes to AuthProxyWorkload resources on operator startup. 

Related to #87
@hessjcg hessjcg marked this pull request as ready for review March 8, 2023 19:20
@hessjcg hessjcg requested a review from a team as a code owner March 8, 2023 19:20
@hessjcg hessjcg requested a review from enocom March 8, 2023 20:36
case <-ctx.Done():
return nil
default:
err := c.c.List(ctx, l, client.Continue(l.Continue))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the comment here. Should we add it into the code?

if err != nil {
t.Fatal(err)
}
func TestUpdateWorkloadContainerWhenDefaultProxyImageChanges(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's definitely add this comment into the code. It really helps.

@hessjcg hessjcg merged commit 2453be6 into main Mar 8, 2023
@hessjcg hessjcg deleted the gh-87-stack branch March 8, 2023 21:36
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.

Upgrade the running proxy container images when the published latest proxy changes.

2 participants