Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Dec 19, 2024
1 parent 7de2392 commit 6b086bd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/handlers/deploy_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (h *Handler) DeployEC2AppVersion(w http.ResponseWriter, r *http.Request) {

go func() {
if err := plan.Execute(store.GetStore(), p); err != nil {
logger.Error(errors.Wrap(err, "failed to execute upgrade plan"))
logger.Error(errors.Wrapf(err, "failed to execute plan %s", p.ID))
}
}()

Expand Down
6 changes: 3 additions & 3 deletions pkg/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Resume(s store.Store) error {

go func() {
if err := Execute(s, p); err != nil {
logger.Error(errors.Wrap(err, "execute plan"))
logger.Error(errors.Wrapf(err, "failed to execute plan %s", p.ID))
}
}()

Expand Down Expand Up @@ -160,7 +160,7 @@ func executeStep(s store.Store, p *types.Plan, step *types.PlanStep) (finalError
switch step.Type {
case types.StepTypeAppUpgradeService:
if step.Status != types.StepStatusPending {
return errors.Errorf("step %q cannot be resumed", step.Name, p.ID)
return errors.Errorf("step %q cannot be resumed", step.Name)
}
if err := executeAppUpgradeService(s, p, step); err != nil {
return errors.Wrap(err, "execute app upgrade service")
Expand Down Expand Up @@ -201,7 +201,7 @@ func waitForStep(s store.Store, p *types.Plan, stepID string) error {
}
}
if stepIndex == -1 {
return errors.Errorf("step %s not found in plan", stepID)
return errors.Errorf("step %s not found in plan %s", stepID, p.ID)
}

if p.Steps[stepIndex].Status == types.StepStatusComplete {
Expand Down
3 changes: 3 additions & 0 deletions pkg/upgradeservice/handlers/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/kotsutil"
"github.com/replicatedhq/kots/pkg/logger"
"github.com/replicatedhq/kots/pkg/util"
)

type InfoResponse struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
HasPreflight bool `json:"hasPreflight"`
IsConfigurable bool `json:"isConfigurable"`
IsEC2Install bool `json:"isEC2Install"`
}

func (h *Handler) Info(w http.ResponseWriter, r *http.Request) {
Expand All @@ -33,6 +35,7 @@ func (h *Handler) Info(w http.ResponseWriter, r *http.Request) {
response.Success = true
response.HasPreflight = kotsKinds.HasPreflights()
response.IsConfigurable = kotsKinds.IsConfigurable()
response.IsEC2Install = util.IsEC2Install()

JSON(w, http.StatusOK, response)
}
4 changes: 3 additions & 1 deletion web/src/components/upgrade_service/ConfirmAndDeploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ const ConfirmAndDeploy = ({
setCurrentStep,
hasPreflight,
isConfigurable,
isEC2Install,
}: {
isConfigurable: boolean;
hasPreflight: boolean;
setCurrentStep: (step: number) => void;
isEC2Install: boolean;
}) => {
useEffect(() => {
setCurrentStep(2);
Expand All @@ -91,8 +93,8 @@ const ConfirmAndDeploy = ({
const { sequence = "0", slug } = useParams<keyof KotsParams>() as KotsParams;
const { mutate: deployKotsDownstream, isLoading } = useDeployAppVersion({
slug,
sequence,
closeModal,
isEC2Install: isEC2Install,
});

const { data: preflightCheck, error: getPreflightResultsError } =
Expand Down
1 change: 1 addition & 0 deletions web/src/components/upgrade_service/UpgradeService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const UpgradeServiceBody = () => {
isConfigurable={upgradeInfo?.isConfigurable}
hasPreflight={upgradeInfo?.hasPreflight}
setCurrentStep={setCurrentStep}
isEC2Install={upgradeInfo?.isEC2Install}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useQuery } from "@tanstack/react-query";
type UpgradeInfoResponse = {
isConfigurable: boolean;
hasPreflight: boolean;
isEC2Install: boolean;
};

type UpgradeInfoParams = {
Expand Down
19 changes: 10 additions & 9 deletions web/src/components/upgrade_service/hooks/postDeployAppVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { useMutation } from "@tanstack/react-query";
async function postDeployAppVersion({
slug,
body,
isEC2Install,
}: {
apiEndpoint?: string;
body: string;
slug: string;
sequence: string;
isEC2Install: boolean;
}) {
const response = await fetch(
// TODO (@salah): revert this
`${process.env.API_ENDPOINT}/upgrade-service/app/${slug}/ec2-deploy`,
let url = `${process.env.API_ENDPOINT}/upgrade-service/app/${slug}/deploy`;
if (isEC2Install) {
url = `${process.env.API_ENDPOINT}/upgrade-service/app/${slug}/ec2-deploy`;
}
const response = await fetch(url,
{
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -45,12 +47,12 @@ function makeBody({

function useDeployAppVersion({
slug,
sequence,
closeModal,
isEC2Install,
}: {
slug: string;
sequence: string;
closeModal: () => void;
isEC2Install: boolean;
}) {
return useMutation({
mutationFn: ({
Expand All @@ -62,9 +64,8 @@ function useDeployAppVersion({
}) =>
postDeployAppVersion({
slug,
sequence,

body: makeBody({ continueWithFailedPreflights, isSkipPreflights }),
isEC2Install,
}),
onError: (err: Error) => {
console.log(err);
Expand Down

0 comments on commit 6b086bd

Please sign in to comment.