-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial: update loadbalancer metadata status in resolvers (#273)
* bump testcontainers to v0.26.0 Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * bump chart dependencies - bitnami common (2.13.3), reloader (1.0.50) Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * add supergraph url, metadata status namespace id, timeout and oidc client to config Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * update metadata status for loadbalancer cud Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * move to supergraph config Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * port cud - update loadbalancer status Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * permissions ignoreNoResponders Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * update loadbalancer status - pools/origins cud Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * add oidc client issuer to chart Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * use helper resolver method Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * conditional metadata usage Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> * loadbalancer metadata pkg Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com> --------- Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com>
- Loading branch information
Showing
21 changed files
with
337 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
dependencies: | ||
- name: common | ||
repository: https://charts.bitnami.com/bitnami | ||
version: 2.9.2 | ||
version: 2.13.3 | ||
- name: reloader | ||
repository: https://stakater.github.io/stakater-charts | ||
version: 1.0.41 | ||
digest: sha256:fdc264d2df58440f4ffbe739352a634726fb29cacd9beec3b4f20eab34b890e6 | ||
generated: "2023-10-02T18:43:45.099356257Z" | ||
version: 1.0.50 | ||
digest: sha256:f1aa54b58b177001f10e6c2d72d39de7bba5e3ca5bf84dffb2256e40b31d4ce6 | ||
generated: "2023-11-07T16:03:46.737333402Z" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package graphapi | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
metadata "go.infratographer.com/metadata-api/pkg/client" | ||
"go.infratographer.com/x/gidx" | ||
|
||
lbstate "go.infratographer.com/load-balancer-api/pkg/metadata" | ||
|
||
"go.infratographer.com/load-balancer-api/internal/config" | ||
) | ||
|
||
const metadataStatusSource = "load-balancer-api" | ||
|
||
// Metadata interface for the metadata client | ||
type Metadata interface { | ||
StatusUpdate(ctx context.Context, input *metadata.StatusUpdateInput) (*metadata.StatusUpdate, error) | ||
} | ||
|
||
// LoadBalancerStatusUpdate updates the state of a load balancer in the metadata service | ||
func (r Resolver) LoadBalancerStatusUpdate(ctx context.Context, loadBalancerID gidx.PrefixedID, state lbstate.LoadBalancerState) error { | ||
if r.metadata == nil { | ||
r.logger.Warnln("metadata client not configured") | ||
return nil | ||
} | ||
|
||
if _, err := r.metadata.StatusUpdate(ctx, &metadata.StatusUpdateInput{ | ||
NodeID: loadBalancerID.String(), | ||
NamespaceID: config.AppConfig.Metadata.StatusNamespaceID.String(), | ||
Source: metadataStatusSource, | ||
Data: json.RawMessage(fmt.Sprintf(`{"state": "%s"}`, state)), | ||
}); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.