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

[kots]: delete channel on branch delete #11323

Merged
merged 1 commit into from
Jul 19, 2022
Merged

Conversation

mrsimonemms
Copy link
Contributor

@mrsimonemms mrsimonemms commented Jul 12, 2022

Description

GitHub Action to delete a KOTS channel on branch deletion. This will cut down on the amount of manual work that @gitpod-io/engineering-self-hosted have to do in housekeeping in the Replicated vendor portal.

In most cases, this will actually do nothing. Most branches do not create a channel in Replicated - the only time is if a PR is run with /werft run publish-to-kots when it will publish to a channel with the same name as the branch. This Action exists to delete these channels when the branch is deleted.

If a channel has customers assigned to it, it will not delete the channel as the workflow is that channels must have zero customers before they can be deleted - that's a failsafe against customer channels such as stable or enterprise being deleted. Also, this Action can never error as the continue-on-error: true param is set.

/hold Before this is merged, a secret will need to be added to our GitHub settings.

How to test

I have built this using a noddy repo and done various tests to prove it works:

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@mrsimonemms
Copy link
Contributor Author

/hold cancel

The secrets have been added to GitHub Actions

@mrsimonemms mrsimonemms requested a review from a team July 18, 2022 14:22
@mrsimonemms mrsimonemms added the team: delivery Issue belongs to the self-hosted team label Jul 18, 2022
Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

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

LGTM, apart from that question!

/hold just on the discussion. Feel free to remove this if you don't think that's necessary. :)

fi

# Allowed to fail if customers on channel - this will need to be manually deleted
replicated channel rm "${CHANNEL_ID}" || true
Copy link
Contributor

Choose a reason for hiding this comment

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

TIOLI: How about we also do the check manually? Just want to be on the safer side, as its a v important operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To the best of my knowledge, there's no way of checking if a channel has customers using the CLI. Honestly, it's all a little undocumented so I've had to dig through the source code. The closest we have is channel counts but keeps coming back with Error: This feature is not supported for Kots applications. which makes no sense.

It is documented that you cannot delete a channel with customers and there's no option to force delete. And we wouldn't habitually use branches with the channel names stable, beta, unstable, enterprise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the elaborate answer. It makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's any issues, we can always get revert this commit (I'm going to create/delete a branch now)

@Pothulapati
Copy link
Contributor

/unhold

@roboquat roboquat merged commit e7e1f54 into main Jul 19, 2022
@roboquat roboquat deleted the sje/delete-kots-channel branch July 19, 2022 06:34
@mrsimonemms
Copy link
Contributor Author

@Pothulapati
Copy link
Contributor

NICE @mrsimonemms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/M team: delivery Issue belongs to the self-hosted team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants