Skip to content

Commit f9788b4

Browse files
Merge pull request #2 from MCBrandenburg/unadmin
fix: remove cluster admin
2 parents 8e63f6e + f939c92 commit f9788b4

File tree

8 files changed

+0
-151
lines changed

8 files changed

+0
-151
lines changed

pkg/prom/collector.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,21 +1280,6 @@ func (c *SolidfireCollector) collectAccounts(ctx context.Context, ch chan<- prom
12801280
return nil
12811281
}
12821282

1283-
func (c *SolidfireCollector) collectClusterAdmins(ctx context.Context, ch chan<- prometheus.Metric) error {
1284-
clusterAdmins, err := c.client.ListClusterAdmins(ctx)
1285-
if err != nil {
1286-
return err
1287-
}
1288-
mu.Lock()
1289-
defer mu.Unlock()
1290-
ch <- prometheus.MustNewConstMetric(
1291-
MetricDescriptions.ClusterAdminCount,
1292-
prometheus.CounterValue,
1293-
float64(len(clusterAdmins.Result.ClusterAdmins)),
1294-
)
1295-
return nil
1296-
}
1297-
12981283
func (c *SolidfireCollector) collectInitiators(ctx context.Context, ch chan<- prometheus.Metric) error {
12991284
initiators, err := c.client.ListInitiators(ctx)
13001285
if err != nil {
@@ -1372,9 +1357,6 @@ func (c *SolidfireCollector) Collect(ch chan<- prometheus.Metric) {
13721357
metricsGroup.Go(func() error {
13731358
return c.collectAccounts(ctx, ch)
13741359
})
1375-
metricsGroup.Go(func() error {
1376-
return c.collectClusterAdmins(ctx, ch)
1377-
})
13781360
metricsGroup.Go(func() error {
13791361
return c.collectInitiators(ctx, ch)
13801362
})

pkg/prom/collector_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,6 @@ func newMockedClient(t *testing.T, mockErrs mockErrors) *testutils.MockSolidfire
238238
require.NoError(t, json.Unmarshal(bytes, &listAccountsResponse))
239239
mockSfClient.On(string(call), mock.Anything).Return(listAccountsResponse, mockErrs[call])
240240

241-
listClusterAdminsResponse := solidfire.ListClusterAdminsResponse{}
242-
call = solidfire.RPCListClusterAdmins
243-
bytes, err = ioutil.ReadFile(testutils.ResolveFixturePath(fixtureBasePath, call))
244-
require.NoError(t, err)
245-
require.NoError(t, json.Unmarshal(bytes, &listClusterAdminsResponse))
246-
mockSfClient.On(string(call), mock.Anything).Return(listClusterAdminsResponse, mockErrs[call])
247-
248241
listInitiatorsResponse := solidfire.ListInitiatorsResponse{}
249242
call = solidfire.RPCListInitiators
250243
bytes, err = ioutil.ReadFile(testutils.ResolveFixturePath(fixtureBasePath, call))

pkg/solidfire/solidfire.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const (
3030
RPCListVolumes RPC = "ListVolumes"
3131
RPCListVolumeStats RPC = "ListVolumeStats"
3232
RPCListAccounts RPC = "ListAccounts"
33-
RPCListClusterAdmins RPC = "ListClusterAdmins"
3433
RPCListInitiators RPC = "ListInitiators"
3534
RPCListVolumeAccessGroups RPC = "ListVolumeAccessGroups"
3635
)
@@ -329,28 +328,6 @@ func (s *Client) ListISCSISessions(ctx context.Context) (ListISCSISessionsRespon
329328
return r, nil
330329
}
331330

332-
func (s *Client) ListClusterAdmins(ctx context.Context) (ListClusterAdminsResponse, error) {
333-
payload := &RPCBody{
334-
Method: RPCListClusterAdmins,
335-
Params: ListClusterAdminsParams{},
336-
ID: 1,
337-
}
338-
339-
payloadBytes, err := json.Marshal(&payload)
340-
r := ListClusterAdminsResponse{}
341-
bodyBytes, err := s.doRpcCall(ctx, payloadBytes)
342-
343-
if err != nil {
344-
return r, err
345-
}
346-
err = json.Unmarshal(bodyBytes, &r)
347-
348-
if err != nil {
349-
return r, err
350-
}
351-
return r, nil
352-
}
353-
354331
func (s *Client) ListAccounts(ctx context.Context) (ListAccountsResponse, error) {
355332
payload := &RPCBody{
356333
Method: RPCListAccounts,

pkg/solidfire/solidfire_test.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -475,49 +475,6 @@ func TestClient_ListAccounts(t *testing.T) {
475475
})
476476
}
477477
}
478-
func TestClient_ListClusterAdmins(t *testing.T) {
479-
fixture, err := ioutil.ReadFile(testutils.ResolveFixturePath(fixtureBasePath, solidfire.RPCListClusterAdmins))
480-
if err != nil {
481-
t.Errorf(err.Error())
482-
}
483-
tests := []struct {
484-
name string
485-
s solidfire.Client
486-
want string
487-
wantErr bool
488-
}{
489-
{
490-
name: "Username of first cluster admin should match fixture",
491-
want: "admin",
492-
},
493-
}
494-
495-
for _, tt := range tests {
496-
t.Run(tt.name, func(t *testing.T) {
497-
defer gock.Off()
498-
//gock.Observe(gock.DumpRequest)
499-
gock.New(sfHost).
500-
Post(sfRPCEndpoint).
501-
MatchType("json").
502-
JSON(solidfire.RPCBody{
503-
ID: 1,
504-
Method: solidfire.RPCListClusterAdmins,
505-
Params: solidfire.ListClusterAdminsParams{},
506-
}).
507-
Reply(200).
508-
BodyString(string(fixture))
509-
gotRaw, err := sfClient.ListClusterAdmins(context.Background())
510-
got := gotRaw.Result.ClusterAdmins[0].Username
511-
if (err != nil) != tt.wantErr {
512-
t.Errorf("Client.ListClusterAdmins() error = %v, wantErr %v", err, tt.wantErr)
513-
return
514-
}
515-
if !reflect.DeepEqual(got, tt.want) {
516-
t.Errorf("Client.ListClusterAdmins() = %v, want %v", got, tt.want)
517-
}
518-
})
519-
}
520-
}
521478

522479
func TestClient_ListInitiators(t *testing.T) {
523480
fixture, err := ioutil.ReadFile(testutils.ResolveFixturePath(fixtureBasePath, solidfire.RPCListInitiators))

pkg/solidfire/types.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ type Interface interface {
5050
ListVolumes(ctx context.Context) (ListVolumesResponse, error)
5151
ListVolumeStats(ctx context.Context) (ListVolumeStatsResponse, error)
5252
ListAccounts(ctx context.Context) (ListAccountsResponse, error)
53-
ListClusterAdmins(ctx context.Context) (ListClusterAdminsResponse, error)
5453
ListInitiators(ctx context.Context) (ListInitiatorsResponse, error)
5554
ListVolumeAccessGroups(ctx context.Context) (ListVolumeAccessGroupsResponse, error)
5655
}
@@ -107,10 +106,6 @@ type ListAccountsParams struct {
107106
// No params needed
108107
}
109108

110-
type ListClusterAdminsParams struct {
111-
// No params needed
112-
}
113-
114109
type ListInitiatorsParams struct {
115110
// No params needed
116111
}
@@ -518,19 +513,6 @@ type ListAccountsResponse struct {
518513
} `json:"result"`
519514
}
520515

521-
type ListClusterAdminsResponse struct {
522-
ID int `json:"id"`
523-
Result struct {
524-
ClusterAdmins []struct {
525-
Access []string `json:"access"`
526-
Attributes interface{} `json:"attributes"`
527-
AuthMethod string `json:"authMethod"`
528-
ClusterAdminID int `json:"clusterAdminID"`
529-
Username string `json:"username"`
530-
} `json:"clusterAdmins"`
531-
} `json:"result"`
532-
}
533-
534516
type ListInitiatorsResponse struct {
535517
ID int `json:"id"`
536518
Result struct {

pkg/testutils/collector.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ solidfire_cluster_account_count 2
99
solidfire_cluster_active_block_space_bytes 4.977419581e+09
1010
solidfire_cluster_active_faults{code="driveAvailable",details="Node ID 1 has 1 available drive(s).",drive_id="0.000000",node_hardware_fault_id="0.000000",node_id="1",node_name="n01",resolved="false",service_id="0.000000",severity="warning",type="drive"} 1
1111
solidfire_cluster_active_sessions 1
12-
solidfire_cluster_admin_account 3
1312
solidfire_cluster_average_io_bytes 0
1413
solidfire_cluster_average_iops 0
1514
solidfire_cluster_block_fullness{level="stage1Happy"} 0
@@ -300,7 +299,6 @@ solidfire_cluster_account_count 2
300299
solidfire_cluster_active_block_space_bytes 4.977419581e+09
301300
solidfire_cluster_active_faults{code="driveAvailable",details="Node ID 1 has 1 available drive(s).",drive_id="0.000000",node_hardware_fault_id="0.000000",node_id="1",node_name="n01",resolved="false",service_id="0.000000",severity="warning",type="drive"} 1
302301
solidfire_cluster_active_sessions 1
303-
solidfire_cluster_admin_account 3
304302
solidfire_cluster_average_io_bytes 0
305303
solidfire_cluster_average_iops 0
306304
solidfire_cluster_block_fullness{level="stage1Happy"} 0

pkg/testutils/solidfire_mock.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ func (m *MockSolidfireClient) ListAccounts(ctx context.Context) (solidfire.ListA
5959
args := m.Called(ctx)
6060
return args.Get(0).(solidfire.ListAccountsResponse), args.Error(1)
6161
}
62-
func (m *MockSolidfireClient) ListClusterAdmins(ctx context.Context) (solidfire.ListClusterAdminsResponse, error) {
63-
args := m.Called(ctx)
64-
return args.Get(0).(solidfire.ListClusterAdminsResponse), args.Error(1)
65-
}
6662
func (m *MockSolidfireClient) ListInitiators(ctx context.Context) (solidfire.ListInitiatorsResponse, error) {
6763
args := m.Called(ctx)
6864
return args.Get(0).(solidfire.ListInitiatorsResponse), args.Error(1)

test/fixtures/ListClusterAdmins.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)