Skip to content

Commit 9823d30

Browse files
johnstcnaslilac
authored andcommitted
fix(enterprise/coderd): remove useless provisioner daemon id from request (#16723)
`ServeProvisionerDaemonRequest` has had an ID field for quite a while now. This field is only used for telemetry purposes; the actual daemon ID is created upon insertion in the database. There's no reason to set it, and it's confusing to do so. Deprecating the field and removing references to it.
1 parent 544f547 commit 9823d30

File tree

5 files changed

+2
-20
lines changed

5 files changed

+2
-20
lines changed

codersdk/provisionerdaemons.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func (c *Client) provisionerJobLogsAfter(ctx context.Context, path string, after
239239
// @typescript-ignore ServeProvisionerDaemonRequest
240240
type ServeProvisionerDaemonRequest struct {
241241
// ID is a unique ID for a provisioner daemon.
242+
// Deprecated: this field has always been ignored.
242243
ID uuid.UUID `json:"id" format:"uuid"`
243244
// Name is the human-readable unique identifier for the daemon.
244245
Name string `json:"name" example:"my-cool-provisioner-daemon"`
@@ -270,7 +271,6 @@ func (c *Client) ServeProvisionerDaemon(ctx context.Context, req ServeProvisione
270271
}
271272
query := serverURL.Query()
272273
query.Add("version", proto.CurrentVersion.String())
273-
query.Add("id", req.ID.String())
274274
query.Add("name", req.Name)
275275
query.Add("version", proto.CurrentVersion.String())
276276

enterprise/cli/provisionerdaemonstart.go

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
225225
}
226226
srv := provisionerd.New(func(ctx context.Context) (provisionerdproto.DRPCProvisionerDaemonClient, error) {
227227
return client.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
228-
ID: uuid.New(),
229228
Name: name,
230229
Provisioners: []codersdk.ProvisionerType{
231230
codersdk.ProvisionerTypeTerraform,

enterprise/coderd/coderdenttest/coderdenttest.go

-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ func newExternalProvisionerDaemon(t testing.TB, client *codersdk.Client, org uui
388388

389389
daemon := provisionerd.New(func(ctx context.Context) (provisionerdproto.DRPCProvisionerDaemonClient, error) {
390390
return client.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
391-
ID: uuid.New(),
392391
Name: testutil.GetRandomName(t),
393392
Organization: org,
394393
Provisioners: []codersdk.ProvisionerType{provisionerType},

enterprise/coderd/provisionerdaemons.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
175175
return
176176
}
177177

178-
id, _ := uuid.Parse(r.URL.Query().Get("id"))
179-
if id == uuid.Nil {
180-
id = uuid.New()
181-
}
182-
183178
provisionersMap := map[codersdk.ProvisionerType]struct{}{}
184179
for _, provisioner := range r.URL.Query()["provisioner"] {
185180
switch provisioner {
@@ -295,7 +290,7 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
295290
api.AGPL.WebsocketWaitMutex.Unlock()
296291
defer api.AGPL.WebsocketWaitGroup.Done()
297292

298-
tep := telemetry.ConvertExternalProvisioner(id, tags, provisioners)
293+
tep := telemetry.ConvertExternalProvisioner(daemon.ID, tags, provisioners)
299294
api.Telemetry.Report(&telemetry.Snapshot{ExternalProvisioners: []telemetry.ExternalProvisioner{tep}})
300295
defer func() {
301296
tep.ShutdownAt = ptr.Ref(time.Now())

enterprise/coderd/provisionerdaemons_test.go

-11
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
5050
defer cancel()
5151
daemonName := testutil.MustRandString(t, 63)
5252
srv, err := templateAdminClient.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
53-
ID: uuid.New(),
5453
Name: daemonName,
5554
Organization: user.OrganizationID,
5655
Provisioners: []codersdk.ProvisionerType{
@@ -180,7 +179,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
180179
defer cancel()
181180
daemonName := testutil.MustRandString(t, 63)
182181
_, err := templateAdminClient.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
183-
ID: uuid.New(),
184182
Name: daemonName,
185183
Organization: user.OrganizationID,
186184
Provisioners: []codersdk.ProvisionerType{
@@ -205,7 +203,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
205203
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
206204
defer cancel()
207205
_, err := another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
208-
ID: uuid.New(),
209206
Name: testutil.MustRandString(t, 63),
210207
Organization: user.OrganizationID,
211208
Provisioners: []codersdk.ProvisionerType{
@@ -229,7 +226,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
229226
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
230227
defer cancel()
231228
_, err := another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
232-
ID: uuid.New(),
233229
Name: testutil.MustRandString(t, 63),
234230
Organization: user.OrganizationID,
235231
Provisioners: []codersdk.ProvisionerType{
@@ -360,7 +356,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
360356
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
361357
defer cancel()
362358
req := codersdk.ServeProvisionerDaemonRequest{
363-
ID: uuid.New(),
364359
Name: testutil.MustRandString(t, 63),
365360
Organization: user.OrganizationID,
366361
Provisioners: []codersdk.ProvisionerType{
@@ -425,7 +420,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
425420
another := codersdk.New(client.URL)
426421
pd := provisionerd.New(func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
427422
return another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
428-
ID: uuid.New(),
429423
Name: testutil.MustRandString(t, 63),
430424
Organization: user.OrganizationID,
431425
Provisioners: []codersdk.ProvisionerType{
@@ -503,7 +497,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
503497
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
504498
defer cancel()
505499
_, err := another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
506-
ID: uuid.New(),
507500
Name: testutil.MustRandString(t, 32),
508501
Organization: user.OrganizationID,
509502
Provisioners: []codersdk.ProvisionerType{
@@ -538,7 +531,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
538531
defer cancel()
539532
another := codersdk.New(client.URL)
540533
_, err := another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
541-
ID: uuid.New(),
542534
Name: testutil.MustRandString(t, 63),
543535
Organization: user.OrganizationID,
544536
Provisioners: []codersdk.ProvisionerType{
@@ -571,7 +563,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
571563
defer cancel()
572564
another := codersdk.New(client.URL)
573565
_, err := another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
574-
ID: uuid.New(),
575566
Name: testutil.MustRandString(t, 63),
576567
Organization: user.OrganizationID,
577568
Provisioners: []codersdk.ProvisionerType{
@@ -698,7 +689,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
698689

699690
another := codersdk.New(client.URL)
700691
srv, err := another.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
701-
ID: uuid.New(),
702692
Name: testutil.MustRandString(t, 63),
703693
Organization: user.OrganizationID,
704694
Provisioners: []codersdk.ProvisionerType{
@@ -758,7 +748,6 @@ func TestGetProvisionerDaemons(t *testing.T) {
758748
defer cancel()
759749
daemonName := testutil.MustRandString(t, 63)
760750
srv, err := orgAdmin.ServeProvisionerDaemon(ctx, codersdk.ServeProvisionerDaemonRequest{
761-
ID: uuid.New(),
762751
Name: daemonName,
763752
Organization: org.ID,
764753
Provisioners: []codersdk.ProvisionerType{

0 commit comments

Comments
 (0)